Git Product home page Git Product logo

dfrobot_sim808's Introduction

DFRobot_SIM808

SIM808 GPS/GPRS/GSM arduino shield is an integrated quad-band GSM/GPRS and GPS navigation technology Arduino expansion shields. A credit card size only, according to the standard Arduino pin packaging, compatible with Arduino UNO, arduino Leonardo, arduino Mega and other arduino mainboard. Compared to the previous generation SIM908, SIM808 made some improvement on the performance and stability. In addition to the normal SMS and phone functions, the shield also supports MMS, DTMF, FTP and other functions. You can achieve the data acquisition, wireless data transceiver, IoT application and GPS orientating. The should integrates onboard microphone and headphone jack, saving your cost and making your project easily. it can also directly connect to the GSM and GPS antenna by an external antenna connector.

产品实物图

SKU: TEL0097

Table of Contents

Summary

  • Send and receive GPRS data (TCP/IP, HTTP, etc.)
  • Receive GPS data and A-GPS data
  • Send and receive SMS messages
  • Make and receive phone calls

Installation

To use this library, first download the library file, paste it into the \Arduino\libraries directory, then open the examples folder and run the demo in the folder.

Methods

    /**
     * @fn DFRobot_SIM808
     * @brief Constructor
     * @param mySerial  serial ports for communication, supporting hard and soft serial ports
     * @n Tx, rx, and baudRate can also be passed in this order
     * @return None
     */
    DFRobot_SIM808(SoftwareSerial *mySerial);
    DFRobot_SIM808(HardwareSerial *mySerial);
    DFRobot_SIM808(uint8_t tx, uint8_t rx, uint32_t baudRate = 9600);

    /**
     * @fn getInstance
     * @brief get instance of DFRobot_SIM808 class
     * @return instance of DFRobot_SIM808 class
     */
    static DFRobot_SIM808* getInstance() { return inst; };

    /**
     * @fn init
     * @brief initialize DFRobot_SIM808 module including SIM card check & signal strength
     * @return true if connected, false otherwise
     */
    bool init(void);

    /**
     * @fn checkPowerUp
     * @brief check if DFRobot_SIM808 module is powered on or not
     * @return true on success, false on error
     */
    bool checkPowerUp(void);

    /**
     * @fn powerUpDown
     * @brief power Up DFRobot_SIM808 module (JP has to be soldered)
     * @param pin  pin 9 connected to JP jumper so we can power up and down through software
     * @return None
     */
    void powerUpDown(uint8_t pin);

    /**
     * @fn powerReset
     * @brief power reset for SIM800 board
     * @param pin  (preconfigurated as OUTPUT)
     * @return None
     */
    void powerReset(uint8_t pin);

    /**
     * @fn sendSMS
     * @brief send text SMS
     * @param number  phone number which SMS will be send to
     * @param data  message that will be send to
     * @return true on success, false on error
     */
    bool sendSMS(char* number, char* data);

    /**
     * @fn isSMSunread
     * @brief Check if there is any UNREAD SMS: this function DOESN'T change the UNREAD status of the SMS
     * @return returned value
     * @retval 1~20 - on success, position/index where SMS is stored, suitable for the function ReadSMS
     * @retval -1 - on error
     * @retval 0 - there is no SMS with specified status (UNREAD)
     */
    char isSMSunread(void);

    /**
     * @fn readSMS
     * @brief read SMS, phone and date if getting a SMS message. It changes SMS status to READ
     * @param messageIndex  SIM position to read
     * @param message  buffer used to get SMS message
     * @param length  length of message buffer
     * @param phone  buffer used to get SMS's sender phone number
     * @param datetime  buffer used to get SMS's send datetime
     * @return true on success, false on error
     */
    bool readSMS(int messageIndex, char *message, int length, char *phone, char *datetime); 

    /**
     * @fn readSMS
     * @brief read SMS if getting a SMS message
     * @param buffer  buffer that get from DFRobot_SIM808 module(when getting a SMS, DFRobot_SIM808 module will return a buffer array)
     * @param message  buffer used to get SMS message
     * @param check  whether to check phone number(we may only want to read SMS from specified phone number)
     * @return true on success, false on error
     */
    bool readSMS(int messageIndex, char *message, int length);

    /**
     * @fn deleteSMS
     * @brief delete SMS message on SIM card
     * @param index  the index number which SMS message will be delete
     * @return true on success, false on error
     */
    bool deleteSMS(int index);

    /**
     * @fn callUp
     * @brief call someone
     * @param number  the phone number which you want to call
     * @return true on success, false on error
     */
    bool callUp(char* number);

    /**
     * @fn answer
     * @brief auto answer if coming a call
     * @return None
     */
    void answer(void);

    /**
     * @fn hangup
     * @brief hang up if coming a call
     * @return true on success, false on error
     */
    bool hangup(void);

    /**
     * @fn disableCLIPring
     * @brief Disable +CLIP notification when an incoming call is active, RING text is always shown. See isCallActive function
     * @note This is done in order no to overload serial outputCheck if there is a call active and get the phone number in that case
     * @return true on success, false on error
     */
    bool disableCLIPring(void);

    /**
     * @fn getSubscriberNumber
     * @brief Get Subscriber Number (your number) using AT+CNUM command, but if nothing return, then
     * @n     you need to command this to your SIM900. (See AT+CPBS, AT+CPBW)
     * @n     AT+CPBS="ON"
     * @n     AT+CPBW=1,"+{Your Number}",145
     * @n     AT+CPBS="SM"
     * @param number  your phone number
     * @return true on success, false on error
     */
    bool getSubscriberNumber(char *number);

    /**
     * @fn isCallActive
     * @brief Check if there is a call active and get the phone number in that case
     * @param number  Check if there is a call active and get the phone number in that case
     * @return true on success, false on error
     */
    bool isCallActive(char *number);

    /**
     * @fn getDateTime
     * @brief get DateTime from SIM900 (see AT command: AT+CLTS=1) as string
     * @param buffer  DateTime from SIM900
     * @return true on success, false on error
     * @note If it doesn't work may be for two reasons:
     * @n    1. Your carrier doesn't give that information
     * @n    2. You have to configurate the SIM900 IC.
     * @n    - First with SIM900_Serial_Debug example try this AT command: AT+CLTS?
     * @n    - If response is 0, then it is disabled.
     * @n    - Enable it by: AT+CLTS=1
     * @n    - Now you have to save this config to EEPROM memory of SIM900 IC by: AT&W
     * @n    - Now, you have to power down and power up again the SIM900 
     * @n    - Try now again: AT+CCLK?
     * @n    - It should work now
     * 
     */
    bool getDateTime(char *buffer);

    /**
     * @fn getSignalStrength
     * @brief get Signal Strength from SIM900 (see AT command: AT+CSQ) as integer
     * @param buffer  Signal Strength
     * @return true on success, false on error
     */
    bool getSignalStrength(int *buffer);

    /**
     * @fn sendUSSDSynchronous
     * @brief Send USSD Command Synchronously (Blocking call until unsolicited response is received)
     * @param ussdCommand  command UUSD, ex: *123#
     * @param resultCode  char Result Code, see AT+CUSD command
     * @param response  string response
     * @return true on success, false on error
     */  
    bool sendUSSDSynchronous(char *ussdCommand, char *resultcode, char *response);

    /**
     * @fn cancelUSSDSession
     * @brief Cancel USSD Session
     * @return true on success cancel active session, false on error or because no active session
     */
    bool cancelUSSDSession(void);

