Arduino problem with sim800L

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

Why do You need to disconnect the GSM module?

Avoid connecting an Arduino to an unpowered sensor or module.

Doing so can destroy the input/output circuitry of either one, and will often cause the Arduino to reset.

There is no need to disconnect it, disconnecting it could also mean removing the general supply which is the battery

I first noticed that whenever i turn off the tracking device the problem occurs, so i decided to individually remove each of the module and test, till i was able to trace it back to the sim800L.

You realise that when the modem is repowered, it has ‘forgotten’ its previous settings until they’re sent again…

Okey. Pay attention to reply #3. Either all devices have power or none of them. Else the unit having power will ghost powering the powerless unit. That can damage things.

1 Like

okay, i'd avoid that henceforth

Is it because of the 2 particular lines of code?, i tried deleting them from the main code and tested it again. It’s still the same problem except this time, when it doesn’t work, it doesn’t show anything on the serial monitor.

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