Request any sensor data read via SMS Using Arduino and GSM SIM808

GSM SIM808 is a widely used GSM module .It is possible to create many fun projects by interfacing between the GSM SIM808 module and the Arduino .With this technology I will show you that you can read the data of any sensor and get it on your phone through message. Today we will show you how you can do such a project yourself by interfacing with Arduino and GSM SIM 808.Here I have used the DHT11 sensor as the sensor. You can use any sensor . By reading the temperature and humidity through the DHT11 sensor, I will show you how to get the temperature and humidity message on your phone as a reply message through your message request.

You notice the two images above. I sent a message with one image and I received the message with the other image. Let’s see what components and devices I need to do this project.

 

  1. Arduino Uno R3 Board.
  2. GSM SIM808 Module.
  3. DHT11 Temperature and Humidity Sensor.
  4. 5v 2Amp Power Supply.
  5. Any SIM card.
  6. Breadboard.
  7. Connecting wire.

Now we will see how the interface between GSM and Arduino board is connected to do each of these.

GSM Sim808
GSM Sim808

 

See above I showed you the connection diagram. Here I have shown only with DHT11 temperature and humidity sensors but you can do with any sensor. Now I will show you the Arduino coding. First you need to download a library file. If you do not download the library file, the coding will not work properly. You need to download this library file and add it to the Arduino IDE software.

 

Code:

 #include <dht.h>  
 #include <DFRobot_sim808.h>  
 #include <SoftwareSerial.h>  
 #include <Wire.h>  
 float h;  
 float t;  
 String data;  
 dht DHT;  
 char b[100];  
 #define DHT11_PIN 12 // temperature and humidity output pin  
 #define PIN_TX  7  
 #define PIN_RX  8  
 //int light = 13;  
 char MESSAGE[300];  
 char lat[12];  
 char lon[12];  
 char wspeed[12];  
 SoftwareSerial mySerial(PIN_TX,PIN_RX);  
 DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,  
 #define PHONE_NUMBER "01814946110"   
 #define MESSAGE_LENGTH 160  
 #define MESSAGE"data"   
 char gprsBuffer[64];  
 char *s = NULL;  
 char message[MESSAGE_LENGTH];  
 int messageIndex = 0;  
 String rmsg;  
 String asish = String("result");  
 char phone[16];  
 char datetime[24];  
 //DFRobot_SIM808 sim808(&Serial);  
 void temp_humidity();  
 void setup() {  
  pinMode(12, INPUT);  
  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!");  
  // sim808.callUp(PHONE_NUMBER);  
  //sim808.sendSMS(PHONE_NUMBER,MESSAGE);   
 }  
 void loop() {  
  temp_humidity();  
  Read_SMS();  
 }  
 void Read_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);  
    delay(200);  
      rmsg=String(message);  
       if(asish == message)  
      {  
       sim808.sendSMS(phone,b);  
      }        
    //***********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);    
   }  
 }  
 void temp_humidity() // temperature and humudity check  
 {  
   int chk = DHT.read11(DHT11_PIN);  
  Serial.println("Temp: ");  
  Serial.println(DHT.temperature);  
  // Serial.println((char)223);  
  Serial.println("C");  
  h=(DHT.humidity);  
  t=(DHT.temperature);  
  Serial.println("Humidity: ");  
  Serial.println(DHT.humidity);  
  Serial.println("%");  
   Serial.println(h);  
   Serial.println(t);  
   data = ("Temperature: " + String(t) + "*C " + " Humidity: " + String(h) + "%" );  
    data.toCharArray(b,100);  
   Serial.println(b);  
    Serial.println(b);  
   Serial.println(data);  
  delay(400);  
 }  

 

Copy the coding that I have shown you above and paste the Arduino IDE software .And the library file that I have given you above, you must download the library file and add it with the Arduino IDE  software.

 

2 thoughts on “Request any sensor data read via SMS Using Arduino and GSM SIM808”

  1. Thank you, but I did not understand how can I see the temp and humidity value on my cellphone; I sent a message, but Arduino had not sent a message to me; where was wrong with it?

    Reply
  2. Thank you very much for your dedication to enlighten us on Sim808 gps module Sir! You really helped me a lot, i nearly thought i had to give up on gps.

    Reply

Leave a Comment