Arduino Sleep mode with sim808 module

Hi I'm looking for some help with my project I made a vehicle tracking system using Arduino Uno R3 and Sim808, I want to put the Arduino and sim808 on sleep mode to save battery life and to make the system starts only when a phone message is received by the sim808
Tracking.ino (2.7 KB)
This is the code from my project
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char MESSAGE[300];
char lat[12];
char lon[12];
char phone[16];
char datetime[24];
char gprsBuffer[64];
char s = NULL;
#define PIN_TX 9
#define PIN_RX 10
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,
void setup()
{
pinMode(3,OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
//
******* Initialize sim808 module *************
while(!sim808.init())
{
Serial.print("Sim808 init error\r\n");
delay(1000);
}
delay(3000);
if( sim808.attachGPS())
Serial.println("Open the GPS power success");
else
Serial.println("Open the GPS power failure");

Serial.println("Init Success, please send SMS message to me!");
}
void loop()
{
messageIndex = sim808.isSMSunread();
if (messageIndex >0)
{
digitalWrite(3,HIGH);
Serial.print("messageIndex: ");
Serial.println(messageIndex);
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.println("MESSAGE_LENGTH");
Serial.println(MESSAGE_LENGTH);
Serial.print("Datetime: ");
Serial.println(datetime);
Serial.print("Recieved Message: ");
Serial.println(message);
sim808.attachGPS();
while(!sim808.getGPS())
{
}
Serial.print("latitude :");
Serial.println(sim808.GPSdata.lat,8);
Serial.print("longitude :");
Serial.println(sim808.GPSdata.lon,8);
float la = sim808.GPSdata.lat;
float lo = sim808.GPSdata.lon;
dtostrf(la, 11, 8, 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, 11, 8, lon); //put float value of lo into char array of lon
sprintf(MESSAGE, "Google Maps",lat,lon);
Serial.println("Sim808 init success");
Serial.println("Start to send message ...");
Serial.println(MESSAGE);
Serial.println(phone);
sim808.sendSMS(phone,MESSAGE);
sim808.detachGPS();
}
if(sim808.readable()){
sim808_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
Serial.print(gprsBuffer);
if(NULL != strstr(gprsBuffer,"RING")) {
sim808.answer();
digitalWrite(3,LOW);
Serial.println("work");}
}
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.