-
Notifications
You must be signed in to change notification settings - Fork 7.7k
-
I have an ESP32-WROOM-32 module which I was trying to connect it with WiFi, but couldn't. Reading and writing data to a device (sensor, etc) has no problem. But only connecting to WiFi, it didn't work.
E (xxxx) wifi:Set status to INIT
The error above only is shown when I tried to connect the ESP32 with Hotspot. At the other hand, when I tried to connect it with WiFi router, it didn't show any error yet connect successfully.
I had tried to add WiFi STA mode on the code, and also try to figure out the error. But all I could find are only: WL_DISCONNECT (on Router's WiFi and Hotspot) and WL_CONNECT_FAILED (on Hotspot).
Anybody has an idea on this?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 5 comments 6 replies
-
@DespyZx The "Hotspot" is generated from? Can you provide a short example code, where the problem can be reproduced?
Beta Was this translation helpful? Give feedback.
All reactions
-
The hotspot is generated from Mobile Phone.
The problem was found using usual code to connect to WiFi.
This is the code that I was using.
#include <WiFi.h>
#define LED_BUILTIN 2
// Set the IP address, gateway, and subnet mask
IPAddress ip(192, 168, 100, 100); // Replace with your desired static IP address
IPAddress gateway(192, 168, 100, 1); // Replace with your gateway address
IPAddress subnet(255, 255, 255, 0); // Replace with your subnet mask
void setup() {
WiFi.disconnect(true);
WiFi.mode(WIFI_STA);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Serial.begin(115200);
Serial.println("Scanning available networks...");
int numOfNetworks = WiFi.scanNetworks();
Serial.print("Number of available networks: ");
Serial.println(numOfNetworks);
for (int i = 0; i < numOfNetworks; i++) {
Serial.print(i + 1);
Serial.print(": ");
Serial.println(WiFi.SSID(i));
}
// Set the static IP address, gateway, and subnet mask
if (!WiFi.config(ip, gateway, subnet)) {
Serial.println("Failed to configure static IP address.");
}
// Wait for connection
int wait = 0;
while (WiFi.status() != WL_CONNECTED) {
// Connect to WiFi
WiFi.begin("SSID", "Password");
wait++;
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
delay(5000);
Serial.println("Connecting to WiFi...");
if(wait == 5)
{
WiFi.disconnect(true);
Serial.println("Reconnecting...");
wait = 0;
ESP.restart();
}
}
}
void loop() {
// Your code goes here
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("Test!");
}
These are all the Libraries that I was using:
- WiFi101 by Arduino Version 0.16.1
- EspSoftwareSerial by Dirk Kaar, Peter Lerup
- LiquidCrystal by Arduino, Adafruit
- ATtinySerialOut by Armin Joachimsmeyer
- Adafruit FONA Library by Adafruit
- Adafruit MQTT Library by Adafruit
- Adafruit SleepyDog Library by Adafruit
- Adafruit Unified Sensor by Adafruit
- DHT sensor library by Adafruit
- LiquidCrystal I2C by Frank de Brabander
- ThingSpeak by MathWorks support@thingspeak.com
- arduino-display-lcdkeypad by dieter.niklaus@gmx.net
- spin-timer by Dieter Niklaus dieter.niklaus@gmx.net
These libraries might not be responsible for the error happened. ( I tried to reproduce the error on another device with different libraries, but the error still occurs )
Fyi, if I remove the 'IPAddress' codes on the codes above, the error still happens.
These are the URL I use for the additional board.
"http://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
The board I was using was "ESP32 Dev Module"
Hope this could answer your question.
Beta Was this translation helpful? Give feedback.
All reactions
-
Which phone Exactly? Had this problem in the past. Using a different phone from an other brand solved.
Beta Was this translation helpful? Give feedback.
All reactions
-
I used POCO and Realme, both had the same issue. Which brand were you using?
Beta Was this translation helpful? Give feedback.
All reactions
-
No problem with Samsung A52.
Beta Was this translation helpful? Give feedback.
All reactions
-
I had tried with iPhone and Vivo (if I'm not mistaken), the error "INIT" doesn't appear, but it couldn't be connected to the WiFi anyway.
Beta Was this translation helpful? Give feedback.
All reactions
-
Using WiFi.config(ip, gateway, subnet)
to set a static IP might make some APs unhappy. I'm not familiar with WF101 library. Can you try your project without it? Your code example should work with #include <WiFi.h>
.
Beta Was this translation helpful? Give feedback.
All reactions
-
It couldn't work either.
Beta Was this translation helpful? Give feedback.
All reactions
-
I am also getting the same problem. Did you find any solution?
Beta Was this translation helpful? Give feedback.
All reactions
-
Nope, it still occurs.
Beta Was this translation helpful? Give feedback.
All reactions
-
I am too facing the similar issue. It connects to phone hotspot but not when the hotspot is generated by another ESP8266 module.
Kindly suggest some solution.
Beta Was this translation helpful? Give feedback.