jyberg / Enhanced-Nextion-Library

Enhanced Nextion library for Arduino, NodeMcu, Esp8266,...
MIT License
47 stars 23 forks source link
arduino esp32 esp8266 nextion nodemcu tft

# Enhanced Nextion Library with multi display instance support

Jyrki Berg 01/08/2024 (https://github.com/jyberg) Version 1.5.1

Introduction

Nextion Arduino library provides an easy-to-use way to manipulate Nextion serial displays.
Old deprecated Enhanced Nextion Library with single display support can be found with Release tag 0.12.1

Nextion has also hidden commands see if intrested see link to UNUF project in Links section.

This new major updated library version has atleast following improvements:

Converting from old to new library version:

// Get Nextion display instance by defining:
// esp8266 / NodeMCU software serial ports
SoftwareSerial mySerial_D1(D2, D1); // RX, TX

// Declare Nextion instance
Nextion *next_D1 = Nextion::GetInstance(mySerial_D1); // uses software serial

// Declare a main page object and other objects
// Display instance is first parameter, and in page object component id is removed
NexPage p0_D1(next_D1, 0, "page0");

// Check nextion events using nextloop over Nextion instance
next_D1->nexLoop(nex_listen_list_D1);<br />

See ./examples folder on how to use new version and multiple display support with esp8266/NodeMCU board!

Earlier improvements:

Suppported Mainboards

All boards, which has one or more hardware serial, can be supported.

For example:

Configuration

In configuration file NexConfig.h, you can configure:

If you want activate Debug messages, uncomment //#define DEBUG_SERIAL_ENABLE line and define serial port used for debug messges using line: //#define dbSerial Serial, it is responsibiity of main program to initialize/open debug serial port.

NodeMcu esp8266 connectivity tips

NodeMcu board pin numbers not match with Esp8266 pin numbers. So use D<x> pin number definitions from pins_arduino.h
You need to remember that Software serial is not nessessary workin with out problmes at least when using NodeMcu/Esp8266 boards (See power tips...).

Power tips

Nextion and NodeMcu/Esp8266 is sensitive with power quality and current. Especially when Software serial is used, (Serial message quality can be bad and then functionality is not stable...). Don't power Nextion display from NodeMcu/Esp8266 board, because Nextion takes guite mutch of current, and NodeMcu/Esp8266 internal power requlator is not good enough. Use separate power to power Nextion and connect Nextion and NodeMcu/Esp8266 board GND to commond GND point.

Useful Links