/*************************** DFRobot_SIM808 ***************************/

    /**
     * @fn join
     * @brief Connect the DFRobot_SIM808 module to the network.
     * @param apn  APN(Access Point Name)
     * @param userName  user name
     * @param passWord  pass word
     * @return true if connected, false otherwise
     */
    bool join(const __FlashStringHelper *apn = 0, const __FlashStringHelper *userName = 0, const __FlashStringHelper *passWord = 0);

    /**
     * @fn disconnect
     * @brief Disconnect the DFRobot_SIM808 module from the network
     * @return None
     */
    void disconnect(void);

    /**
     * @fn connect
     * @brief Open a tcp/udp connection with the specified host on the specified port
     * @param ptl protocol for socket, TCP/UDP can be choosen
     * @param host host (can be either an ip address or a name. If a name is provided, a dns request will be established)
     * @param port port
     * @param timeout wait seconds till connected
     * @param chartimeout wait milliseconds between characters from DFRobot_SIM808 module
     * @return true if successful, false if error
     */
    bool connect(Protocol ptl, const char * host, int port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);
    bool connect(Protocol ptl, const __FlashStringHelper *host, const __FlashStringHelper *port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT);

    /**
     * @fn is_connected
     * @brief Check if a tcp link is active
     * @return true if successful, false if error
     */
    bool is_connected(void);

    /**
     * @fn close
     * @brief Close a tcp connection
     * @return true if successful, false if error
     */
    bool close(void);

    /**
     * @fn readable
     * @brief check if DFRobot_SIM808 module is readable or not
     * @return true if readable
     */
    int readable(void);

    /**
     * @fn wait_readable
     * @brief wait a few time to check if DFRobot_SIM808 module is readable or not
     * @param wait_time time of waiting
     * @return Returns the length of readable data
     */
    int wait_readable(int wait_time);

    /**
     * @fn wait_writeable
     * @brief wait a few time to check if DFRobot_SIM808 module is writeable or not
     * @param req_size time of waiting
     * @return req_size + 1
     */
    int wait_writeable(int req_size);

    /**
     * @fn send
     * @brief send data to socket
     * @param str string to be sent
     * @param len string length
     * @return return bytes that actually been send
     */
    int send(const char * str, int len);

    /**
     * @fn recv
     * @brief read data from socket
     * @param buf buffer that will store the data read from socket
     * @param len string length need to read from socket
     * @return bytes that actually read
     */
    int recv(char* buf, int len);

    /**
     * @fn listen
     * @brief Enables the selected software serial port to listen
     * @return None
     */
    void listen(void);

    /**
     * @fn isListening
     * @brief Tests to see if requested software serial port is actively listening.
     * @return Now masking enabled, return null
     */
    bool isListening(void);

    /**
     * @fn gethostbyname
     * @brief convert the host to ip
     * @param host host ip string, ex. 10.11.12.13
     * @param ip long int ip address, ex. 0x11223344
     * @return true if successful
     */
    //NOT USED bool gethostbyname(const char* host, uint32_t* ip); 

    /**
     * @fn getIPAddress
     * @brief get IP address
     * @return IP address, char*
     */
    char* getIPAddress(void);

    /**
     * @fn getIPnumber
     * @brief get IP number
     * @return IP number, unsigned long
     */
    unsigned long getIPnumber(void);

    /**
     * @fn getLocation
     * @brief get Location
     * @param apn APN(Access Point Name)
     * @param longitude longitude
     * @param latitude latitude
     * @return true if successful, false if error
     */
    bool getLocation(const __FlashStringHelper *apn, float *longitude, float *latitude);

    /**
     * @fn attachGPS
     * @brief Open GPS
     * @return true if successful, false if error
     */
    bool attachGPS(void);

    /**
     * @fn detachGPS
     * @brief Close GPS
     * @return true if successful, false if error
     */
    bool detachGPS(void);

    /**
     * @fn getTime
     * @brief parse time
     * @param time Time data to be parsed
     * @return None
     */
    void getTime(uint32_t time);

    /**
     * @fn getDate
     * @brief parse date
     * @param date Date data to be parsed
     * @return None
     */
    void getDate(uint32_t date);

    /**
     * @fn parseDecimal
     * @brief Parse a (potentially negative) number with up to 2 decimal digits -xxxx.yy
     * @param term Data to be parsed
     * @return Parsed data
     */
    int32_t parseDecimal(const char *term);

    /**
     * @fn latitudeConverToDMS
     * @brief  latitude Conver To DMS
     * @return None
     */
    void latitudeConverToDMS(void);

    /**
     * @fn LongitudeConverToDMS
     * @brief Longitude Conver To DMS
     * @return None
     */
    void LongitudeConverToDMS(void);

    /**
     * @fn parseGPRMC
     * @brief parser GPRMC, Determine whether gpsbuffer[18] is 'A'
     * @param gpsbuffer GPS buffer data to be parsed
     * @return true if gpsbuffer[18] is 'A'
     */
    bool parseGPRMC(char *gpsbuffer);

    /**
     * @fn getGPRMC
     * @brief Get the parsed GPRMC
     * @return true if successful, false if error
     */
    bool getGPRMC(void);

    /**
     * @fn getGPS
     * @brief get GPS signal
     * @return true if successful, false if error
     */
    bool getGPS(void); 

