GSM module stops sending message within couple of days

HI -

I've a strange issue at hand, the configuration and implementation works perfectly for a day or two and then stops sending the message, once we start it behaves normally for a day or two then stops sending message, not able to figure where the issue could be?

Below is the code, would appreciate if some cone can help me with this dragging issue

#include <SoftwareSerial.h>
#include <EEPROM.h>

#include <Wire.h>
#include "Adafruit_VL6180X.h"
Adafruit_VL6180X vl = Adafruit_VL6180X();
SoftwareSerial GPRS(10, 11); // RX, TX
int num = 2;

String smsTime[2] {"11", "41"};

String contact[2] { "8098034034", "9488072237"};

int resetPin = 5;
int mem = 200;

String date[5];
int stringplace = 0;
unsigned long range;
int CDate;

void setup()
{
pinMode(resetPin, OUTPUT);
digitalWrite(resetPin, LOW);
GPRS.begin(9600);
Serial.begin(9600);
resetGSM();

// rtc.stopRTC(); //stop the RTC
//
// rtc.setTime(15, 30, 0 ); //set the time here time change
// rtc.startRTC(); //start the RTC

Wire.begin();

EEPROM.get(mem, CDate);

}

void loop()
{
//int state = sensorCheck();
//sendSMS(state);
Serial.flush();
GPRS.flush();
GPRS.println("AT+CCLK? ");

while (GPRS.available() > 0) GPRS.read();

if (GPRS.find("+CCLK: ")) checkTime();

}

void sendSMS(int diagnosis) {
int sto=0;
delay(2000);
if(diagnosis <=1) sto = 1;
else if( diagnosis ==10) sto = 2;
else sto = num;
for (int i = 0; i < sto; i++) {
Serial.println(i);
Serial.flush();
GPRS.flush();
GPRS.println("AT+CMGF=1\r");

delay(1000);
Serial.println(contact*);*
_ Serial.println("AT+CMGS="+91" + contact + ""\r");_
_ GPRS.println("AT+CMGS="+91" + contact + ""\r");
* delay(1000);
if (diagnosis == 0) {
GPRS.println("LOG: Failed to find sensor");
Serial.println("Failed to find sensor");
}
else {
Serial.println("LOG- " + date[0] + ":" + date[1] + " " + date[2] + "/" + Month(date[3].toInt()));
GPRS.println("LOG:" + date[0] + ":" + date[1] + " " + date[2] + "/" + Month(date[3].toInt()) + " ");
if (diagnosis == 1) {
GPRS.println("LD1-Smoke shaft Baffle wall SOUTH side dust level TODAY ");
GPRS.print(range);// The SMS text you want to send*
* GPRS.println("mm. ");
}
else if (diagnosis == 10) {
GPRS.println("In LD1 smoke shaft baffle wall SOUTH Side roof dust level reached ");
GPRS.println(range);
GPRS.println(" mm. ");
GPRS.println("So Kinldy plan for cleaning.");
}
else if (diagnosis == 30) {
GPRS.println("In LD1 smoke shaft baffle wall SOUTH roof dust level reached ");
GPRS.print(range);// The SMS text you want to send*
* GPRS.println("mm.");
GPRS.println(" The max acceptable limit 35mm. Clean the dust immediately.");
}
}
// GPRS.println(random(100));
// Serial.println("- Rohit");
// GPRS.println("- Rohit");
delay(100);
GPRS.write( 0x1a ); // ctrl+Z character*
* GPRS.println((char)26);
// while(1){
// while(GPRS.available()>0)
// Serial.write(GPRS.read());
//
// if (GPRS.find("+CMGS: ")) break;
//
//
// while (Serial.available()) {
// byte b = Serial.read();
// if ( b == '')

// GPRS.write( 0x1a ); // replace * with ctrl+z_

* // else*
* // GPRS.write(b);*
* // }*
* // }*
* delay(5000);*
* }*
}
void checkTime() {
* String tempMsg = GPRS.readStringUntil('\n');*
* // Serial.println(tempMsg.length());*
* date[0] = tempMsg.substring(10, 12);*
* //Serial.println(date[0]);*
* date[1] = tempMsg.substring(13, 15);*
* Serial.println(date[0] + " " + date[1] );*
* date[2] = tempMsg.substring(7, 9);*
* date[3] = tempMsg.substring(4, 6);*
* date[4] = tempMsg.substring(1, 3);*
* Serial.println(CDate);*
* if ( CDate != date[2].toInt() ) {*
* if (date[0].toInt() >= smsTime[0].toInt()) {*
* if (date[1].toInt() >= smsTime[1].toInt()) {*
* //Check sensor data*
* int state = sensorCheck();*
// signalStrength();
* sendSMS(state);*
* EEPROM.put(mem, date[2].toInt());*
* CDate = date[2].toInt();*
* }*
* }*
* }*
}
int sensorCheck() {
* int i = 0, j = 0;*
* int a = 1, b = 0, range, reference = 0, adjustment = 0;*
* unsigned long d, f, e;// time variables*
* long k = 0, c = 0;*
* while (i < 1000) {*
* range = vl.readRange();*
* // Serial.print("range range=");*
* // Serial.println(range);*
* k = k + range;*
* i++;*
* delay(5);*
* }*
* j = k / 1000;*
* Serial.print("range j=");*
* Serial.println(j);*
* c = reference + j;*
* Serial.print("range c=");*
* Serial.println(c);*
* range = c;*
* if (c >= 10 && c < 30) return 10;*
* else if (c >= 30 ) return 30;*
* else return 1;*
}
void resetGSM() {
* Serial.println("Reseting GSM module...");*
* Serial.println("Wait 15Sec...");*
* digitalWrite(resetPin, HIGH);*
* delay(2000);*
* digitalWrite(resetPin, LOW);*
* delay(7000);*
* GPRS.println("AT");//AT commands*
* delay( 2500);*
* GPRS.println("AT+CMGF=1");//AT for messages mode*
* delay( 2500);*
}
String Month(int month) {
* switch (month) {*
* case 1 :*
* return ("Jan");*
* case 2 :*
* return ("Feb");*
* case 3 :*
* return ("Mar");*
* case 4 :*
* return ("Apr");*
* case 5 :*
* return ("May");*
* case 6 :*
* return ("Jun");*
* case 7 :*
* return ("Jul") ;*
* case 8 :*
* return ("Aug");*
* case 9 :*
* return ("Sep");*
* case 10 :*
* return ("Oct");*
* case 11 :*
* return ("Nov");*
* case 12 :*
* return ("Dec");*
* }*
}
SIM800_data_transmit.txt (5.38 KB)

