Getting Started With Arduino and Nextion (pt 3)

In the previous instructable we saw how data is received from the Nextion. There was, however, only 1 page and 1 button sending 1 value. In this instructable we'll see how to deal with multiple pages, buttons and values that are sent "simultaneously".

As with the other 2 instructables, we'll do this without the libraries.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Create Your Interface

Like in the previous instructable you can download the interface and I'll point out things to note:

  1. There are now 2 pages. Note the code in their "Preinitialize" events. This hides the text boxes.
  2. On page0 note that the "2 is a party" has 2 events. The touch press event sends the component's id ahead of the actual data (send component id is checked). The release event sends the data.
  3. The same goes for the buttons on page1.
  4. All the increment/decrement buttons have code to ensure that only positive numbers are entered.

Remember to compile the interface and copy the .tft file from the build folder to the SD card. Load the interface onto the Nextion via the SD card.

Step 2: Upload the Arduino Sketch

The previous two instructables shows the evolution of the code to get to here. This sketch can handle multiple values and multiple pages. You can easily add more functions to the sketch for your extra components and pages.

Once again I've tried adding enough comments to the sketch to make it easily understandable.

Step 3: Connect the Nextion to the Arduino

Connect the red and black wires to 5V and ground on the Arduino respectively. Connect the blue (TX) wire of the Nextion pin 10 and the yellow (RX) wire to pin 11.

Step 4: Test

Open the serial monitor and set the baud rate to 57600 bits per second. See the info that comes in from the Nextion as you press different buttons

Be the First to Share

    Recommendations

    • Instrument Contest

      Instrument Contest
    • Make it Glow Contest

      Make it Glow Contest
    • STEM Contest

      STEM Contest

    2 Discussions

    0
    None
    tsgcoltd

    2 years ago

    It was really great was the only circuit that was set-up is simple and practical.

    You have a career in teaching

    Thank you...

    1 reply
    0
    None
    Gideon Rossouwvtsgcoltd

    Reply 2 years ago

    Thank you for the kind words. I'm glad it was useful to you.