switching softserials

hello

i am having an issue switching between soft serial ports, one for GPS(neo 6m ublox) and the other is for GSM(sim800L) and here is the code that actually works 100%

void loop() {

gps.listen();   // open gps port

delay(5000);

if ( gps.available()) {

gps_parsing();  // read the coordinates

}



gsm.listen();     // open gsm port

if ( gsm.available()) {

gsm_parsing();  // check if new sms is received and read it

}


}

i hate the fact that delay(1000) is in the loop, but when try to remove it, gps port is never LISTENED and i can't get data out of it , but i can get sms received and read via gsm port

even if i reduce delay down to delay(2000) , still it won't work

any help is hugely appreciated

any help is hugely appreciated

You really need to get a Mega with 4 hardware serial ports.

You can NOT use software serial to listen to two devices at the same time. When you are listening to one, the other is COMPLETELY ignored. Nothing that the device you are not listening to sends has ANY impact on the Arduino.

As Paul says, yes, but what about the listening to 1 device on the hwSerial ? or is that being used for something else ?

Deva_Rishi: As Paul says, yes, but what about the listening to 1 device on the hwSerial ? or is that being used for something else ?

nice idea but this would spike up my RAM usage,

KASSIMSAMJI: nice idea but this would spike up my RAM usage,

If you want to listen to 2 ports you will need 2 buffers, if you are that stressed for RAM use a different Board, MEGA/ nodeMCU whatever...