Compatibility

MCU Work Well Work Wrong Untested Remarks
Arduino Uno
Arduino MEGA2560
Arduino Leonardo

History

  • 2022/02/08 - Version 1.0.0 released.
  • 2022/06/30 - Version 1.0.1 released.

Credits

Written by Jason, 2022. (Welcome to our website)

dfrobot_sim808's People

Contributors

arduinolibrary avatar cnlg avatar qsjhyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dfrobot_sim808's Issues

Where is SoftwareSerial.h ?

When compiling the code, I get the following error:
SoftwareSerial.h:No such file or directory

Where would I find the SoftwareSerial.h file?

Mike

isSMSunread = -1

isSMSunread = -1 i know this is an error but i cant figure it out why this is happening please HELP!

do GPS & TCP Connection are conflict?

Hi,

GPS & TCP Connection are working perfectly separately but it is broken after attaching GPS. Is this the behavior or something wrong in the library?

Sending data via HTTP

Hi,

Fiirst off thanks for the library, the GPS portion works great and is accurate. However, I am having trouble setting up HTTP POST requests to send data to an API. the TCP version is not working for me. Any advise or example code?

Language

I need to send smstext in Danish, I think I need an AT comando that looks like "AT + CSCS = PCDN", how can I make it work?

"getGPS()" does not return actual GPS coordinates.

