Gps not reading data

My neo 6m gps module reads location data on serial monitor when i test it alone but it wont read on my code so my gsm module just sends a blank message and my lcd displays latitude and longitude as 0.00.
Below is the code i used

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include <TinyGPS++.h>
TinyGPSPlus gps;
SoftwareSerial gpsSerial(2, 3);
double latitude, longitude;


SoftwareSerial SIM800L(4,5);

String response;
int lastStringLength = response.length();

String link;

void setup() {
  lcd.init();
  lcd.backlight();
lcd.print("Vehicle Tracking");
delay(1000);
lcd.setCursor(0,1);
lcd.print("    System      ");
delay(3000);
lcd.clear();
lcd.print("Initializing...");
delay(1000);
  Serial.begin(9600);
  Serial.println("GPS Ready");
  delay(5000);
SIM800L.begin(9600); 
    delay(1000);                     
    SIM800L.println("AT+CMGF=1");
    Serial.println("SIM800L started at 9600");
    delay(1000);
    Serial.println("Setup Complete! System Ready!");
    SIM800L.println("AT+CNMI=2,2,0,0,0");   
lcd.clear();
lcd.print("System Ready");
delay(1000);
 
}

void loop() {

  if (SIM800L.available()>0){
      response = SIM800L.readStringUntil('\n');
    }
     

  if(lastStringLength != response.length()){
      GPS();
      //Perintah ON
      if(response.indexOf("Track")!=-1){ //ganti FIND dengan keyword teman-teman
            SIM800L.println("AT+CUSD=1,\"*556#\"\r"); // AT command for Balance request
      delay(5000);
      
     String balance = SIM800L.readStringUntil("64");  // Read string until 64 is found (end of message
      Serial.print("Balance is = ");
      Serial.print(balance);
      delay(1000);
          SIM800L.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
          delay(1000);  // Delay of 1000 milli seconds or 1 second
          SIM800L.println("AT+CMGS=\"08125098892\"\r"); //ganti no hp kalian ya
          delay(1000);
          SIM800L.println("Your Vehicle Location: ");
          SIM800L.println(link);// The SMS text you want to send
          SIM800L.println(balance);
          delay(100);
          SIM800L.println((char)26);// ASCII code of CTRL+Z
          delay(1000);
          lcd.clear();
     lcd.print("Lat:");
     lcd.print(latitude,6);
     lcd.setCursor(0,1);
     lcd.print("Long:");
     lcd.print(longitude,6);
     delay(3000);
     lcd.clear();
     lcd.print("Message Sent");
     delay(2000);
     lcd.clear();
     lcd.print("System Ready");
     delay(1000);
          
      }
  }
   
}

void GPS(){
  if(Serial.available()) {
    gps.encode(Serial.read());
  }
  if(gps.location.isUpdated()) {
    latitude = gps.location.lat();
    longitude = gps.location.lng();
    link = "www.google.com/maps/place/" + String(latitude, 6) + "," + String(longitude, 6) ;
    Serial.println(link);
  
  }
}

Below is the message i receive from my sim800l

Your Vehicle Location:

AT+CUSD=1,"*556#"

OK

+CUSD: 0, "Pulse Main Account:N1947.

You cannot use two SoftwareSerial objects to receive data. Only one of them can be receiving at a given time.

What type of Arduino are you using?

We just went through this a week or 2 ago. If you have only one hardware serial port (Uno Nano, ...) so must use software serial, use only 1 software serial port. Receive the GPS TX on the software serial RX. Sent through the GSM RX from the software serial TX. You really do not need to connect the GPS RX pin nor the GSM TX pins.

The best thing would be to use a board with multiple hardware serial ports.

The GPS will not likely work indoors. It needs a clear unobstructed outdoor view of the sky.

i'm using an arduino nano

Good choice of Arduino, better than UNO, but you really need to explain what it is you are wanting to do before we can offer practical advice. :roll_eyes:

Hi, have you tried the GPS outdoor?

Hi, I came across many GPS modules which do not give any output indoors. If you're using the GPS indoors, try it outdoor.

As you do the output to an LCD, use the hardware serial interface for the GSM communication module and the SoftwareSerial for the GPS. Remote all debugging serial output from the sketch and your sketch should work.

okay, so basically when i text my sim 800l with the word "Track", it sends me back latitude and longitude of gps location via text message and also the remaining balance on the simcard. It then also displays the location on the LCD. The location code was working fine until not long ago, i've tested each of the module individually and they all work fine

yeah, i also noticed. it mostly doesnt blink when it is indoors

yes, i've tried it

GPS signals are not strong enough to penetrate into buildings.

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