I made an App to get data from ESP32 and display it in the App. Am getting an error saying 'ERROR 1101: Unable to get Response from specified URL:http://192.168.4.1 .
I have attached the App inventor BLOCKs and as well as App ERROR messages screenshots for reference.
This is the code I used on esp32
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
// Set these to your desired credentials.
const char *ssid = "PODA";
const char *password = "";
WiFiServer server(80);
int sensorValue ;
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("Configuring access point...");
// You can remove the password parameter if you want the AP to be open.
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.begin();
Serial.println("Server started");
}
void loop() {
sensorValue = analogRead(33);
WiFiClient client = server.available(); // listen for incoming clients
client.print("<HEAD>");
client.print("<meta http-equiv=\"refresh\" content=\"1\">");
if (client) { // if you get a client,
Serial.println("New Client."); // print a message out the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
if (c == '\n') { // if the byte is a newline character
if (currentLine.length() == 0) {
client.print("<HEAD>");
client.print("<meta http-equiv=\"refresh\" content=\"1\">");
if ((sensorValue >= 0) and (sensorValue <=500)) {
client.print("SEE YOU SOON");
client.println();
break;
}
else if ((sensorValue >= 501) and (sensorValue <=1000)) {
client.print("HELLO");
client.println();
break;
}
else if ((sensorValue >= 1001) and (sensorValue <=1500)) {
client.print("BYE");
client.println();
break;
}
else if ((sensorValue >= 1501) and (sensorValue <=2000)) {
client.print("HELP");
client.println();
break;
}
else if ((sensorValue >= 2001) and (sensorValue <=3000)) {
client.print("DANGER");
client.println();
break;
}
else {
client.println();
break;
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
}
client.stop();
Serial.println("Client Disconnected.");
}
}