i am very new to display and programming. I was trying to update a text field on my 2nd page(i renamed it as weather). From the main page, i can able to navigate to 2nd page by clicking button(page navigation is from editor and i am not using Nextion library)
here is my code,
void show_weatherpage(){
Temperature = dht.readTemperature(); // Gets the values of the temperature
Humidity = dht.readHumidity(); // Gets the values of the humidity
Serial.println((int)Temperature);
Serial.println((int)Humidity);
mySerial.print(“weather.wetn0.val=” );
mySerial.print((int)Temperature); //mySerial.print("");
mySerial.print(“weather.wetn1.val=” );
mySerial.print((int)Humidity); //mySerial.print("");
mySerial.write(0xff);
mySerial.write(0xff);
mySerial.write(0xff);
}
if i comment any of ""mySerial.print("weather.wetn** ( meaning updating one field ), display is updating value
If i enable both "mySerial.print(“weather.wetn”, both fields is going blank
The reason is probably that you’re missing the triple mySerial.write(0xff) after the first command (assigning a value to wetn0). You need to add it to every command you’re sending, not just once for a group of commands.
Btw. if you want to share code, you can put ``` before and after a block of code and it will be formatted as code. For inline code like I used it in this post, you can use a single ` before and after the code.
Command looks right… But without knowing your HMI file there’re quite a few possible issues:
Is that page currently active? If not, is the component global? Otherwise you can’t access it.
Is everything spelled correctly? You called the page “Home”, but wrote “home” in the command. I assume it’s a simple typo in your post here but it would matter for Nextion.
How about the txt_maxl attribute of your text component? Is it big enough?
I’d suggest to use the Nextion Simulator/Debugger. Swap your serial ports*, such that the Arduino sends the Nextion commands to your computer. Then, in the Nextion Editor, use the Debug function and set it to MCU Input (bottom left). Now your Arduino can communicate with your HMI application running in the editor. The big advantage is that you can see all the data and commands that have been sent to the (virtual) Nextion as well as any potential error codes.
* You could also use a USB-Serial adapter to connect both serials to your computer at the same time (f.ex. using another Arduino).
While I think debugging with the editor is the easiest solution (because you don’t have to reupload your HMI file every time you make a change), you could also listen for error codes on mySerial and pass them to Serial to see if there are any errors.
Is that page currently active? If not, is the component global? Otherwise you can’t access it.
Yes, that is the default page . moreover i am calling that function under setup. While testing text are loading to text field.
Is everything spelled correctly? You called the page “Home”, but wrote “home” in the
command. I assume it’s a simple typo in your post here but it would matter for Nextion.
Home is for function and home is the print passing from nextion. Spellings are correct.
How about the txt_maxl attribute of your text component? Is it big enough?
it was set to “10”, and i am trying to display (in test) maximum of 2 charactor
Thanks for the update, glad you solved it. I completely overlooked the missing quotes.
Kind regards,
Max
1 Like
This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).