Getting Error 1101 in app when trying to get value from esp32

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.1Screenshot (185) .

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.");
  }
}

What happens when you try to connect to that URL on your phone using a web browser?

It works, I will get the data

There are some good esp32 tutorials at ESP32. WiFi. WebServer. LED on/off. Static IP. Soft Access Point

Notice the networking differences between examples 3 and 4.

Your lack of connectivity might be due to several factors:

  • Your choice of local IP address (192.169.4.1) for the esp32 might be outside of the IP address subnet range of the local router that your AI2 app connects. Is the subnet 255.255.0.0 or it it 255.255.255.0 ?
  • You are using the web component in your AI2 app, which acts a little differently from the WebViewer component in the case of connection via password. What happens if you use a WebViewer instead of Web1?

I suggest using this board's search (magnifying glass) for '1101' for more ideas.

It worked when I used the web viewer component

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.