Hi,

This is a great library which has quickened my development with the SIM808 module. Many thanks for this!

Just as a heads-up, the "getGPS()" function doesn't actually return the GPS coordinates. The function simply divides the return N/S and E/W coordinates by 100 (DFRobot_sim808.cpp:1059 and DFRobot_sim808.cpp:1062) as below:

GPSdata.lat = latitude/100;

// convert longitude from minutes to decimal  
GPSdata.lon= longitude/100;

The above returns really inaccurate coordinates, and does not take into account N/S and E/W (positive and negative) coordinates. I have implemented a more accurate conversion, which converts the GPRMC message to actual coordinates. Please freely replace the code above with the code below (or simplify it!) :

int a, b;
float lat, lon;
float latitude = atof(latp);
float longitude = atof(longp);

// convert latitude from minutes to decimal 
a = latitude / 100;
lat = ((latitude / 100) - a) * 100;
lat /= 60;
lat += a;
if(*latdir == 'S') lat *= -1;
GPSdata.lat = lat;

// convert longitude from minutes to decimal  
b = longitude / 100;
lon = ((longitude / 100) - b) * 100;
lon /= 60;
lon += b;
if(*longdir == 'W') lon *= -1;
GPSdata.lon= lon;

Hope this helps!

is_connected() not working, send() problems.

With code belowe I have problems.

  1. is_connected() does not seem to work
  2. Every few GETs some other string is sent instead GET /hello.txt ...
  3. I get send error but I can see in webserver log that there is request made

BTW what is the proper way of making regular get requests, I thought it would be check if connected, if not connect, send request.

###Serial monitor

AT+CIPSTART="TCP","f.example.org",8666
Connect error
AT+CIPSTATUS
TCP NOT CONNECTED
Sending CMD
GET /hello.txt HTTP/1.0


AT+CIPSEND=27
GET /hello.txt HTTP/1.0

Webserver LOG

5.41.3.224 - - [04/Sep/2017:12:57:07 +0200] "GET /hello.txt HTTP/1.0" 200 5 "-" "-"
95.41.3.224 - - [04/Sep/2017:12:57:27 +0200] "GET /hello.txt HTTP/1.0" 200 5 "-" "-"
31.2.54.24 - - [04/Sep/2017:12:58:30 +0200] "AT+CIPSTART=\x22TCP\x22,\x22f.example." 400 173 "-" "-"
31.2.54.24 - - [04/Sep/2017:12:59:00 +0200] "GET /hello.txt HTTP/1.0" 200 5 "-" "-"

Code

/*
### Connect TCP and send GET request.
1. This example is used to test DFRobot_SIM808 GPS/GPRS/GSM Shield's connect TCP and send GET request.
2. Open the SIM808_TCPConnection example or copy these code to your project
3. Download and dial the function switch to Arduino
4. Open serial helper
5. Waiting for a few minutes, until serial has sent "Connect mbed.org success"
6. Serial will send "Hello world!"

create on 2016/09/23, version: 1.0
by jason
*/
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

//#define PIN_TX    10
//#define PIN_RX    11
//SoftwareSerial mySerial(PIN_TX,PIN_RX);
//DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

//make sure that the baud rate of SIM900 is 9600!
//you can use the AT Command(AT+IPR=9600) to set it through SerialDebug

DFRobot_SIM808 sim808(&Serial);

char http_cmd[] = "GET /hello.txt HTTP/1.0\r\n\r\n";
char buffer[512];

void setup(){
  //mySerial.begin(9600);
  Serial.begin(9600);
  
  //******** Initialize sim808 module *************
  while(!sim808.init()) {
      delay(1000);
       Serial.print("Sim808 init error\r\n");
  }
  delay(3000);  
    
  //*********** Attempt DHCP *******************
  while(!sim808.join(F("internet"))) {
       Serial.println("Sim808 join network error");
      delay(2000);
  }

  //************ Successful DHCP ****************
  Serial.print("IP Address is ");
  Serial.println(sim808.getIPAddress());

}

