# Enhanced Nextion Library with multi display instance support
Jyrki Berg 01/08/2024 (https://github.com/jyberg) Version 1.5.1
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:
STD_SUPPORT
define replaced with platform ESP8266 define if other platforms supports needed std functionality add platform define with or (||
).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:
NexHardware.cpp
)CurrentPageIdCallback
, systemStartUpCallback
, ... see NexHardware.h
NexObject
.std::vector
etc..All boards, which has one or more hardware serial, can be supported.
For example:
In configuration file NexConfig.h
, you can configure:
DEBUG_SERIAL_ENABLE
to enable debug serial, and used debug serial portNEX_ENABLE_HW_SERIAL
NEX_ENABLE_SW_SERIAL
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 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...).
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.