I want to send a 1 from Nextion display to arduino once a timer has ended.
I used the command
to send but I have no idea how to fetch this 1 value...
The goal is to change a variable in arduino once the timer has ended.
Any help pse.
Thanks in advance
I have successfully used this library (link in instructions) in my weather project. It's simple and does the trick.. The official Nextion library has more to it, but this works for my needs.
if you are using ITEAD Library
NexVariable va0 = NexVariable(0,1,"va0");
add &va0 to your Nex_listen_list
in your loop or when you have a function callback, use, va0.getvalue(&number) and va0.sendvalue(&number)
If you can attach your .ino file and HMI file. I can take a look into that.
When your compiler gives errors it is not enough to say it has given errors.
You must look at the errors that it gave to solve your compile error.
This is basics of programming.
No one can see what errors was given
(and don't want to either - so please do not post 200 lines of compile errors)
Please download and install the Iteadlib Arduino Nextion Library
If you need the link let me know. Let me know when this task is complete
Task 2: Open the CompNumber_v0_32.HMI attached below
- Ensure to change the settings for your Nextion Device Series and Model
- Ensure to Save the file so that it is saved in v0.43 format from the Nextion Editor
- Build this HMI and upload to your Nextion Device.
Task 3: Open the corresponding CompNumber_v0_32.ino file below.
Examine the code.
Number component is defined near top as
NexNumber n0 = NexNumber(0, 3, "n0");
To read a number from the n0 component you need an Arduino side variable of type uint32_t
Look at the b0PopCallback function you will see number is declared
You will see two lines down where the read is done.
To send this value to serial monitor you need to use dbSerialPrintln
To set the number on the Nextion use the setValue function
To have Arduino listen for a Touch Press/Release Event the n0 needs
to be included in the nex_listen_list, you will see this near the top
NexTouch *nex_listen_list =
But it also needs to have in the setup which function Iterate will pass
the Touch Press/Release touch event to. To define a press (PUSH)
To define a release (POP)
After this is defined in setup, you must actually have the function code
that you just stated
void n0PopCallback(void *ptr)
// your code when n0 is released
void n0PushCallback(void *ptr)
// your code when n0 is pressed
Setup must also have a call to initialize nextion Serial
Finally, the whole listening aspect has to be done inside loop
So that each run through loop the Arduino can look for the event
it seems that does not call the library...
and point 2. include the library is #include <Nextion.h>
not # include "Nextion.h"
If you can't get from the example given
no one is going to write your program for you
- You must learn and code it yourself.
Arduino has their flavour of C
C programming languages are Case Sensitive.
Core Libraries in installed space are included with angle brackets
Other Libraries in user space are included with double quotes
Looking to Nextion.h file will reveal this file merely includes all other needed files