Go Down

Topic: Arduino UNO + SIM800L (SMS) + NEO M6 (GPS) = Serial issues (Read 669 times) previous topic - next topic

iPhelps_

Hi everyone,

I'm trying to send my GPS location by SMS, using an Arduino Uno, with SIM800L at Serial (7,8) and NEO 6M at Serial (10,11).

The code is below:

Code: [Select]
#include <Sim800l.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>

SoftwareSerial GPS(5, 6); // RX, TX (GPS)
SoftwareSerial SMS(7, 8); // RX, TX (SMS)
TinyGPS gps1;
Sim800l Sim800l;

char latBuffer[20];
char longBuffer[20];
char fullBuffer[100];

void setup()
{
  Sim800l.begin();
  GPS.begin(9600);
  delay(1000);
  SMS.begin(9600);
  Serial.begin(9600);

  Serial.println("Waiting...");
  GPS.listen();
  delay(1000);
}

void loop()
{
  bool rec = false;
  bool rec2 = false;

  while (GPS.available() > 0)
  {
    rec = gps1.encode(GPS.read());
    break;
  }

  if (rec)
  {
    Serial.println("----------------------------------------");

    //Latitude e Longitude
    float latitude, longitude;
    unsigned long age;
    gps1.f_get_position(&latitude, &longitude, &age);
    float lat = latitude;
    float lon = longitude;

    if (latitude != TinyGPS::GPS_INVALID_F_ANGLE)
    {

      Serial.print("Latitude: ");
      Serial.println(lat);
    }

    if (longitude != TinyGPS::GPS_INVALID_F_ANGLE)
    {
      Serial.print("Longitude: ");
      Serial.println(lon);
    }

    dtostrf(lat, 0, 4, latBuffer);
    dtostrf(lon, 0, 4, longBuffer);
    sprintf_P(fullBuffer, PSTR("Lat: %s; Lon: %s"), latBuffer, longBuffer);
    Serial.println(fullBuffer); //show in Serial

    GPS.end();
    delay(1000);
    SMS.listen();
    delay(100);

    while (SMS.available() > 0)
    {
      Sim800l.sendSms("+XXXXXXXXXX", fullBuffer);
      delay(1000);
      GPS.begin(9600);
      delay(1000);
      GPS.listen();
      delay(1000);
    }
  }
}


What I get on Serial:

Code: [Select]
Waiting...
----------------------------------------
Latitude: -21.98
Longitude: -47.88
Lat: -21.9841; Lon: -47.8832


And it stops.

I tried everything I've read in web, like ".listen()" commands, "delay()", but, it seems that SMS Serial is never available. I edited the SIM800L library to set pins 6 and 7 for RX and TX. It worked when it's alone, but when I attach the GPS shield, it stops.

Did someone have the same problem?

Thank you!

Go Up