void makeGetReq()
{
  
  //*********** Establish a TCP connection ************


    
  if(!sim808.connect(TCP,"f.example.org", 8666)) {
       Serial.println("Connect error");
  }else{
      Serial.println("Connect mbed.org success");
  }
  
  if(sim808.is_connected() == false)
  {
    Serial.println("TCP NOT CONNECTED");
  } else if (sim808.is_connected() == true)
  {
    Serial.println("TCP CONNECTED");
  }
  
  //*********** Send a GET request *****************
   Serial.println("Sending CMD");
   Serial.println(http_cmd);
  sim808.send(http_cmd, sizeof(http_cmd)-1);
  delay(5000);
//  while (true) {
//      int ret = sim808.recv(buffer, sizeof(buffer)-1);
//      if (ret <= 0){
//          Serial.println("fetch over...");
//          break; 
//      }
//      buffer[ret] = '\0';
//      Serial.print("Recv: ");
//      Serial.print(ret);
//      Serial.print(" bytes: ");
//      Serial.println(buffer);
//      break;
//  }

  //************* Close TCP or UDP connections **********
  //sim808.close();

  //*** Disconnect wireless connection, Close Moving Scene *******
  //sim808.disconnect();
}

void loop(){

 
  makeGetReq();
  

}

sim808.isSMSunread() detecting an unread message even though there isn't an unread message

hello, I made some modifications to the code which was supposed to receive an SMS message and then get its GPS location and send the GPS location back to whoever sent the SMS message, basically a small GPS tracker, but when I put my SD into the sim808 module to test it, the message index is always 1 when the code proceeded into void loop() detecting an unread message, even though I already read all the messages before putting it in. Is there a way for me to fix this issue, Thank you for reading this. :slight_smile:
here is the complete code:
`#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
bool messageIndex = 0;
char MESSAGE[300];
char lat[12];
char lon[12];
char wspeed[12];

char phone[16];
char datetime[24];

#define PIN_TX 10
#define PIN_RX 11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

void setup()
{
mySerial.begin(9600);
Serial.begin(9600);
//******** Initialize sim808 module *************

if( sim808.attachGPS())
Serial.println("Open the GPS power success, please send SMS message to me!");

else 
Serial.println("Open the GPS power failure");
Serial.print("init message index: ");   //debug code
Serial.println(messageIndex);

}

void loop()
{
//*********** Detecting unread SMS ************************
messageIndex = sim808.isSMSunread();
Serial.print("SMS Index under loop: "); //degbug code
Serial.println(messageIndex);
//*********** At least one UNREAD SMS ***********
if (messageIndex > 0)
{
Serial.println("Entering SMS processing block");

  sim808.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
  //***********In order not to full SIM Memory, is better to delete it**********
  sim808.deleteSMS(messageIndex);
  Serial.print("From number: ");
  Serial.println(phone);  
  Serial.print("Datetime: ");
  Serial.println(datetime);        
  Serial.print("Recieved Message: ");
  Serial.println(message); 

while(!sim808.getGPS())
{
  
}


  Serial.print(sim808.GPSdata.year);
  Serial.print("/");
  Serial.print(sim808.GPSdata.month);
  Serial.print("/");
  Serial.print(sim808.GPSdata.day);
  Serial.print(" ");
  Serial.print(sim808.GPSdata.hour);
  Serial.print(":");
  Serial.print(sim808.GPSdata.minute);
  Serial.print(":");
  Serial.print(sim808.GPSdata.second);
  Serial.print(":");
  Serial.println(sim808.GPSdata.centisecond);
  Serial.print("latitude :");
  Serial.println(sim808.GPSdata.lat);
  Serial.print("longitude :");
  Serial.println(sim808.GPSdata.lon);
  Serial.print("speed_kph :");
  Serial.println(sim808.GPSdata.speed_kph);
  Serial.print("heading :");
  Serial.println(sim808.GPSdata.heading);
  Serial.println();

  float la = sim808.GPSdata.lat;
  float lo = sim808.GPSdata.lon;
  float ws = sim808.GPSdata.speed_kph;

  dtostrf(la, 6, 2, lat); //put float value of la into char array of lat. 6 = number of digits before decimal sign. 2 = number of digits after the decimal sign.
  dtostrf(lo, 6, 2, lon); //put float value of lo into char array of lon
  dtostrf(ws, 6, 2, wspeed);  //put float value of ws into char array of wspeed

  sprintf(MESSAGE, "Latitude : %s\nLongitude : %s\nWind Speed : %s kph\nMy Module Is Working. Mewan Indula Pathirage. Try With This Link.\nhttp://www.latlong.net/Show-Latitude-Longitude.html\nhttp://maps.google.com/maps?q=%s,%s\n", lat, lon, wspeed, lat, lon);
  

   Serial.println("Sim808 init success");
   Serial.println("Start to send message ...");

   Serial.println(MESSAGE);
   Serial.println(phone);

   sim808.sendSMS(phone,MESSAGE);

  //************* Turn off the GPS power ************
  sim808.detachGPS();

}
else
{
Serial.println("No unread SMS");
}

}`

GPS in TEST Mode

Hi,