Maybe the evils of Strings?

Is half your code really in italics? Read the "how to use this forum-please read" stickies to see how to post code properly.

None of the coding is in italics, but when copied and pasted some of it has turned into italics, do not know how it happend, you may check the attachment, there are not italics in it

SIM800_data_transmit.txt (5.38 KB)

The forum software interprets the i in square brackets as the tag for italics.

When put on the forum without code tags:
This line has the italic tag () in it so it shows everything after the tag in italics and removes all of the tags..
When the same line is in code tags it looks like this:

This line has the italic tag ([i]) in it but is not italicized.

Read the "how to use this forum-please read" stickies to see how to post code properly.

do not know how it happend

Well, we do. It's because you failed to follow the directions in the stickies at the top of the forum with respect to how to post your code. The sequence of characters '[', 'i', ']' tells the forum software to use italics. Somewhere in your code, that sequence of characters appears.

You still need to stop using the String class. Completely. Totally. Everywhere.

Is italics tag the reason for message not getting transmitted after 2 days?

No - that just screws up the appearance of the code on the forum which as mentioned, is solved with code tags.

Check the link groundFungus gave you about Strings. A cursory glance at your code doesn't show anything obviously wrong with it apart from the use of Strings but until they're gone, I at least, am not prepared to give it any deeper analysis.

GPRS.println("LOG:" + date[0] + ":" + date[1] + " " + date[2] + "/" + Month(date[3].toInt()) + "   ");
      if (diagnosis == 1) {

String class concatenation is the worst of the worst in using String Class

convert your code to use C strings. There are about a gajillion posts on this forum from which you can search/learn.