In previous blog, we’ve given a simple example of Nextion. In this blog, we will show you how to apply Nextion in an Arduino project.
Hardware we use
- Nextion 2.4″
- Iteaduino UNO
- Rotary Potentiometer Brick
Click here to download the HMI file.
Demonstration Video
Hardware Connection

Code we upload to Iteaduino UNO
float getValue;
int value;
float oldvalue;
void setup() {
Serial.begin(9600);
}
void loop() {
getValue = analogRead(A0);
if (getValue==oldvalue)
{;}
else
{ oldvalue=getValue;
getValue=(getValue*100/1023);
value=getValue;
Serial.print("j0.val=");
Serial.print(value);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t0.txt=");
Serial.write(0x22);
Serial.print(value);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
}
delay(100);
}
If use the Arduino library we offer, it will be much concise and easy to read.
#include nextion.h //view more about the arduino_nextion_library here:https://github.com/itead/ITEADLIB_Arduino_Nextion
float getValue;
int value;
float oldvalue;
Nextion bar(j0);
Nextion percent(t0);
void setup() {
Serial.begin(9600);
}
void loop() {
getValue = analogRead(A0);
if (getValue==oldvalue)
{;}
else
{ oldvalue=getValue;
getValue=(getValue*100/1023);
value=getValue;
bar.val(value);
percent.txt(value);
}
delay(100);
}
Step by step image tutorial of how to build the Nextion project for this demo HERE.



