This is my first attempt to write to a Nextion 3.2" display, but nothing shows up from the ESP32 . I was successful in creating my screen and defining some text and variable boxes on the Nextion. I set the Baud rate to 115200 on page 0 (only 1 page). When I run the ESP32 and utilize “Serial”, it prints on the serial monitor. When I utilize Serial2.print nothing happens to the Nextion. I suspect it may be the UART. I have a separate USP powering the Nextion with common ground pins If I connect the TX on the Esp32 to the RX pin nothing shows up on the serial monitor. It’s almost like the UART is not working. Here is the code:
#define ENHANCED //
#include "Nextion.h"
NexPage page0 = NexPage(0, 0, "page0");
NexText textNumber = NexText(0, 2, "CurrentControl");
NexText Amps = NexText(0, 1, "Amps"); //I named text block "Amps", ID=1
NexText Amps2 = NexText(0, 14, "Amps2");
NexNumber Temp =NexNumber(0,7,"Temp");
NexHotspot VoltsSet = NexHotspot(0, 13, "VoltsSet"); //Couple of hotspots that do nothing now
NexHotspot AmpsSet = NexHotspot(0, 14, "AmpsSet");
NexHotspot Volts12 = NexHotspot(0, 10, "Volts12");
NexHotspot Volts5 = NexHotspot(0,11, "Volts5");
NexHotspot Volts33 = NexHotspot(0, 12, "Volts33");
NexTouch *nex_listen_list[] =
{
&VoltsSet,
&AmpsSet,
&Volts12,
&Volts5,
&Volts33,
NULL
};
//----------------- S E T U P ----------------------------
void setup(void)
{
nexInit(115200,16,17); // Baud 115200,RX TX pins Libary adjusted.
Serial2.begin(115200,16,17); //Yes the nexInit is supposed to set the pins but just desperate
}
//------------------- L O O P ----------------------------------------
void loop(void)
{
Serial2.print(("Amps=\""));
Serial2.print(("Nextion"));
Serial2.print(("\""));
Serial2.write(0xff);
Serial2.write(0xff);
Serial2.write(0xff);
nexLoop(nex_listen_list);
delay(1000);
}