Skip to main content

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.

                       

Comments

  1. Thank you so much. I really liked how you explained the project step by step. It was really helpful.

    ReplyDelete

Post a Comment

Popular posts from this blog

ARDUINO PORTENTA H7 Tutorial

Portena H7 simultaneously run high level code along with real time tasks. H7 main processor is the STMICROELECTRONICS dual core STM32H747  including an ARM CORTEX -M7 running at 480 MHz and ARM COTEXT M4 running at 240MHz. The two core communicate via a Remote Procedure call mechanism that allows calling functions on the other processor seamlessly. The  Portenta H7  simultaneously runs high level code along with real time tasks, since it includes two processors that can run tasks in parallel. For example, it is possible to execute Arduino compiled code along with MicroPython one and have both cores to communicate with one another. The Portenta functionality is two-fold, it can either be running like any other embedded microcontroller board or as the main processor of an embedded computer. There are many features in one module  STM32H747 dual-core processor 8 MB SDRAM 16 MB  NOR FLASH 10/100 ETHERNET PHY USB HIGH SPEED SECURE ELEMENT WIFI/ BLUETOOTH MODULE UFL CO...

Getting Started with mmWave Sensor MR60BHA1 and Arduino

Introduction : The MR60BHA1 mmWave Sensor is a compact and efficient radar sensor that utilizes millimeter-wave technology to detect objects, measure distance, and track motion. With its high precision and low power consumption , this sensor is ideal for applications in robotics, automation, and security systems. . Millimeter-wave (mmWave) sensors operate at extremely high frequencies, typically in the 30GHz to 300GHz range, allowing them to detect objects with great accuracy regardless of lighting conditions. Unlike optical sensors, mmWave sensors can penetrate fog, dust, and even certain materials, making them reliable in harsh environments. The MR60BHA1 is one such sensor that operates at 60GHz , providing precise motion detection and range measurement capabilities. By integrating the MR60BHA1 with an Arduino , users can develop a variety of projects, such as human presence detection , security systems , and robotic navigation . In this blog, we will explore how to interface...

Exploring Color Sensing with Arduino: A Journey into the World of RGB Detection

                           In today's tech-driven world, the Arduino platform continues to empower enthusiasts and professionals alike to explore the realms of electronics and programming. One fascinating avenue within this domain is color sensing using Arduino boards. With the integration of RGB sensors, Arduino opens up a world of possibilities for projects ranging from color sorting machines to ambient light displays. Let's delve into the exciting world of color sensing with Arduino and discover its applications, principles, and how you can embark on your own creative endeavors. Understanding Color Sensing       At the heart of color sensing lies the ability to distinguish between different wavelengths of light. RGB (Red, Green, Blue) sensors are commonly used for this purpose. These sensors typically consis...