GSM SIM808 WITH GPRS DOESN'T RECEIVE MESSAGES AFTER TEXTING IT 6 TIMES OR MORE

Hello Guys I just want to ask what I can I do because my gsm sim808 doesn’t receive messages after pressing the pushbutton and sending it 6 keywords it doesn’t reply and receive anymore :frowning: my code is in below thankyou for your answers guys I really need it badly for my project thankyouuu
#include <SoftwareSerial.h>
SoftwareSerial sim808(11, 10); //Arduino(RX), Arduino(TX)
//Arduino(RX) to SIM808(TX)
//Arduino(TX) to SIM808(RX)
char phone_no = “+639513927267”;// replace this with your phone no.
char phone_no2 = “+639953492721”;// replace this with your phone no2.
char phone_no3 = “+639672534320”;// replace this with your phone no3.
char phone_no4 = “+639104033684”;// replace this with your phone no4.
char phone_no5 = “+639366198755”;// replace this with your phone no5.

String data[7];
#define DEBUG true
String state,timegps,latitude,longitude,atmsg,msgi,gspeed;
bool bAdmin,bGetloc,bHelp,bClrmsg,bClrst=0;

int buttonpin = 12;

void setup() {
pinMode (buttonpin,INPUT);
sim808.begin(9600);
Serial.begin(9600);
delay(100);
sim808.print(“AT+CMGF=1\r”);//configure SIM to TEXT mode
delay(500);
sendData(“AT+CGNSPWR=1”,1000,DEBUG);//Turn on GPS(GNSS - Global Navigation Satellite System)
delay(500);
sendData(“AT+CGNSSEQ=RMC”,1000,DEBUG);
delay(500);
sendData(“AT+CGPSSTATUS?”,1000,DEBUG);//this will check your GPS status. A working GPS should get either a 2D or 3D fix location
delay(500);
sendMessage(“Your bike GPS has been switched ON please wait for it to blink every second.”);
Serial.println (“Done Notifying”);
delay (500);

}

