Page 1 of 1

Arduino soft serial port failure problem

PostPosted: Tue Jun 22, 2021 11:22 am
by Mars
I encountered a situation where I need 2 soft serial ports, one of them is not working and I can't get the data. The switch listener was also written, but it still didn't work.
There is no problem with the hardware circuit, and the code is executable after switching to another one that uses only one soft interface.
I am new to learning and looking for guidance on whether I am missing something.
CODE: SELECT_ALL_CODE
#include <Arduino.h>
#include <SoftwareSerial.h>
 
SoftwareSerial GSMSerial(10, 11); // RX, TX
SoftwareSerial GpsSerial(5, 6); // RX, TX
 
#define DEBUGSerial Serial



void setup()
{
  DEBUGSerial.begin(9600);
  GSMSerial.begin(9600);
  Init();
  GpsSerial.begin(9600);
}
 
void loop()
{
  gpsRead();  //Acquisition of GPS data
  parseGpsBuffer();//Parsing GPS data 
  printGpsBuffer();//Output the parsed data
  GSMSerial.end();
  if(tic == 0) {
    Init();
  }else{
    url = urlhead+"longitude="+llongitude+"&latitude="+llatitude;
    SendMessage();
  }
}
 
**The following GSMSerial.available() is not working, to be precise, it is not listening;**
void gpsRead() {
  GpsSerial.listen();
  while (GSMSerial.available())
  {
    gpsRxBuffer[ii++] = GSMSerial.read();
    if (ii == gpsRxBufferLength)clrGpsRxBuffer();
  }
    。
    。
    。
}
 
void Init()
{
  GSMSerial.listen();
  DEBUGSerial.print("Initialization in progress, please wait。。。");
  // AT
  GSMSerial.print("AT"); 
    。
    。
    。
}

Re: Arduino soft serial port failure problem

PostPosted: Fri Jun 25, 2021 10:42 am
by Idris
Hi Mars,

Personally, I will avoid to use 2 software serial. Instead I will use board like Mega that have 3-4 hardware serial. Never mind, back to your question, I noticed you put GSMSerial.end(). It will disable the software serial right? Maybe that is the reason?

Re: Arduino soft serial port failure problem

PostPosted: Tue Jun 29, 2021 2:31 pm
by BabbRust
Hi...Pins 0 and 1 on the UNO are for the equipment sequential port. So basically you have both Serial and mySerial on similar pins. Move your SoftwareSerial to various pins.

Nail 14 to the Mega2560 is additionally an equipment sequential pin, TX3. Why not utilize one of the equipment sequential ports on the Mega at any rate. There are 4.

Re: Arduino soft serial port failure problem

PostPosted: Thu Aug 12, 2021 7:04 pm
by theaecassociates
thanks for sharing the info was facing similar kind of trouble