I made an application to obtain different values from ESP32 and display them in the application. I'm getting an error saying 'ERROR 1101: Unable to get the response from the specified URL http://192.168.15.70/on' and I can't find anywhere to resolve it, I've tried many things.
My code for App Inventor:
Command sent through the browser:
Esp32 serial port:
The error presented in the application:
I wanted to write on the label Status! if the LED was ON = ligado or OFF = desligado.
The code in esp32:
#include <WiFi.h> #define led1 2 //string de mensagem enviada pelo client String ClientRequest; //IP estático, de preferencia conectar ESP32 e smartphone na mesma rede IPAddress staticIP(192,168,15,70); //Gateway, colocar o gateway da rede em que está conectado IPAddress gateway(192,168,15,1); //Máscara, colocar a máscara da rede em que está conectado IPAddress subnet(255,255,255,0); //Porta de COM server/client WiFiServer server(80); // Wi-Fi Client WiFiClient client; //variável usada para solicitar o client String myresultat; String ReadIncomingRequest() { //Enquanto houver dados enviados pelo client while(client.available()) { //Atribui para a variável string o comando enviado pelo client ClientRequest = (client.readStringUntil('\r')); //Se existir "HTTP/1.1" na string então recebe comando if ((ClientRequest.indexOf("HTTP/1.1")>0)) myresultat = ClientRequest; } //Retorna variável resultado return myresultat; } void setup() { //Inicializa varíavel sem dados ClientRequest = ""; pinMode(led1,OUTPUT); Serial.begin(115200); delay(10); Serial.println("PRONTO!"); WiFi.begin("Matheus", "12345678"); while (WiFi.status() != WL_CONNECTED) //Enquanto não conectar exibe "." { delay(500); Serial.print("."); } Serial.println("Conectado!"); WiFi.config(staticIP, gateway, subnet); //Configura ip estático, gateway e máscara (definidos no início do código) Serial.println("Seu IP é"); //Exibe IP utilizado pelo ESP32 Serial.println((WiFi.localIP())); server.begin(); //Inicia COM com servidor } void loop() { client = server.available(); if (!client) return; //Enquanto nao existir COM com client aguardar while(!client.available()) delay(1); //Obtem respostas utilizando a função local ReadIncomingRequest ClientRequest = (ReadIncomingRequest()); //Retira dados da página e obtem apenas o comando enviado ClientRequest.remove(0, 5); ClientRequest.remove(ClientRequest.length()-9,9); if (ClientRequest == "on"){ digitalWrite(led1,HIGH); Serial.println("LED ON!"); client.print("ligado"); } if (ClientRequest == "off"){ digitalWrite(led1,LOW); Serial.println("LED OFF!"); client.print("desligado"); } client.flush(); client.stop(); delay(1); }