How to interface Nextion HMI with Arduino Mega2560 and learn how to use Nextion editor and program tags in Arduino

Nextion is a smart hardware HMI (Human Machine Interface) solution published by ITEAD that provides visualization and control interface between human and machine. Nextion HMI comes with simple serial interface and can be easily communicate with Arduino, raspberry pi and other serial Interface compatible hardware’s.
In this post, I will explain how to draw basic HMI screens, setting tag names and reading tags using Arduino.

Circuit Diagram:

NextionHMI_Arduino Mega2560
Circuit Diagram

Nextion HMI Arduino Mega 2560

Nextion HMI Designing:
Watch bellow video for complete tutorial on how to operate Nextion HMI graphic designing software.

Arduino Code:
Note: I am using common anode RGB LED for output testing purpose. So I have written this code to operate common anode LED as output. If you want to drive relays instead of LED, you will need to change the code a bit.

HMI with Arduino working video:

Downloads :

Nextion Library

Nextion HMI file

Nextion TFT file

HMI Images

Arduino Code




  • John Hoffman

    (November 19, 2018 - 5:57 am)

    I am using Nextion basic 5″ and Arduino MEGA 2560 Rev3

    I watched the video and copied the code and download HMI ( had to change device to 5″)

    Outputs are not changing state and I get the output window below. ( Not sure why I would be getting the multiple “err”‘s )

    recvRetCommandFinished err
    recvRetCommandFinished err
    setup done
    recvRetNumber err

    • psadminetechpath

      (November 25, 2018 - 8:06 am)

      Can you copy paste your error here .. i will try to rectify the problem ..

  • Siddhi

    (December 7, 2018 - 2:18 pm)

    Hello, actually I am having doubt for the arduino and nextion screen display .
    I am getting the input on the digital pin of arduino and by using pulse in function I am calculating the time period of the pin being low.
    And then I have a formula in which I placed that time value and the answer of the formula needs to be displayed on the nextion screen. I have used text box for that and programed according t that but I am not getting the value on the screen but getting on the serial monitor of arduino. So can you help me out. Thank you.

    • psadminetechpath

      (December 9, 2018 - 12:36 am)

      If you are getting output on serial monitor and not on nextion means there is something wrong in particular tag definition for text box. Check your code again.
      Or send your code and nextion hmi file to me, i will try to help you out with the code..

      • siddhi

        (December 11, 2018 - 2:19 pm)

        Thank you sir for your help.I got the output. I did small mistake in my arduino sketch that’s wahy i was unable to get the ouput on the screen.

        • Sahil Ahmad

          (January 9, 2019 - 11:26 pm)

          I am also getting the same error (recvRetCommandFinished err). Getting this error wherever I am trying to write on any text box. Can you please help?

Leave a Reply

Your email address will not be published. Required fields are marked *