I tried The following sketch with ESP 8266 (Node – MCU-12E) and it worked fine.
#include “Nextion.h”
const int led = 4;//RED LED aatched to D2 pin (GPIO4)
//Declare your Nextion objects , pageid, component id., component name
NexButton b0 = NexButton(0,2,”b0″);
NexButton b1 = NexButton(0,3,”b1″);
NexText t0 = NexText(0,4,”t0″);
//Register a button object to the touch event list
NexTouch *nex_listen_list[] = {
&b0,
&b1,
NULL
};
//Button b0 component popcallback function
// When ON button is Released the LED turns ON and the state text changes
void b0PopCallback(void *ptr){
t0.setText (“State:ON”);
digitalWrite(led,HIGH);
}
//Button b1 component popcallback function
// When OFF button is released the LED turns OFF and the state text changes
void b1PopCallback(void *ptr){
t0.setText (“State:OFF”);
digitalWrite(led,LOW);
}
void setup(void) {
Serial.begin(9600);
nexInit();
//Register the pop event callback function of the components
b0.attachPop(b0PopCallback,&b0);
b1.attachPop(b1PopCallback,&b1);
pinMode(led,OUTPUT);
digitalWrite(led,LOW);
}
void loop() {
nexLoop(nex_listen_list);
}
=======================================================================================
Then I wanted to same sketch with ESP32 but it was giving compilation error so I did the modifications using Git GUI and Git Bash and explained in git hub. and it worked with ESP 32. but now it is not working with Node MCU.
So I removed the repository of ESP32 as that was install as explained above. But with this now it is giving compilation error for both the boards.
I want to use Nextion HMI with both ESP8266 and ESP 32. Please guide me.
The error message which I am getting now is as below.
=====================================================================================
Arduino: 1.8.12 (Windows 10), Board: “DOIT ESP32 DEVKIT V1, 80MHz, 921600, None”
C:\Users\APTE\Documents\Arduino\libraries\ITEADLIB_Arduino_Nextion-master\NexUpload.cpp:17:28: fatal error: SoftwareSerial.h: No such file or directory
Multiple libraries were found for “SD.h”
compilation terminated.
Used: C:\Users\APTE\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
Error compiling for board DOIT ESP32 DEVKIT V1.
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
Hi.
I answered your question here: https://rntlab.com/question/nextion-with-esp8266/
Regards,
Sara