Arduino project issue

I am currently working on a vehicle tracker system sends the location of the vehicle when you message it, the project works fine after i upload the code on the arduino uno but it stops working properly when i unplug the usb cord and put it back or connect it to another power supply. So i have to upload another code on the arduino uno then reupload my original code before it continues working.
This is the code i used for the project

#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
#include <TinyGPS++.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
float lattitude,longitude;
float a[2];
float p;
SoftwareSerial gpsSerial(4,3);
SoftwareSerial gsmSerial(7,6);
TinyGPSPlus gps;
void setup(){
lcd.begin(16,2);
delay(1000);
Serial.begin(9600);
delay(1000);
gpsSerial.begin(9600);
delay(1000);
gsmSerial.begin(9600);
delay(1000);
lcd.clear();
lcd.print("Vehicle Tracking");
lcd.setCursor(0,1);
lcd.print(" System ");
gsmSerial.println("AT+CNMI=2,2,0,0,0");
Serial.println("AT+CNMI=2,2,0,0,0");
delay(3000);
lcd.clear();
lcd.print("Initializing...");
delay(3000);
lcd.clear();
lcd.print("System Ready");
delay(1000);
}
/
---------------------------------------------------------------------------------------*/
void loop(){
while(gsmSerial.available()){
gsmSerial.read();
}
while(Serial.available()){
Serial.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=\"xxxxx\"\r"); //replace “x”s with phone number
 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);
 lcd.clear();
 lcd.clear();
 lcd.print("Lat:");
 lcd.print(*p,6);
 lcd.setCursor(0,1);
 lcd.print("Long:");
 lcd.print(*(p+1),6);
 delay(3000);
 lcd.clear();
 lcd.print("Message Sent");
 delay(2000);
 lcd.clear();
 lcd.print("System Ready");
 delay(1000);
}

}
}
Below is a picture of when it doesn’t work

Please post the schematics. It clearly looks like a powering problem.
Pen and paper is often good. Don't use toy pictures like Fritzing.

1 Like

This is the circuit diagram i used . I couldn’t post more than 1 picture due to new account restrictions. I intend to power it externally using a 9v battery


The problem only seem to occur when i use this particular code

That is exactly the kind of first picture You posted. They are just jokes to engineers. The most wanted information is the powering and in that "toy picture" the controller is powered by the surrounding air.

In the second picture the light blue colour is just not readable in my equipment....

No criticism, just trying to help. As above, likely a powering issue but I can't read the pin designations.
My guess...
Maybe the controller 5 volt converter powers the LCD. That is basically wrong.

A GSM module will never run on a "smoke alarm" battery, if that is what you have for a 9V.

I’ve tested it and it works, the issue is why the code stops working when ever i unplug the arduino from my computer and plug it back in

Yes i used the controller 5 volts to power the lcd and the sim800L

Hi,
Can you please draw a circuit diagram, identifying all components and pin names.
A pen(cil) and paper schematic is fine.

Lay your components out so you can clearly see pin names and include your power supply.

To add code please click this link;

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

It doesn’t sound like you need our help.

Sure it will. For a few minutes.

Your code is unreadable- post it using code tags.

When you post your schematic, a hand drawn circuit in jpg or png is far preferable over a pretty Fritzing picture. A schematic is way simpler and easy to understand than a physical layout. The schematic is a functional description describing the flow of operation. The symbols actually describe functions and are read as such, something Fritzing does poorly. Using Fritzing will reduce the pool of folks prepared to even look at your problem. Do not hurry drawing a schematic, it is a very valuable tool to help you and us understand your project.

CTRL-T, then right-click on the code and then "Copy for Forum". Then in the forum, just paste.

Very bad choice.

Do not attempt to power any "real" project via "Vin" or the "barrel jack". Provide 5 V - using a switchmode "buck" regulator if you must use a higher voltage battery (but obviously not a "smoke alarm" battery).

Do not connect the contrast potentiometer for the LCD to 5 V. Connect it only to ground - if you have the wrong (10k) value as in most "tutorials", connect both ends to ground and the wiper to pin 3 of the display.

Don't be too sure. The peak power of a GSM transmitter can easily overwhelm a batteries internal resistance and drop the supply voltage beyond usable limits. The tower controls device output power too, so you can't limit that.

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