Arduino soft serial port failure problem

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Arduino soft serial port failure problem

Postby Mars » Tue Jun 22, 2021 11:22 am

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"); 
    。
    。
    。
}
Mars
Novice
 
Posts: 28
Joined: Tue Jun 22, 2021 11:10 am

Re: Arduino soft serial port failure problem

Postby Idris » Fri Jun 25, 2021 10:42 am

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?
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: Arduino soft serial port failure problem

Postby BabbRust » Tue Jun 29, 2021 2:31 pm

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.
BabbRust
Fledgling
 
Posts: 1
Joined: Tue Jun 29, 2021 2:19 pm

Re: Arduino soft serial port failure problem

Postby theaecassociates » Thu Aug 12, 2021 7:04 pm

thanks for sharing the info was facing similar kind of trouble
The AEC Associates is a leading Design Support Service for the Global AEC Industry offering CAD & BIM Services.

Outsource cad drafting
theaecassociates
Fledgling
 
Posts: 1
Joined: Thu Aug 12, 2021 6:30 pm
Location: Noida


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 12 guests

cron