A problem with receiving data by MIT app inventor from ESP01

I connect directly to the esp01 module through the phone's Wi-Fi and do not use the home router.

Did you change port numbers?

What happened to port 8888, which you have in your global url variable?

the port number is set on 8888 and the error is: unable to get a response with the specified url: http://192.168.4.1:8888

I'm sorry the 8887 was a typo.

Point your phone's web browser to http://192.168.4.1:8888 and take a screen shot.
Post the screen shot here.

OK, I will do it and share the result here

One more question, Do I have to consider special settings for the phone's Wi-Fi to connect the application with the Wi-Fi module?

That depends on the result of the browser test, which you have not yet posted.

I did it. Nothing is displayed on the browser screen, but the serial monitor shows the following message:

That proves that your esp is not responding with a web response.

It's time to show us your esp code.

Please, no screen shots. Copy and paste the text here.

OK. The written code is as follows:


#include <SoftwareSerial.h>
//*********************************************Config Uart_PIN
const int PIN_RXD = 2;
const int PIN_TXT = 3;
String reponse ="" ;
const int hall1 = 4;
const int hall2 = 5;
const int hall3 = 6;
const int hall4 = 7;
int i ,z ;
String sendcommand=" " ;
int hallstate1,  hallstate2,hallstate3,hallstate4 ;
SoftwareSerial esp8266(PIN_RXD, PIN_TXT); // RX, TX
void setup() 
{
  Serial.begin(115200) ;
  esp8266.begin(115200) ;
  pinMode(hall1, INPUT);
  pinMode(hall2, INPUT);
  pinMode(hall3, INPUT);
  pinMode(hall4, INPUT);
  initesp8266() ;

}

void loop() 
{
  
  while(esp8266.available())
     {
       if(esp8266.find("0,CONNECT"))
          {
    
             Serial.println("wifi CONNECT") ;
             i=1 ;
          }
       else if(esp8266.find("0,CLOSED"))
          {
            i=0 ;
          }
  
      }
  while(i)
     {
       hallstate1=digitalRead(hall1) ;
       hallstate2=digitalRead(hall2) ;
       hallstate3=digitalRead(hall2) ;
       hallstate4=digitalRead(hall2) ;
      /* hallstate2=digitalRead(hall2) ;
       hallstate3=digitalRead(hall3) ;
       hallstate4=digitalRead(hall4) ;
       */
       //sendcommand=hallpinsensor(hallstate ,x )  ;
       if(hallstate1==LOW)
       {
        sendhall("CHANNEL1") ;
       }
        if(hallstate2==LOW)
       {
        sendhall("CHANNEL2") ;
       }
        if(hallstate3==LOW)
       {
        sendhall("CHANNEL3") ;
       }
        if(hallstate4==LOW)
       {
        sendhall("CHANNEL4") ;
       }
     } 
}
void initesp8266()
{
  Serial.println("*************");
  Serial.println("****** Wi-Fi settings ******");
  Serial.println("AT");
  sendtoesp8266("AT") ;
  waitforesp8266(1000) ;
  Serial.println("AT+RST");
  sendtoesp8266("AT+RST") ;
  waitforesp8266(1000) ;
  Serial.println("AT+CWMODE=3");
  sendtoesp8266("AT+CWMODE=3") ;
  waitforesp8266(1000) ;
  Serial.println("AT+CIPMUX=1");
  sendtoesp8266("AT+CIPMUX=1") ;
  waitforesp8266(1000) ;
  Serial.println("AT+CIPSERVER=1,8888");
  sendtoesp8266("AT+CIPSERVER=1,8888") ;
  waitforesp8266(1000) ;
  
}
void sendtoesp8266(String command ) 
{
  esp8266.println(command ) ;
}
void waitforesp8266(const int timeout)
{
  String reponse ="" ;
  long int time=millis() ;
  while((time+timeout)>millis())
  {
    while (esp8266.available())
    {
      char c=esp8266.read() ;
      reponse +=c ;
    }
  }
  Serial.print(reponse) ; 
}
/*
String hallpinsensor(int hallstate ,int x )
{
  int z
  String sendcommand="" ;
  if(hallstate==0||x==1)
  {
  
    z=11 ;
   
          
  }
  else 
  {
    z=10;
  }
  if(hallstate==0||x==2)
  {
    z=21;
    sendcommand="channel1" ;
  }
  else 
  {
    z=20;
  }
  if(hallstate==0||x==3)
     {
        z=31;
        sendcommand="channel3" ;
     {
    else 
    {
    z=30;
    }
   if(hallstate==0||x==4)
     {
        z=41;
        sendcommand="channel4" ;
        
     {
    else 
    {
    z=40;
    }
   return sendcommand ;
}
*/
void sendhall(String command) 
{
    
    Serial.println("AT+CIPSEND=0,8");
    sendtoesp8266("AT+CIPSEND=0,8") ;
    waitforesp8266(1000) ;
    while(esp8266.available())
     {
       if(esp8266.find(">"))
          {
    
             Serial.println("command") ;
             sendtoesp8266("command") ;
             waitforesp8266(1000) ;
          }
      }
}

I don't see any WiFI libraries or http server libraries in your code.

Where did you get that code?

I suggest searching this board's Tutorials and Guides section for ESP8266 samples.

I see your code is using a C++ String, which may or may not be compatible with the esp8266 or App Inventor. Usually we use a C string (array of chars)

char[] response;
char[] sendcommand;

How is your ESP8266-01?
This device only has 2 GPIO

Google Images ESP8266-01

I use esp01 .I didn't use the esp8266 which requires a library. We send AT command with Arduino and serial communication.

I have tested the code using the available Wi-Fi ready software. I have used Wifi controller software and was able to send and receive data.
But I have a problem to receive with App Inventor.


Uploading: Screenshot_۲۰۲۲۱۱۰۷-۲۰۴۳۰۹_Socket Protocol.jpg...

The header is missing.
httpHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/html; \r\n";

Guide on the ESP8266-01:

I also tested similar projects that others have done with the esp 01. But I still get error 1101 for all of them. I don't know what is the reason!
Should I consider special settings for the phone's Wi-Fi to connect the application and the Wi-Fi module?

Have you done the examples that I have put in the guide?
Load a Firmware as indicated in the guide.

I can think of two possible obstacles that might keep your phone from being able to connect to your IOT device through WiFi ...

  • Your IOT device has started its own subnetwork in its own WiFi channel, but you have not gone into your phone's Settings and asked it to scan for local WiFi connection points to get to the IOT device, or have not yet asked the phone to log onto that WiFi SSID.
  • This is more complex, and deals with IP subnetting, which uses masks to define IP address allocation ranges. An IP address like 192.168.4.1 would require a subnetting mask like 255.255.0.0 to admit that IP address (a Type B network), as opposed to a Type C network with a mask of 255.255.255.0 which would admit only IP addresses like 192.168.1.x or 192.168.0.x (depending on the home router's setup.)

The second possibility is at the limits of my capacity for complexity, and I am probably wrong.

Memiliki kasus yg sama. Apakah sdh menemukan jalan kluar nya