I have been trying to get your library to work, Here are some issues I found that might be helpful to somebody:

  1. The GPS on the sim808 works without SIM. However, the init function returns false / error if there is no SIM. Minor issue, but would have been nice to know.

  2. The GPS data is accessed by putting the chip on test mode.

bool DFRobot_SIM808::attachGPS()
{
  Serial.println("DFRobot_SIM808::attachGPS");
	 if(!sim808_check_with_cmd("AT+CGNSPWR=1\r\n", "OK\r\n", CMD)) { 
        return false;
    }
	 if(!sim808_check_with_cmd("AT+CGNSTST=1\r\n", "OK\r\n", CMD)) { 
        return false;
    }
	return true;
}

this floods the serial port with a lot of information, so a small serial buffer is likely to overflow (arduino's default is 64 Bytes), so function getGPS() will likely overflow between calls, and never return anything. For this to work, the getGPS() function MUST be called before the serial overflows.

I don't see the point in putting the chip in TEST mode to access functionality that i think should be accessed by using (AT+CGNSINF) instead.

  1. the parse functions, don't work with the string returned by AT+CGNSINF as the format is slightly different.

Cheers....

Not getting exact lat and lon

Hi!

I`m using the library, and, for example, if my location is: -45.344454, -32.098987, the example code Get_GPS returns 45.344454, 32.098987 (with no negative). How can I return the negative?

DFRobot_sim808 library not compatible with ESP8266 esp8266 nodemcu v3 board

When using the library alone the code run fine, but when include other library like ESP8266wifi.h then the IDE when complied will indicate below error

In file included from C:\Users\crazy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:28:0,

from F:\crazy\Download\combine\combine.ino:10:

C:\Users\crazy\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\libraries\ESP8266WiFi\src/include/wl_definitions.h:73:17: error: redeclaration of 'CLOSED'

CLOSED = 0,

             ^

In file included from F:\crazy\Download\combine\combine.ino:2:0:

F:\crazy\Documents\Arduino\libraries\DFRobot_SIM808-master/DFRobot_sim808.h:41:5: note: previous declaration 'Protocol CLOSED'

 CLOSED = 0,

 ^

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

i am getting sim 808 init error

hello,
i am using sim 808 for getting gps location and send notification.
but i am getting sim808 init error when i m excuting thios code.
please help me out

Every http request after the first fails

So i am using SIM808 Module with Arduino Mega 2560.The problem is that every time the first POST or GET http request to my server is always successful, but all of the requests after the first one cannot be made.I am getting the fetch over... message.I am following the TCPConnection example.

Latitude and Longitude not correct

Hi! I try to use your library to get information about latitude and longitude, but they are not correct!
I tried other library (TinyGPS) and it gives me correct datas.
I use a shield:
SIM808 EVB - V3.2.4
Do you know why they are incorrect?
Thanks!

DFRobot_SIM808 with blynk, GPS not working

Hi all,

I am a beginner coder and not quite familiar with AT commands. Right now, I am trying to use this library to get GPS data to work with blynk, when I loaded up the example for the GetGPS, everything works fine and I could get latitude and longitude readings However, when I try to implement it onto the blynk sketch, I didn't get any data. My code:

`#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>

#define TINY_GSM_MODEM_SIM808
#define SerialAT Serial
DFRobot_SIM808 sim808(&Serial);

const char auth[] = "";
const char apn[] = "giffgaff.com";
const char user[] = "giffgaff";
const char pass[] = ""

TinyGsm modem(SerialAT);
DFRobot_SIM808 sim808(&Serial);

void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);

// Set GSM module baud rate
SerialAT.begin(9600);
delay(3000);

// Restart takes quite some time
// To skip it, call init() instead of restart()
Serial.println("Initializing modem...");
modem.restart();

String modemInfo = modem.getModemInfo();
Serial.print("Modem: ");
Serial.println(modemInfo);

// Unlock your SIM card with a PIN
//modem.simUnlock("");

