Problem to read serial from Nextion.

Hi. Started my new project on Arduino Nano and Nextion screen. Later i decided to go wireless, and fun begins. Earlier i had projects done with Nextion and Wemos D1 mini. And still have some running at home. But this time it is not working. I can transmit values from Wemos to Nextion, but cannot read them. I have tried different pins, few boards, jumper wires. I can see data coming back on the osciloscope, but cannot get them into Wemos. I can also read serial output sent from Arduino Nano, and Nano can read Nextion. Just in case tried with two different Nextion screens as well. My last hope is, i had recently updated boards, maybe that is a problem, but othervise i am out of idea, how to solve this.
Maybe someone can try Wemos and Nextion with the latest esp8266 boards update pls? Any advice much appreciated.
I am using this library: bborncr/nextion
My test code is:

#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Nextion.h>

SoftwareSerial nextion(D6, D4); // 3, 4 on Nano  

Nextion nex(nextion, 9600);

void setup() {
  Serial.begin(115200);
  nex.init();
}

void loop() {
  nex.setComponentValue("data.n50", random(0, 20));
  delay(3);
  Serial.println(nex.getComponentValue("data.n50")); //returns 4294967295
  delay(1300);
 }

Hello zarsss.

Support for Nextion on these fora is pretty much as follows:

You can follow the methods I set out in using Nextion displays with Arduino. My methods do not use the Nextion libraries, so I can offer help on using my methods but I cannot offer anything very helpful for any Nextion library.

The original Nextion libraries are full of bugs. There is a link from my tutorial to to some improved Nextion libraries created by Ray Livingston, I suggest those might be worth trying if you prefer to use a library.

There’s also a guy on here called Seithan who has also developed his own ways of dealing with Nextion displays, you can find his methods in his tutorial on how to write code with Nextion and Arduino.

Beyond that the odd person occasionally offers a bit of help but not much.

As for the problem you are having as it’s a library problem I can’t help, sorry.

Just a thought,
Have you tried writing some simple code to take data from the serial Rx connected to the Nextion Tx and mirroring it to the serial monitor? This would be a test to see if the data is even getting to the D1 mini.

Personally I would not bother with software serial. I have a D1 mini but have not used it yet. I think this is the one that uses the ESP8266, it that correct? You can use:

  Serial.begin(9600)
  Serial.swap();        //GPIO15 > Tx, GPIO 13 < Rx

To use the hadrware serial port for the Nextion, but you lose the serial monitor when you do.

Got a little bit further with my current setup. Now i am sure, that is one of library faults. don`t know which, but managed to get output on serial monitor:

18:23:32.436 -> 65 5 1 1 ff ff ff
18:23:35.041 -> 65 5 1 0 ff ff ff
18:23:35.076 -> -1
18:23:35.179 -> q⸮⸮⸮

First two lines are button object ID, another two are representation of my numeric value.
I`ve been using bborncr/nextion library for few years now, as it was so easy to use. Seems like its time has gone now.....

My programing skills are poor, so i rely on debug monitor a lot.

PerryBebbington:
Just a thought,

Thank you for your kind reply, i had a look at your tutorials, it looks as complex as Mars rover comparing to my old “Lego” way of doing it. Will need good few days to break into it.

Got my stuff working again, had to downgrade esp8266 boards in boards manager to v.2.5.2. Happy as pig in the mud.

zarsss:
Happy as pig in the mud.

:slight_smile: