Start a new topic

Sending a integer to Nextion number component

Hello


I tried searching but didn't find an answer to my problem or anyone else with this problem


I'm sending a integer from Arduino to Nextion, the problem is Nextion won't receive it, I can send a string and display it on Nextion but Number component isn't behaving in the same way


Heres how I'm sending a string to text component, this works:


    Serial3.print("t1");

    Serial3.print(".txt=");

    Serial3.write(0x22);

    Serial3.print(*var);

    Serial3.write(0x22);

    Serial3.write(0xFF);

    Serial3.write(0xFF);

    Serial3.write(0xFF);


This is how I'm trying to send a integer to a number component, this does not work:


    Serial3.print("n1");

    Serial3.print(".val=");

    Serial3.write(0x22);

    Serial3.print("5000");

    Serial3.write(0x22);

    Serial3.write(0xFF);

    Serial3.write(0xFF);

    Serial3.write(0xFF);


It should be noted that in the simulator, this method works, sending n1.val="5000" changes n1 number component in to 5000.


Any ideas on how to solve this issue without using the Nextion library?

1 Comment

I ended up solving it by myself, when writing to a number component you should send n1.val=5000 and not n1.val="5000",


So this works:


Serial3.print("n1");

    Serial3.print(".val=");

    Serial3.print("5000");

    Serial3.write(0xFF);

    Serial3.write(0xFF);

    Serial3.write(0xFF);

Login or Signup to post a comment