Blynk.begin(auth, modem, apn, user, pass);
//Init GPS
//******** Initialize sim808 module *************
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}
//************* Turn on the GPS power************
if(sim808.attachGPS()){
Serial.println("Open the GPS power success");
}else{
Serial.println("Open the GPS power failure");
}
}
void loop(){
Blynk.run();
sim808.getGPS();
Serial.print("Latitude :");
Serial.println(sim808.GPSdata.lat);
Serial.print("longitude :");
Serial.println(sim808.GPSdata.lon);

sim808.detachGPS();
}`

If anyone can help, that would be brilliant. Since I am not entirely sure whether it is the problem with parsing GPS or not, so I have added some of the improvements made by the users like the getInfGPS(), stopGpsDataflow(), startGpsDataflow() into the .cpp and .h files in the library.... but I don't know how and when to use them. Thanks!

Getting GPS altitude

Is there a way to get the gps altitude? Apparently there was an attempt to code that but dfrobot just left it there.
Maybe there is a way to get the nmea data and process it with tinygps?

GPS Data did not get in the indoor location/environment

GPS Data did not get to the indoor location. I have used SIM808 EVB-v 3.2.2 GSM/GPRS + GPS board.

It has the functionality to receive GPS data and A-GPS data.

I have used the same DFRobot Library.

How to get GPS response in the indoor location?
How to access A-GPS?

I did not get GPS data in the indoor location. "I got data outside in the open air environment."

Can you please suggest me to get GPS data in the indoor environment.

Thanks!!

Dfrobot Sim808 join network error with Telenor Denmark

So I trying to get it to join my sim provider network and send TCP request. My Operator is Telenor Danmark
here is the Serial Output
18:09:07.450 -> AT+CFUN=1
18:09:07.484 -> AT+CPIN?
18:09:12.023 -> Init Success, please call or send SMS message to me!
18:09:12.092 -> AT+CSTT="internet","",""
18:09:17.046 -> AT+CIICR
18:09:22.056 -> AT+CIFSR
18:09:27.043 -> Sim808 join network error
18:09:29.062 -> AT+CSTT="internet","",""
18:09:34.077 -> AT+CIICR
18:09:39.068 -> AT+CIFSR
18:09:44.084 -> Sim808 join network error

here is my code
`#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

//#define PIN_TX 10
//#define PIN_RX 11
//SoftwareSerial mySerial(PIN_TX,PIN_RX);
//DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

//make sure that the baud rate of SIM900 is 9600!
//you can use the AT Command(AT+IPR=9600) to set it through SerialDebug

DFRobot_SIM808 sim808(&Serial);

char http_cmd[] = "GET /admin/Scripts/submit?x=8.869531&y=56.414029 HTTP/1.0\r\n\r\n";
char buffer[512];

void setup(){
//mySerial.begin(9600);
Serial.begin(9600);

//******** Initialize sim808 module *************
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}
delay(3000);
Serial.println("Init Success, please call or send SMS message to me!");

//*********** Attempt DHCP *******************
while(!sim808.join(F("internet"),F(""),F(""))) {
Serial.println("Sim808 join network error");
delay(2000);
}

//************ Successful DHCP ****************
Serial.print("IP Address is ");
Serial.println(sim808.getIPAddress());

//*********** Establish a TCP connection ************
if(!sim808.connect(TCP,"My.website", 80)) {
Serial.println("Connect error");
}else{
Serial.println("Connect success");
}

//*********** Send a GET request *****************
Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
int ret = sim808.recv(buffer, sizeof(buffer)-1);
if (ret <= 0){
Serial.println("fetch over...");
break;
}
buffer[ret] = '\0';
Serial.print("Recv: ");
Serial.print(ret);
Serial.print(" bytes: ");
Serial.println(buffer);
break;
}

//************* Close TCP or UDP connections **********
sim808.close();

//*** Disconnect wireless connection, Close Moving Scene *******
sim808.disconnect();
}

