(This kind of reaction means: what have you tried yourself yet?)
QuickFix wrote:Yes
(This kind of reaction means: what have you tried yourself yet?)
see what I am done up to now the only problem is I can not get the text (wifi name and password) from nextion to arduino, but my reaction is dont try to understand codes already you can not, just say me if you know how to get any text from nextion to nodemcu
#include "ESP8266WiFi.h"
#include "Nextion.h"
void t0PopCallback(void *ptr);
void t1PopCallback(void *ptr);
void b204PopCallback(void *ptr);
void t0PushCallback(void *ptr);
void t1PushCallback(void *ptr);
void b204PushCallback(void *ptr);
void APushCallback(void *ptr);
void BPushCallback(void *ptr);
void CPushCallback(void *ptr);
int CurrentPage = 0;
NexText t0 = NexText(0, 5, "t0");
NexText t1 = NexText(0, 6, "t1");
NexButton b204 = NexButton(0, 2, "b204");
NexPage A = NexPage(0, 0, "A"); // Page added as a touch event
NexPage B= NexPage(1, 0, "B"); // Page added as a touch event
NexPage C = NexPage(2, 0, "C"); // Page added as a touch event
char buffer[100] = {0};
NexTouch *nex_listen_list[] =
{
&t0,
&t1,
&b204,
&A,
&B,
&C,
NULL
};
void t0PopCallback(void *ptr)
{
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
Serial.print("A.b204.txt=");
Serial.print(buffer); // This is the value you want to send to that object and atribute mentioned before.
Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial.write(0xff);
Serial.write(0xff);
}
void t1PopCallback(void *ptr)
{
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
Serial.print("A.b204.txt=");
Serial.print(buffer); // This is the value you want to send to that object and atribute mentioned before.
Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial.write(0xff);
Serial.write(0xff);
}
void t0PushCallback(void *ptr)
{
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
Serial.print("A.b204.txt=");
Serial.print(buffer); // This is the value you want to send to that object and atribute mentioned before.
Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial.write(0xff);
Serial.write(0xff);
}
void t1PushCallback(void *ptr)
{
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
Serial.print("A.b204.txt=");
Serial.print(buffer); // This is the value you want to send to that object and atribute mentioned before.
Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial.write(0xff);
Serial.write(0xff);
}
void b204PopCallback(void *ptr)
{
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
Serial.print("A.b204.txt=");
Serial.print(buffer); // This is the value you want to send to that object and atribute mentioned before.
Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial.write(0xff);
Serial.write(0xff);
}
void b204PushCallback(void *ptr)
{
memset(buffer, 0, sizeof(buffer));
t0.getText(buffer, sizeof(buffer));
Serial.print("A.b204.txt=");
Serial.print(buffer); // This is the value you want to send to that object and atribute mentioned before.
Serial.write(0xff); // We always have to send this three lines after each command sent to the nextion display.
Serial.write(0xff);
Serial.write(0xff);
}
void A0PushCallback(void *ptr) // If page 0 is loaded on the display, the following is going to execute:
{
CurrentPage = 0; // Set variable as 0 so from now on arduino knows page 0 is loaded on the display
} // End of press event
void BPushCallback(void *ptr) // If page 0 is loaded on the display, the following is going to execute:
{
CurrentPage = 1; // Set variable as 0 so from now on arduino knows page 0 is loaded on the display
} // End of press event
void CPushCallback(void *ptr) // If page 0 is loaded on the display, the following is going to execute:
{
CurrentPage = 2; // Set variable as 0 so from now on arduino knows page 0 is loaded on the display
} // End of press event
void setup() {
nexInit();
/* Register the pop event callback function of the current text component. */
t0.attachPop(t0PopCallback);
t0.attachPush(t0PushCallback);
/* Register the pop event callback function of the current button0 component. */
b204.attachPop(b204PopCallback);
b204.attachPush(b204PushCallback);
/* Register the pop event callback function of the current button1 component. */
t1.attachPop(t1PopCallback);
t1.attachPush(t1PushCallback);
A.attachPush(APushCallback); // Page press event
B.attachPush(BPushCallback); // Page press event
C.attachPush(CPushCallback); // Page press event
dbSerialPrintln("setup done");
pinMode(13,OUTPUT);
Serial.begin(9600);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
}
void loop() {
nexLoop(nex_listen_list);
int n = WiFi.scanNetworks();
if (n == 0) {
{;}
delay(1000);
}
else {
for (int i = 0; i < 8; ++i) {
if (i==0){
Serial.print("t11.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t12.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t13.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("B.b200.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t14.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t15.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t16.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t17.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
else if (i==1){
Serial.print("t21.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t22.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t23.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("b300.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t24.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t25.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t26.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t27.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
else if (i==2){
Serial.print("t31.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t32.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t33.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("b400.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t34.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t35.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t36.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t37.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
else if (i==3){
Serial.print("t41.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t42.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t43.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("b500.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t44.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t45.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t46.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t47.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
else if (i==4){
Serial.print("t51.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t52.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t53.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("b600.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t54.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t55.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t56.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t57.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
else if (i==5){
Serial.print("t61.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t62.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t63.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("b700.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t64.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t65.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t66.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t67.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
else if (i==6){
Serial.print("t71.txt=");
Serial.write(0x22);
Serial.print(i + 1);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t72.txt=");
Serial.write(0x22);
Serial.print(": ");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t73.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("b800.txt=");
Serial.write(0x22);
Serial.print(WiFi.SSID(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t74.txt=");
Serial.write(0x22);
Serial.print(" (");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t75.txt=");
Serial.write(0x22);
Serial.print(WiFi.RSSI(i));
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t76.txt=");
Serial.write(0x22);
Serial.print(")");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
Serial.print("t77.txt=");
Serial.write(0x22);
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
Serial.write(0x22);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
delay(100);
}
}
}
}