background image

This example tests the DFRobot_SIM808 GPS/GPRS/GSM Shield's call answering and SMS reading function.

1. Open the `SIM808_LoopHandle` example or copy the code to your project
2. Download and set the function switch to `Arduino`
3. The shield will auto­answer phone calls or send SMS Messages to the serial terminal

#include <DFRobot_sim808.h>

#define MESSAGE_LENGTH 20
char gprsBuffer[64];
char *s = NULL;

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 call or send SMS message to me!");
}

void loop() {
   //******** Wait serial data *************
   if(sim808.readable()){
      sim808_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
      //Serial.print(gprsBuffer);

   //************** Detect the current state of the telephone or SMS ************************
      if(NULL != strstr(gprsBuffer,"RING")) {
          sim808.answer();
      }else if(NULL != (s = strstr(gprsBuffer,"+CMTI: \"SM\""))) { //SMS: $$+CMTI: "SM",24$$
          char message[MESSAGE_LENGTH];
          int messageIndex = atoi(s+12);
          sim808.readSMS(messageIndex, message,MESSAGE_LENGTH);
          Serial.print("Recv Message: ");
          Serial.println(message);
     }
     sim808_clean_buffer(gprsBuffer,32);  
   }
}

Read SMS Messages

This example tests the DFRobot_SIM808 GPS/GPRS/GSM Shield's ability to read SMS messages.

1. Open the `SIM808_SMSread` example or copy the code to your project
2. Download and set the function switch to `Arduino`
3. The shield will receive SMS Messages and send them to the serial terminal

Содержание TEL0097

Страница 1: ...n 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 d...

Страница 2: ...e with PC to make a debug AT debugging 3 Arduino When the expansion board plugged on the Arduino dial to here to make SIM808 communicate with Arduino Arduino Examples In this SIM808 Arduino Shields tu...

Страница 3: ...sim808 init delay 1000 Serial print Sim808 init error r n Serial println Sim808 init success Serial println Start to call Call specified number sim808 callUp PHONE_NUMBER void loop nothing to do Send...

Страница 4: ...lease call or send SMS message to me void loop Wait serial data if sim808 readable sim808_read_buffer gprsBuffer 32 DEFAULT_TIMEOUT Serial print gprsBuffer Detect the current state of the telephone or...

Страница 5: ...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...

Страница 6: ...nect 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...

Страница 7: ...ial print speed_kph Serial println sim808 GPSdata speed_kph Serial print heading Serial println sim808 GPSdata heading Serial println Turn off the GPS power sim808 detachGPS USB Debugging AT command I...

Страница 8: ...08 chip through the serial port assistant Make a Phone Call wiki index php File TEL0097_Phone_call png Make a Phone Call Send AT in the serial port assistant if it returns OK it means that serial comm...

Страница 9: ...wiki index php File TEL0097_Send_Message png Send Message Read SMS wiki index php File TEL0097_Read_Message png Read Message TCP Communication...

Страница 10: ...More exciting instruction please refer to AT command on the page of the end These two test code are very simple and easy to be understood Only need to enter the corresponding serial AT commands you wo...

Страница 11: ...Series GNSS Application Note V1 00 https github com leffhub DFRobotSIM808_Leonardo_mainboard raw master Documents NEW 20SIM800 20Series_GNSS_Application 20Note 20V1 00 pdf SIM800 Series AT Command Ma...

Отзывы: