Nextion problem

Hi All
can you help please.
First of all I have tried to use the tutorials on this and other forums. I have had little success (the same problem as I have here). So I thought I would go back to basics.
I am using a Nextion 4024K032 Enhanced display.
and an Uno.
here is the simple sketch to send a number from the Uno to the display

/*
Connection with Arduino Uno/Nano:
* +5V = 5V
* TX  = none
* RX  = pin 1 (TX)
* GND = GND
*/
int variable1 = 0;// This is a simple variable to keep increasing a number to have something dynamic to show on the display.





void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  variable1++;   // Increase the value of the variable by 1.
  if(variable1 == 201){  // If the variable reach 201...
    variable1 = 0;   // Set the variable to 0 so it starts over again.
  }
// We are going to send the variable value to the object called n0:
  // After the name of the object you need to put the dot val because val is the atribute we want to change on that object.
  Serial.print("n0.val=");  // This is sent to the nextion display to set what object name (before the dot) and what atribute (after the dot) are you going to change.
  Serial.print(variable1);  // This is the value you want to send to that object and atribute mention before.
  Serial.write(0xff);  // We always have to send this three lines after each command sent to the nextion display.
  Serial.write(0xff);
  Serial.write(0xff);
}   // End of loop

if I look in the serial monitor when running I see the variable incresing. but I get no increment on the display.
I cannot think what I have done wrong.
I have included my HMI file too.
Can someone help please.

Bob

tut1a.zip (9.8 KB)

Hello Bob,
Your code works on my Uno exactly as you have posted it.

To confirm, have you got the yellow wire from the Nextion connected to pin 1 (Tx) on the Uno?

The only other thing is you have nothing to slow loop down, it is going mad sending data as fast as it can. Much as I hate delay(); maybe you should put 500ms delay at the end after the last serial.write.

Unfortunately if you continue with a Uno you will run into problems as the Uno does not have a spare serial port you can connect the Nextion to; you are using port 0 for both the serial monitor and the Nextion, not really a good situation. It might even be the cause of your problem, although it works for me.

Hi Perry
thanks for the reply
Yes I do have the yellow wire in pin 1TX on the uno.
I have put a delay in and it has made no difference to the display.
I am tearing out what little hair I have left I cannot see what the problem is.
I have an old laptop I think I will get it out and install Arduino on that to see if it is the problem.
thanks
Bob

Please can you post some photos of what you have? Your Arduino and the connections to the Nextion and anything else that might be relevant?

The thing I didn't try was your HMI file, although it looks fine.

Have you tried using the debug screen in the Nextion editor? Typing, for example, n0.val=10 ?

That works for me.

Hi Perry
Yes I did try the debug eand it worked fine.
I have tyied 3 different Unos and a Mega all the same
I will post a pic or two later
Thanks
Bob

Hi Perry
just setup n old laptop with Arduino IDE and got the same resaults.
Heres a pic of the wireing.
I tried a separate power supply for the display as well no good.
Bob

Hi Bob,
Your photo is not clear enough for me to be sure but it looks like the yellow wire is connected to pin 0 (Rx) instead of pin 1 (Tx).

Was the Nextion powered when you took the photo? I can't see anything on the display at all, it should show 0.

If you have a Mega connect as per the photo in 'using Nextion displays with Arduino', using Tx1 and Rx1 and modify your code to use Serial1 instead of Serial. Better still use both Serial and Serial1 so you can see the data on the serial monitor as well as sending it to Nextion.

Check the continuity of those wires with a meter. Test from where the pins are soldered to the back of the Arduino to where the connector is soldered to the Nextion.

Hi Perry thanks for that
the one thing I never checked CONINUITY. faulty link lead.
Thnks For your help now to get stuck into your tutorials
Bob

The one thing I never checked CONINUITY. faulty link lead.

:slight_smile:
If you look at the photos in my tutorial you might wonder how I have connected the Nextion wires to the Arduino. I take short (maybe 20mm or so) pieces of wire about the same diameter as the pins that go in those sockets and push one end of the wire into one connector and the other end into the other connector.

Thanks again Perry
Bob

Thats your first tutorial up and running thanks Perry.
Bob