Nextion Display with Arduino without nextion library

    Hello Friends, usually you seen nextion display communicate  to Arduino using nextion library.we are going to show you how do configure nextion display with Arduino without using (No Nextion.h needed).

About Project : 

   Nextion have library for Arduino. but its very memory consuming and also complicated, so it’s better to do with USART Rx/Tx, we are developing project without any library. We are developing this project in two part. One side nextion display screen creates and its programming. Other side Arduino programing.


 Nextion display and Arduino communicate with Rx/Tx transfer data.

Components Requirements:

·        1 ×  Arduino

·        1 ×  Nextion Display ()

·        1 ×  TTL Serial to USB Adapter

·        1 ×  220 Ω Register

·        1 ×  LED

·        8 ×  Jumper Wires


Part – I  Nextion screen create & programming

  If you don’t know how to use nextion editor, please follow this link , have all about nextion display information it just beginners's guide. I created nextion screen as given below

                       

Figure 1

As shown in figure 1 
main screen Id: page0

Slider Id : h0

Text Box Id : t0,t1

Two button  Id : b0,b1


User code instruction for nextion you can find on this linkIts time to write user code for slider h0, button b0,b1 .Now write user code for communicate with Arduino, we are sending data in string form

First we set baudrate for nextion display to communicate

Page0 : postinitialize Event

                     bauds=9600

h0 : TouchRelease  Event

here we care va0 as string variable to convert number to string

            covx h0.val,va0.txt,0,0
              prints va0.txt,3

b0 : TouchRelease  Event

             prints b0.txt,2

b0 : TouchRelease  Event

            prints b0.txt,2 

Interface 

  Upload Project HMI file using TTL Serial to USB Adapter 

  

Nextion display video tutorials link is Nextion Display Tutorial

Part -II Arduino Programming

  Its time write code on other part of project,  Arduino code

  First set data for serial communication baudrate

 ON/ OFF button will do built-In LED On/Off, for that initialize Pin 13 to output mode

   Serial.begin(9600);

  pinMode(13, OUTPUT);

  For reading string coming  from nextion display we need to check serial 

   if(Serial.available())

after read data till data available on serial

while(Serial.available())

  {

    Data_From_Display += char(Serial.read());

  }

Compare string available with what we sent it from nextion display

ON/OFF  or  value of slider

If ON string come write

digitalWrite(13,HIGH);

OFF string coming ,  

digitalWrite(13,LOW); 

else coming data is slider value so we need to send it back to page0 textbox t0, for that we have to

send string as given below             

“page0.t0.txt =” “Data_From_Display”

Here page0 : screen Id,

             t0 : textbox id

           Data_From_Display : string come from slider

Completing sending data to nextion display, need to write after every string , it specify string is compete.

       Serial.write(0xff);

       Serial.write(0xff);

       Serial.write(0xff);

Source code for Arduino and nextion display project file can download from below,

Interface 

 

Hope you find this project interesting and useful,Be sure to leave your comments, questions and edit suggestions.