coming for qt
coming for qt

Reputation: 39

ESP32 can't connect to iPhone Personal Hotspot

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

Answers (6)

nomasmo
nomasmo

Reputation: 11

Changing my phone's name to remove the apostrophe and enabling "Maximize Compatibility" worked for me!

Upvotes: 1

Waged
Waged

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

BaldYak
BaldYak

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

narced133
narced133

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

user18282217
user18282217

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

greycatbug
greycatbug

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:

  • Make sure that you are using the 2.4GHz hotspot and NOT the 5GHz. If you have a iPhone 12, which now supports 5GHz hotspot, disable 5GHz by going to Settings -> Personal Hotspot -> enable(!) "Maximize compatibility"
  • Try to connect with an other wifi (in the 2.4GHz range)
  • (sounds stupid but): did you try to change the SSID and PW on your iPhone? Are you sure that your "ssid" and "password"-variable are both correct (no spelling mistakes)? For testing purposes you could even try to exclude special characters and only use letters and numbers.
  • If all fails it might be a HW issue. Did you try to use a different ESP32?

Upvotes: 5

Related Questions