Reputation: 39
This is my code
#include <WiFi.h>
const char* ssid = "wifiname";
const char* password = "12345678";
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA); // SETS TO STATION MODE!
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(1000);
}
Serial.print("IP is ");
Serial.println(WiFi.localIP());
}
void loop() {
}
I can found my iPhone's personal hotspot using the WiFiscan routine, but I can't connect to it.
Upvotes: 2
Views: 13275
Reputation: 11
Changing my phone's name to remove the apostrophe and enabling "Maximize Compatibility" worked for me!
Upvotes: 1
Reputation: 420
I find a solution for that issue by trials and may be it could help :
1.You have to be in the iPhone hotspot settings when the ESP32 is trying to connect specially if there's no other device connected to the hotspot!
2.Hotspot works fine until the phone gets locked and ESP32 went to deep-sleep and after wake up the ESP32 cannot connect again in some cases until you go again to the hotspot page!
Upvotes: 0
Reputation: 51
For me, the apostrophe in the default hotspot SSID was problematic (ex: John Doe's iPhone
). I changed the iPhone name (and therefore the SSID name) in Settings > General > About
. Afterwards, my ESP32 was able to connect to the hotspot.
Potential caveat: instead of programming the firmware directly, I was using ESP Web Tools to configure the ESP32 with ESPHome, so my issue may have been specific to the ESPHome firmware (and how it handles character encodings).
Upvotes: 5
Reputation: 752
I believe the iPhone hotspot turns off (or at least stops broadcasting an SSID) shortly after leaving the "Personal Hotspot" screen in "Settings". Leaving the "Personal Hotspot" screen open with my iPhone unlocked allowed me to connect my ESP32.
This Apple support discussion from 2011 describes the behavior (assuming it hasn't changed in the last decade): https://discussions.apple.com/thread/2784174
Upvotes: 2
Reputation: 19
FWIW: I have apparently been able to connect the ESP32 chip's Wifi to my iPhone13 pro running IOS 15.3.1. The line of code:
WiFi.mode(WIFI_STA); // SETS TO STATION MODE!
was the break thru allowing me to make this connection. Note that I can make the connection even with settings->personal hotspot->Maximize Compatibility DISABLED.
Upvotes: 1
Reputation: 91
I tested your code and I was able to connect my ESP32 to my iPhone 8+. Since you were able to scan your iPhone's hotspot, you could try the following:
Upvotes: 5