I am currently facing issues with a tracking system that sends its location when you message it, it works fine after i upload the code on the arduino uno but it stops working whenever i disconnect the sim800L gsm module from power and connect it back. The problem only happens with the sim800L losing power supply even for a brief moment. It also wouldnt work when i reupload the code, i have to upload a send or receive gsm code then reupload my initial tracking code before it continues working. It continues working fine as long as i dont turn of my sim800l.
Below is the schematic diagram.
Below is the code i used
#include <SoftwareSerial.h>
#include <TinyGPS++.h>
float lattitude, longitude;
float a[2];
float *p;
SoftwareSerial gpsSerial(2, 3);
SoftwareSerial gsmSerial(4, 5);
TinyGPSPlus gps;
void setup() {
Serial.begin(9600);
delay(1000);
gpsSerial.begin(9600);
delay(1000);
gsmSerial.begin(9600);
delay(1000);
gsmSerial.println("AT+CNMI=2,2,0,0,0");
Serial.println("AT+CNMI=2,2,0,0,0");
delay(3000);
}
//---------------------------------------------------------------------------------------/
void loop() {
if (gsmSerial.available()) {
gsmSerial.read();
}
get_gsm();
}
float *get_gps()
{
gpsSerial.listen();
//Serial.println("INSIDE get_gps");
while (1)
{
while (gpsSerial.available() > 0)
{
gps.encode(gpsSerial.read());
}
if (gps.location.isUpdated())
{
Serial.print("LAT="); Serial.println(gps.location.lat(), 6);
Serial.print("LONG="); Serial.println(gps.location.lng(), 6);
lattitude = gps.location.lat();
longitude = gps.location.lng();
break;
}
}
a[0] = lattitude;
a[1] = longitude;
return a;
}
//---------------------------------------------------------------------------------------/
void get_gsm()
{
gsmSerial.listen();
while (gsmSerial.available() > 0)
{ Serial.println("INSIDE gsmSerial.available");
char Track[] = "Track";
if (gsmSerial.find(Track))
{ Serial.println("INSIDE track");
gsmSerial.println("AT+CMGF=1");
delay(1000);
gsmSerial.println("AT+CMGS=\"08125098892\"\r");
delay(1000);
p = get_gps();
gsmSerial.listen();
Serial.print("Your Vehicle Location: ");
gsmSerial.print("Your Vehicle Location: ");
Serial.print("LATITUDE="); Serial.print(*p, 6);
gsmSerial.print("LATITUDE="); gsmSerial.print(*p, 6); gsmSerial.print(",");
Serial.print("LONGITUDE="); Serial.print(*(p + 1), 6);
gsmSerial.print("\nLONGITUDE="); gsmSerial.print(*(p + 1), 6);
Serial.print("https://maps.google.com/?q="); Serial.print(*(p + 2), 6);
gsmSerial.print("\n https://maps.google.com/?q=");
gsmSerial.print(*p, 6); gsmSerial.print(",");
gsmSerial.print(*(p + 1), 6);
delay(100);
gsmSerial.println((char)26);
delay(1000);
}
}
}
Below is the serial monitor for when it works fine
Below is the serial monitor for when it doesnt work
I'm curious to what the issue could be