void loop() {
if (Serial.available()>0){sim808.write(Serial.read());}
if (sim808.available()>0){Serial.write(sim808.read());}
atmsg = sim808.readString();
if(atmsg.indexOf("+CMTI: “) >=0) {
Serial.println(“Message received: \r” + atmsg); delay (3000);
msgi = atmsg.substring(atmsg.indexOf(”,")+1);
sendData(“AT+CMGR=”+msgi,1000,DEBUG); Serial.println (“Done senda”);
delay (1000);
// delay(50);
}
if (bAdmin ==1 && bHelp ==1){delay (1000);sendMessage(“What can I do for you?\n1. Get Location\n2. Clear Messages\n3. Help”);Serial.print (“Done Sending Keywords”);bAdmin = 0; bHelp =0;}
if (bAdmin ==1 && bGetloc ==1){delay (1000); getGPSLocation();bAdmin = 0; bGetloc =0; }
if (bAdmin ==1 && bClrmsg ==1){ delay (1000); clearMessages();bAdmin = 0; bClrmsg =0; }
if (bAdmin ==1 && bClrst ==1){ delay (1000); setup(); Serial.println (“Done Sending Reset”);bAdmin = 0; bClrst =0; }

Buttonpressing ();
}

void clearMessages(){
sendTabData(“AT+CMGD=1,4”,1000,DEBUG); Serial.println (“Done Clearing”);
delay(3000);
sendMessage(“Messages cleared!”);
}

void getGPSLocation(){
sendTabData(“AT+CGNSINF”,1000,DEBUG);//Get GPS info(location
Serial.println(“State :”+state);
Serial.println(“Time :”+timegps);
Serial.println(“Latitude :”+latitude);
Serial.println(“Longitude :”+longitude);
sim808.print(“AT+CMGS=”");
sim808.print(phone_no);
sim808.println(""");
sim808.print("\nVehicle speed: “);
sim808.print (gspeed);
sim808.print(” kph\n\n");
sim808.println(“Open the map link below for the GPS location… “);
sim808.print(“http://maps.google.com/maps?q=loc:”);
sim808.print(latitude);
sim808.print(”,”);
sim808.print (longitude);
delay(500);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
sim808.println();
sim808.flush();
Serial.println (“Done Sending Loc”);
}

void gpsEmergency (){ sendTabData(“AT+CGNSINF”,1000,DEBUG);
Serial.println(“State :”+state);
Serial.println(“Time :”+timegps);
Serial.println(“Latitude :”+latitude);
Serial.println(“Longitude :”+longitude);
sim808.print(“AT+CMGS=”");
sim808.print(phone_no);
sim808.println(""");
sim808.println(“HELLO THIS IS RAYMARK DURO I AM ON A EMERGENCY RIGHT NOW PLEASE DO CONTACT ME AT MY NUMBER 09513927267 AND I AM LOCATED AT : “);
sim808.print(“http://maps.google.com/maps?q=loc:”);
sim808.print(latitude);
sim808.print(”,”);
sim808.print (longitude);
delay(500);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
sim808.println();
sim808.flush();
Serial.println (“done 1”);
delay (10000);

}

void gpsEmergency2 (){
sim808.print (“AT+CGNSINF”);
sim808.print ("\n");
Serial.println(“State :”+state);
Serial.println(“Time :”+timegps);
Serial.println(“Latitude :”+latitude);
Serial.println(“Longitude :”+longitude);
sim808.print(“AT+CMGS=”");
sim808.print(phone_no2);
sim808.println(""");
sim808.println(“HELLO THIS IS RAYMARK DURO I AM ON A EMERGENCY RIGHT NOW PLEASE DO CONTACT ME AT MY NUMBER 09513927267 AND I AM LOCATED AT : “);
sim808.print(“http://maps.google.com/maps?q=loc:”);
sim808.print(latitude);
sim808.print(”,”);
sim808.print (longitude);
delay(500);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
sim808.println();
sim808.flush();
Serial.println (“done 2”);
delay (10000);
}

void gpsEmergency3 (){
sim808.print ("AT+CGNSINF");
sim808.print ("\n");
Serial.println("State :"+state);
Serial.println("Time :"+timegps);
Serial.println("Latitude :"+latitude);
Serial.println("Longitude :"+longitude);
sim808.print("AT+CMGS="");
sim808.print(phone_no3);
sim808.println(""");
sim808.println("HELLO THIS IS RAYMARK DURO I AM ON A EMERGENCY RIGHT NOW PLEASE DO CONTACT ME AT MY NUMBER 09513927267 AND I AM LOCATED AT : ");
sim808.print("http://maps.google.com/maps?q=loc:");
sim808.print(latitude);
sim808.print(",");
sim808.print (longitude);
delay(500);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
sim808.println();
sim808.flush();
Serial.println ("done 3");
delay (10000);
}

void gpsEmergency4 (){
sim808.print ("AT+CGNSINF");
sim808.print ("\n");
Serial.println("State :"+state);
Serial.println("Time :"+timegps);
Serial.println("Latitude :"+latitude);
Serial.println("Longitude :"+longitude);
sim808.print("AT+CMGS="");
sim808.print(phone_no4);
sim808.println(""");
sim808.println("HELLO THIS IS RAYMARK DURO I AM ON A EMERGENCY RIGHT NOW PLEASE DO CONTACT ME AT MY NUMBER 09513927267 AND I AM LOCATED AT : ");
sim808.print("http://maps.google.com/maps?q=loc:");
sim808.print(latitude);
sim808.print(",");
sim808.print (longitude);
delay(500);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
sim808.println();
sim808.flush();
Serial.println ("done 4");
delay (10000);
}

void gpsEmergency5 (){
sim808.print ("AT+CGNSINF");
sim808.print ("\n");
Serial.println("State :"+state);
Serial.println("Time :"+timegps);
Serial.println("Latitude :"+latitude);
Serial.println("Longitude :"+longitude);
sim808.print("AT+CMGS="");
sim808.print(phone_no5);
sim808.println(""");
sim808.println("HELLO THIS IS RAYMARK DURO I AM ON A EMERGENCY RIGHT NOW PLEASE DO CONTACT ME AT MY NUMBER 09513927267 AND I AM LOCATED AT : ");
sim808.print("http://maps.google.com/maps?q=loc:");
sim808.print(latitude);
sim808.print(",");
sim808.print (longitude);
delay(500);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
sim808.println();
sim808.flush();
Serial.println ("done 5");
delay (10000);
}

void sendTabData(String command , const int timeout , boolean debug){
sim808.println(command);
long int time = millis();
int i = 0;
while((time+timeout) > millis()){
while(sim808.available()){
char c = sim808.read();
if (c != ',') {
data +=c;

  • delay(50);// delay(100);*
  • } else {i++;}*
  • if (i == 7){*
  • delay(100);*
  • goto exitL;*
  • }*
    }
    }
    exitL:
    if (debug){
    state = data[1];
    timegps = data[2];
    latitude = data[3];
    longitude =data[4];
    gspeed =data[6];
    memset(data, 0, sizeof(data));
    }
    }
    String sendData (String command , const int timeout ,boolean debug){
    String response = "";
    sim808.println(command);
    long int time = millis();
    int i = 0;
    while ( (time+timeout ) > millis()){
    while (sim808.available()){
  • char c = sim808.read();*
  • response +=c;*
    }
    }
    if (debug){
    if (response.indexOf(phone_no)>=0){bAdmin=1;}
    if (response.indexOf("Get Location")>=0){bGetloc=1;}
    if (response.indexOf("Help")>=0){bHelp=1;}
    if (response.indexOf("Clear Messages")>=0){bClrmsg=1;}
    if (response.indexOf("Reset")>=0){bClrst=1;}
    Serial.print(response);
    }
    return response;
    }
    void sendMessage(String msg){
    sim808.print("AT+CMGS="");
    sim808.print(phone_no);
    sim808.println(""");
    sim808.print(msg);
    delay(50);
    sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
    sim808.println();
    sim808.flush();
    Serial.println(msg);}
    void Buttonpressing () { if (digitalRead(buttonpin)==HIGH){Serial.println("button is pressed"); delay (3000);
    *gpsEmergency(); *
    *gpsEmergency2(); *
    *gpsEmergency3(); *
    *gpsEmergency4(); *
    *gpsEmergency5(); *
    }
    }
    that is the continuation guys of my code

Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

what are you trying to do here

if (sim808.available()>0){Serial.write(sim808.read());}
atmsg = sim808.readString();

Because you read a single byte and write that to Serial and then store the rest in atmsg. atmsg is going to be missing the first char.

How is it gonna miss the first char sir?

once you do sim808.read() you read a single character and write that to the Serial, then you dosim808.readString()which reads whatever is left. And please do as requested in reply #2.

Okay sir thanks I will do it now

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