Reading data received from Nextion on Serial Monitor

Hello Can anyone help please.
Got a far as trying to use Serial Software but using "Serial " I get the expected results but using the "mySerial code "I seem to receive nothing at the Arduino.
This works using Arduino Pins 0 and1

int aaa = 0;
int bbb = 0;

void setup() {
  Serial.begin(9600);
  Serial.println ("   GIDDAY  ");
}

void loop() {
  
if(Serial.available())
{
String datA="";
delay(30);
while(Serial.available()){
  datA+=char(Serial.read());
  }
  //Serial.println(datA);
  //sendData(datA);//   
  aaa = datA.toInt();
  if (aaa >0){
  Serial.println(aaa);
  bbb=(aaa*12);
  Serial.println (bbb);
  }
}
}

This receives nothing at the Arduino using pins 14 and 15

int aaa = 0;
int bbb = 0;
#include <SoftwareSerial.h>
SoftwareSerial mySerial(15,14); //RX, TX 
void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println ("   GIDDAY  ");
}

void loop() {
  
if(mySerial.available())
{
String datA="";
delay(30);
while(mySerial.available()){
  datA+=char(mySerial.read());
  }
  //Serial.println(datA);
  //sendData(datA);//   
  aaa = datA.toInt();
  if (aaa >0){
  Serial.println(aaa);
  bbb=(aaa*12);
  Serial.println (bbb);
  }
}
}

Can anyone please give me some advice
Tx

1 Like
SoftwareSerial mySerial(15,14); //RX, TX 

The first thing to check is the Rx and Tx from the Nextion are connected the right way round

Tx Bob. I seem to have accidentally fixed my problem by reassigning the Arduino Pins 9 and 10 to
Tx and Rx and now the code seems to work.
Is there an easy explainable(Dummies) reason for this?

1 Like

My best guess is that you had the Tx and Rx connections reversed

Thank you. Consider closed.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.