void loop(){

}`

"while (!sim808.getGPS())" Stops Arduino if no GPS signal

Hi
I'd really appreciate some help, as to me this is kind of a bug (I think!).. I have some code which works fine & utilises the library.. However, the code contains :

while (!sim808.getGPS()) { }

If the SIM808 has lost GPS signal, then my code hangs forever waiting for the GPS signal to come back...

Is there any way of working around this please? (i.e. if no GPS signal, just return 0s for everything & continue..don't wait)

Thanks for any help !
James

AT commands PDF is broken

SIM808_Serial_AT_Command_Manual_v1.07.pdf is broken; pages 251-350 are missing when displayed online, and the doc fails to open if downloaded.

const char* in parameters

To minimize warnings, all public functions should accept const char* as parameters instead of char*

GPS Accuracy

Hi,

GPS position as produce by example is limited to two decimal places - there is an issue how you process GPRMC message. GPS produce accurate coordinates, however, once you convert it, you are loosing accuracy.

Kind Regards,
Derek Mizak

Is there anyway to absolutely disable the GPRS ability?

I only want to use DFRobotSIM808 library to receive message and forwarded to Serial port. I'm using a SIM from another country and the international data is super expensive.

Is it true that if I don't try to sim808.join(F("cmnet"), GPRS will not be activated and no data will be used?

Thanks.

Sending data via HTTP

Hello guys,
I want to send my HTTP request to this API:
http://www.ikomoto.com/adiramef/api/generic.php?add_to_db&latitude=" + String(lati) + "&longitude=" + String(longi) + "&device_name=Frigorifero" + " HTTP/1.1\r\n\r\n " ;

and I modified my code as below. However, when I send my request through the browser URL, the server receives it successfully,
but the code doesn't send my request successfully. Can someone please put some lights on what I am doing wrong here? Thanks in advance!

#include <DFRobot_SIM808.h>
DFRobot_SIM808 sim808(&Serial);

char buffer[256];
float lati, longi;

void setup()
{
Serial.begin(9600);

//******** Initialize sim808 module *************
while(!sim808.init()) {
    delay(3000);
    Serial.print("Sim808 init error\r\n");
}


//*********** Attempt DHCP *******************
while(!sim808.join(F("apn.fastweb.it"))) {
    Serial.println("Fastweb join network error");
    delay(3000);
}
Serial.println("Fastweb join network OK");


//************ Successful DHCP ****************
Serial.print("--> IP Address is ");
Serial.println(sim808.getIPAddress());
delay(2000);

//*********** Establish a TCP connection ************
while(!sim808.connect(TCP,"ikomoto.com", 80)) {
   Serial.println("--> Connect error www.ikomoto.com");
   delay(3000);
}
Serial.println("--> Connect www.ikomoto.com OK");   
  
delay(3000);
     
if(sim808.attachGPS())
    Serial.println("--> Open the GPS power success");
else
    Serial.println("Open the GPS power failure");  
} 

void loop()
{
//************** Get GPS data *******************
float lati, longi;
if (sim808.getGPS()) {
Serial.println(" ");
Serial.print("Latitudine rilevata :");
Serial.println(sim808.GPSdata.lat,10);
Serial.print("Longitudine rilevata :");
Serial.println(sim808.GPSdata.lon,10);
Serial.println();

  lati = sim808.GPSdata.lat,10;
  longi = sim808.GPSdata.lon,10;     

sim808.detachGPS();
  
while(!sim808.init()) {
    delay(3000);
    Serial.print("Sim808 init error\r\n");
}  

//************ Successful DHCP ****************
Serial.print("--> IP Address is ");
Serial.println(sim808.getIPAddress());

 while(!sim808.connect(TCP,"ikomoto.com", 80)) {
   Serial.println("--> Connect error www.ikomoto.com");
   delay(3000);
}
Serial.println("--> Connect www.ikomoto.com OK");


 String lnk;
 lnk = "POST /adiramef/api/generic.php?add_to_db&latitude=" + String(lati) + "&longitude=" + String(longi) + "&device_name=Frigorifero" +  " HTTP/1.1\r\n\r\n " ;
 char http_cmd[(lnk.length())+1];
 lnk.toCharArray(http_cmd,(lnk.length()+1));

 sim808.send(http_cmd, sizeof(http_cmd)-1);
 while (true) {
 int ret = sim808.recv(buffer, sizeof(buffer)-1);
  if (ret <= 0){
      Serial.println("  ");
      Serial.println("fetch over...");
      break; 
  }
  buffer[ret] = '\0';
  Serial.print("Recv: ");
  Serial.print(ret);
  Serial.print(" bytes: ");
  Serial.println(buffer);
  break;
  }

  delay(3000);
  
  Serial.println("   ");
  Serial.print("--> Ricomincio daccapo la lettura delle coordinate dal GPS");
  Serial.println("   ");
  
  }

}

I tried SIM808_TCPConnection example. But "Hello World!" did not return.

The code I wrote:

`#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX 10
#define PIN_RX 11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n";
char buffer[512];

void setup(){
mySerial.begin(9600);
Serial.begin(9600);

//******** Initialize sim808 module *************
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}
delay(3000);

//*********** Attempt DHCP *******************
while(!sim808.join(F("cmnet"))) {
Serial.println("Sim808 join network error");
delay(2000);
}

//************ Successful DHCP ****************
Serial.print("IP Address is ");
Serial.println(sim808.getIPAddress());

//*********** Establish a TCP connection ************
if(!sim808.connect(TCP,"mbed.org", 80)) {
Serial.println("Connect error");
}else{
Serial.println("Connect mbed.org success");
}

//*********** Send a GET request *****************
Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
int ret = sim808.recv(buffer, sizeof(buffer)-1);
if (ret <= 0){
Serial.println("fetch over...");
break;
}
buffer[ret] = '\0';
Serial.print("Recv: ");
Serial.print(ret);
Serial.print(" bytes: ");
Serial.println(buffer);
break;
}

//************* Close TCP or UDP connections **********
sim808.close();

//*** Disconnect wireless connection, Close Moving Scene *******
sim808.disconnect();
}

void loop(){

}`

But I get such a result :
Screenshot_1`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.