Hey guys,
i am trying to connect a Sim800l and a GPS module to my Arduino. I am initialising the softwareserial in the setup-section but only the one who comes last, in the code, is working.
Is there a way to get them both running?
The Serialclass for the SIM800l is set in the Sim800l-library, so i didnt forgot it. Both modules are working in different sketches.
#include <Sim800l.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
Sim800l Sim800l; //to declare the library
//GPS
#define RXD2 6
#define TXD2 5
#define GPS_BAUD 9600
TinyGPSPlus gps;
SoftwareSerial gpsSerial(RXD2,TXD2);
//SMS
String textSms,numberSms;
uint8_t index1;
bool error;
void setup() {
gpsSerial.begin(9600);
Serial.begin(19200); // only for debug the results .
Sim800l.begin(); // initializate the library.
//Sim800l.reset();
//don't forget to catch the return of the function delAllSms!
//error=Sim800l.delAllSms(); //clean memory of sms;
Serial.println("setup beendet");
}
void loop() {
Serial.println("Lese Speicher");
delay(100);
textSms=Sim800l.readSms(1); //read the first sms
if (textSms.indexOf("OK")!=-1) //first we need to know if the messege is correct. NOT an ERROR
{
Serial.println("Speicher wird verlesen");
delay(100);
Serial.println(textSms);
Serial.println("Nachricht verlesen");
if (textSms.indexOf("Test")!=-1){
Serial.println("bestimme Position");
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);
}
else {
Serial.println("Positions nicht gefunden");
}
}
Serial.println("leere Speicher");
delay(5000);
//Sim800l.delAllSms(); //do only if the message is not empty,in other case is not necesary
//delete all sms..so when receive a new sms always will be in first position
}
}