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)