Hi
I'm trying to do a simple example of communication between an application and ESP32 through an Access Point.
I made a basic example of turning LEDs on and off.
The application works, I can turn the led on/off, but an error message appears on the screen:
And I'm also not able to make the app receive any data from ESP32.
Could anyone help me on this one?
AppInventor Code:
Arduino Code:
#include <WiFi.h> //Inclui a biblioteca
const char* ssid = "ESP32-AP";
const char* pass = "12345678";
WiFiServer sv(80);
int LED_Pin = 2;
void setup() {
Serial.begin(115200);
pinMode(LED_Pin, OUTPUT);
WiFi.softAP(ssid, pass);
Serial.print("Se conectando a: ");
Serial.println(ssid);
IPAddress ip = WiFi.softAPIP();
Serial.print("Endereço de IP: ");
Serial.println(ip);
sv.begin();
Serial.println("Servidor online");
}
void loop() {
WiFiClient client = sv.available();
if (client) {
String line = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n') {
if (line.length() == 0) {
break;
} else {
line = "";
}
} else if (c != '\r') {
line += c;
}
if (line.indexOf("LEDON") > 0) {
digitalWrite(LED_Pin, HIGH);
client.println("Ligado");
}
if (line.indexOf("LEDOFF") > 0) {
digitalWrite(LED_Pin, LOW);
client.println("Desligado");
}
}
}
client.stop();
}
}
Thank you!