Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Interfacing Nextion HMI with MCU

April 3, 2021 By Aimee Kalnoskas

In the previous tutorial, we learned how to use the Nextion HMI editor. In this tutorial, we will is studying the advanced features of the HMI and learn how to interface an external microcontroller with nextion HMI. Our focus will be on communication protocol, command set, and data synchronization.

Nextion HMI talks with external modules on UART serial communication. The default baud rate is 9600 bps. HMI works on 5 V, so UART is 5 V tolerant.

Output from HMI

HMI output a fixed-sized byte array whenever any event of an object is exercised. Let’s see it in the debugger.

First, select the object and activate its events(touch or release). Every object placed on the HMI canvas has events. You can activate them if you want the object to communicate with the external microcontroller. I have an image on page 1 of HMI. I want it to communicate with the external microcontroller.

After event selection, compile the code and run the debugger. Click on the picture, and you will see two-byte arrays appearing in the simulator return window.

The first-byte array is generated on touch, and the second on release. What the byte array represents?

These bytes are sent through the UART port to the external microcontroller in the real application. Bytes can be interpreted, and a response can be sent back.

The response can be an action of any type.

  • Change image, color, text.
  • Display text, date, time, temperature, etc

Microcontroller-to-HMI instructions

Let’s see how an external microcontroller can request action on event reception. According to the nextion instruction set, each object attribute can be changed by an external microcontroller. Plenty of instructions are listed on their website. Not all the instructions are supported by each HMI. Enhanced versions support all the instructions, whereas the basic version is limited to instructions. Suppose we want to change the text in the text box.

Instruction format is objectname.attribute=Update

t0=object name

txt=attribute (text specifier)

During debugging, you can check the result of the above instruction. Input the instruction in the instruction input area and hit enter. Text will be updated.

 To change the color of text and background instructions are

All the instructions are listed on the following link (Nextion instruction list).

Interfacing Arduino with Nextion display

Simple and straight connections. Arduino Tx to Rx of Nextion and Rx to Tx. Nextion operates on 5 volts, so an Arduino regulator is enough to power the Nextion display.

Writing Arduino code for HMI from scratch is timing consuming and requires plenty of effort. Few predefined libraries are available which can be utilized. Libraries didn’t offer all the functions, but you can define yourself in libraries.

One such library is EasyNextionLibrary.h. A sample code is below.

All the instructions are similar to the one explained above.

Do a DIY project with Nextion: Where to purchase parts?

Mouser: Nextion HMI display
Arduino: Arduino Uno
Mouser: Power supply

 

You may also like:


  • Introduction to USB: Advantages, Disadvantages and Architecture (Part 1/6)

  • Getting started with Nextion HMI

  • Introduction to USB: Advantages, Disadvantages and Architecture (Part 1/6)
  • HMI systems
    Human Machine Interface systems: Harmonising man and machine

  • Touchscreens or Human Machine Interface (HMI)

  • How human-robot interactions are improving

Related Articles Read More >

How to monitor pH levels in an aquarium using Arduino
TV remote hack using Arduino and IR sensor
Gesture sensor using Arduino
How to build a metal detector using an inductive proximity sensor with Arduino

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Introduction to Wireless Modules
  • ADC with NRF24LE1 (Part 2/14)
  • Interrupts with NRF24LE1 (Part 3/14)
  • Power Failure Indicator in NRF24LE1 (Part 4/14)
  • Using EEPROM of NRF24LE1 (Part 5/14)
  • PWM with NRF24LE1 (Part 6/14)

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

Recent Articles

  • What are Application Specific ICs?
  • Introduction to LUFA
  • What are the different types of integrated circuits?
  • Introduction to Wireless Modules
  • ADC with NRF24LE1 (Part 2/14)

RSS EDABOARD.com Discussions

  • Inductive Current , High Current Track
  • Mains voltage range in India?
  • Thyristor choice?
  • Inspecting split AC control board not running the fan
  • Trying to repair an RF generator

RSS Electro-Tech-Online.com Discussions

  • Tesla coil progress
  • Two switch forward topology WEIRD waveform and efficiency issue
  • EasyEDA Discovery / Tip
  • Ideas for a homemade tv set?
  • How to breadboard with WSON devices.
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • EE Design News
    • DIY Reviews
    • Guest Post
    • Sponsored Content
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering