Connect Tcp And Send Get Requests - DFRobot TEL0097 Manual

Sim808 gps/gprs/gsm shield
Table of Contents

Advertisement

#include <DFRobot_sim808.h>
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char phone[16];
char datetime[24];
DFRobot_SIM808 sim808(&Serial);
void setup() {
  //mySerial.begin(9600);
  Serial.begin(9600);
  //******** Initialize sim808 module *************
  while(!sim808.init()) {
      Serial.print("Sim808 init error\r\n");
      delay(1000);
  }
  delay(3000);  
  Serial.println("Init Success, please send SMS message to me!");
}
void loop() {
  //*********** Detecting unread SMS ************************
   messageIndex = sim808.isSMSunread();
    Serial.print("messageIndex: ");
    Serial.println(messageIndex);
   //*********** At least, there is one UNREAD SMS ***********
   if (messageIndex > 0) {
      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);    
   }
}
Connect TCP and Send GET Requests
This example tests the DFRobot_SIM808 GPS/GPRS/GSM Shield's ability to connect TCP and send GET requests
1. Open the `SIM808_TCPConnection` example or copy the code to your project
2. Download and set the function switch to `Arduino`
3. Open the serial terminal
4. Wait for until `Connect mbed.org success` is printed in the terminal
5. The serial terminal will print `Hello world!`

Advertisement

Table of Contents
loading

Table of Contents