Arduino Nano + SIM800L + Neo-6M GPS ----> conflict

Hi, I've spent last week struggling with this so I decided to ask here. I am building a GPS tracker that sends current location in google maps iOS url via GSM when asked by SMS.

Here is my code:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include "SIM900.h"
#include "sms.h"
 
SMSGSM sms;
char latitude[12];
char longitude[12];
char textnav[180];
char number[]="123123123";
char message[180]="123";
char pos;
char *p;
 
static const int RXPin = 7, TXPin = 8;
static const uint32_t GPSBaud = 9600;
 
// The TinyGPS++ object
TinyGPSPlus gps;
 
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
 
void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);
  if (gsm.begin(2400))
   Serial.println("\nstatus=READY");
 else Serial.println("\nstatus=IDLE");
}
 
void loop()
{
 pos=sms.IsSMSPresent(SMS_UNREAD);
 Serial.println((int)pos);
 if((int)pos>0&&(int)pos<=20){
   Serial.print("Incomming message, POS=");
   Serial.println((int)pos);
   message[0]='\0';
   sms.GetSMS((int)pos,number,message,180);
   p=strstr(message,"PASSWORD");  
   
   if(p){
     Serial.println("Success");
 
          while (ss.available() > 0)
    gps.encode(ss.read());
 
  if (gps.location.isUpdated())
  {
        strcpy(textnav, "comgooglemaps://?q=");
        dtostrf(gps.location.lat(), 1, 6, latitude);
        strcat(textnav,latitude);
        strcat(textnav,",");
        dtostrf(gps.location.lng(), 1, 6, longitude);
        strcat(textnav,longitude);
        Serial.println(textnav);
        sms.SendSMS(number, textnav);
        delay(1000);
         
  }
 
   }
   
   }
 
   sms.DeleteSMS((int)pos);
 
 
 
 delay(2000);
}

It should check for incomming messages. When text message arrives it checks if it contains PASSWORD. If it does, GPS location is saved in comgooglemaps url to textnav variable and sent back by SMS.

I have SIM800L module (not a shield) connected to pins 2, 3 of NANO, and GPS connected to pins 7, 8. Modules are connected properly with voltage dividers and voltage is OK. The problem is somewhere in the code. I am not a programmer and it is hard for me to find what is wrong. I think there might be a problem with SoftwareSerial library.

I will appreciate any help :slight_smile:

I am doing a similar project. Could you please share your circuit?

Sure. This is how I connect it:

Do you have any idea what might be wrong with my code? GPS and GSM work fine tested apart but when connected together in one program there is something wrong ;/

I also tried this:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
 
TinyGPSPlus gps;
 
SoftwareSerial ss(10, 11);
SoftwareSerial SIM900(2, 3);
 
char text[180];
char latitude[12];
char longitude[12];
 
void setup()
{
  Serial.begin(115200);
  SIM900.begin(9600);
  delay(2000);
  ss.begin(9600);
  delay(2000);
 
}
 
void loop()
{
   ss.listen();
   delay(2000);
    while (ss.available() > 0) {
    gps.encode(ss.read());
 
  if (gps.location.isUpdated())
  {
        strcpy(text, "comgooglemaps://?q=");
        dtostrf(gps.location.lat(), 1, 6, latitude);
        strcat(text,latitude);
        strcat(text,",");
        dtostrf(gps.location.lng(), 1, 6, longitude);
        strcat(text,longitude);
        delay(200);
        sendSMS();  
        delay(2000);
  }
 }  
}
 
void sendSMS()
{
  Serial.println(text);
  Serial.println("sending SMS");
  SIM900.listen();
  delay(300);
  SIM900.print("AT+CMGF=1\r");                                                     
  delay(100);
  SIM900.println("AT+CMGS=\"phone number\"");                                      
  delay(100);
  SIM900.println(text);        // message to send
  delay(100);
  SIM900.println((char)26);                      
  delay(100);
  SIM900.println();
  delay(9000);
}

I found out I need to listen to one SoftwareSerial at the time and change it with xxx.listen();
But this code seems to be incorrect as well. It sends SMS but not every time.

It sends SMS but not every time.

What do you mean by this?

Cheers,
/dev

@68mustang & @valdek737 - you guys have the same IP address - you should get together.

@68mustang Did you manage to get your setup working in the end? I am working on exactly the same setup, but having trouble getting the GPRS module to work.

Questions:
A. what are the connections?
B. where do you download the library's from?