JAndrassy / WiFiEspAT

Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.
GNU Lesser General Public License v2.1
271 stars 44 forks source link

Not connecting to a mobile hotspot #114

Closed itsosmx closed 5 months ago

itsosmx commented 5 months ago

Hello, I'm opennig a mobile hotspot to connect the esp8266 to it, but its not working i dont know why? the problem also its print that iam connecting when iam not

15:46:13.464 -> [Arduino] Attempting to connect to WPA SSID:  IOTM 
15:46:19.305 -> [Arduino] SSID:  IOTM 
15:46:19.305 -> [Arduino] IP Address: 192.168.1.111

the connection to the home network working well and everything working prefect the problem with the hotspot WhatsApp Image 2024-01-14 at 3 51 45 PM (1) WhatsApp Image 2024-01-14 at 3 51 45 PM

#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7);  // RX, TX
#endif
char ssid[] = "IOTM";       // name
char pass[] = "60606060";  // password
byte status = WL_IDLE_STATUS;
IPAddress ip(192, 168, 1, 111);
bool InitESP() {
  WiFi.init(Serial1);  // initialize ESP module
  WiFi.config(ip);
  // check for the presence of the shield
  if (WiFi.status() == WL_NO_MODULE) {
    Print("Communication with WiFi module failed!");
    return false;
  } else {
    // attempt to connect to WiFi network
    while (status != WL_CONNECTED) {
      Print("Attempting to connect to WPA SSID: ", ssid);
      // Connect to WPA/WPA2 network
      status = WiFi.begin(ssid, pass);
      delay(1000);
    }
    Print("SSID: ", WiFi.SSID());
    Serial.print("[Arduino] IP Address: ");
    Serial.println(WiFi.localIP());
    return true;
  }
}

ESP firmware

15:33:16.898 -> AT+GMR
15:33:16.898 -> AT version:1.7.1.0(Jul 15 2019 16:58:04)
15:33:16.929 -> SDK version:3.0.1(78a3e33)
15:33:16.961 -> compile time:Feb 14 2020 09:19:42
15:33:17.007 -> OK
JAndrassy commented 5 months ago

ESP chips don't support 5 GHz WiFi

itsosmx commented 5 months ago

@JAndrassy I changed the band to 2.4GHz and also not working.

itsosmx commented 5 months ago

more details

18:35:52.142 -> esp> AT+CIPSTATUS ...sent
18:35:52.142 -> esp> STATUS:5 ...matched
18:35:52.177 -> esp> OK ...matched
18:35:52.177 -> [Arduino] Attempting to connect to WPA SSID:  IOTM 
18:35:52.177 -> esp INFO: join AP IOTM current
18:35:52.177 -> esp> AT+CWJAP_CUR="IOTM","60606060" ...sent
18:35:53.166 -> esp> ?
18:35:53.213 -> esp> busy p... ...ignored
18:35:54.198 -> esp> ?
18:35:54.234 -> esp> busy p... ...ignored
18:35:55.103 -> esp> WIFI CONNECTED ...ignored
18:35:55.149 -> esp> WIFI GOT IP ...ignored
18:35:55.228 -> esp> OK ...matched
18:35:56.235 -> esp INFO: AP query
18:35:56.235 -> esp> AT+CWJAP? ...sent
18:35:56.269 -> esp> +CWJAP:"IOTM","72:1f:3c:54:17:af",1,-37,0 ...matched
18:35:56.269 -> esp> OK ...matched
18:35:56.269 -> [Arduino] SSID:  IOTM 
18:35:56.269 -> [Arduino] IP Address: esp INFO: STA IP query
18:35:56.269 -> esp> AT+CIPSTA? ...sent
18:35:56.340 -> esp> +CIPSTA:ip:"192.168.1.111" ...matched
18:35:56.374 -> esp> +CIPSTA:gateway:"192.168.1.1" ...matched
18:35:56.407 -> esp> +CIPSTA:netmask:"255.255.255.0" ...matched
18:35:56.407 -> esp> OK ...matched
18:35:56.407 -> 192.168.1.111
18:35:56.407 -> esp INFO: begin server at port 80
18:35:56.408 -> esp> AT+CIPSERVERMAXCONN=1 ...sent
18:35:56.442 -> esp> OK ...matched
18:35:56.442 -> esp> AT+CIPSERVER=1,80 ...sent
18:35:56.484 -> esp> OK ...matched
18:35:56.484 -> esp> AT+CIPSTO=60 ...sent
18:35:56.484 -> esp> OK ...matched
18:35:56.484 -> [Arduino] Done Initialize 
JAndrassy commented 5 months ago

a server? I think a hotspot only allows to connect to Internet over the 'data' connection. It will not allow the connected devices to communicate to each other and the phone itself can't access the devices too. It is not a router.

itsosmx commented 5 months ago

oh no do you know any workaround or something to make it work with hotspot , i need to make it cuz it will work in a place where there is no wifi

JAndrassy commented 5 months ago

to access the Arduino from phone you can start local Access Point on the Arduino

itsosmx commented 5 months ago

Its working now, after removeing the config ip

WiFi.config(ip)