Having trouble connecting the ESP32 Thing Plus C to a server via iPhone hotspot

Trying to get “Hello, World!” printed on a server, so I can eventually send GPS coordinates. I’m using:
ZED-F9P → Sparkfun ESP32 Thing Plus C → iPhone personal hotspot → Python socket server.

Here’s the sketch I’m using on the ESP32:

#include <WiFi.h>

const char* ssid = "iPhone_name";
const char* password = "iPhone_personal_hotspot_password";

const char* server = "123.456.7.89";
const int port = 12345; // or whatever port your server is listening on

void setup() {
  // Set the WiFi mode to STA
  // Connect to the WiFi network
  Serial.println("Connecting to WiFi...");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("Connected to WiFi");

  // Connect to the server
  Serial.println("Connecting to server...");
  WiFiClient client;
  if (!client.connect(server, port)) {
    Serial.println("Connection failed!");
  Serial.println("Connected to server");

  // Send "Hello, World!" to the server
  Serial.println("Sending message...");
  client.println("Hello, World!");

  // Disconnect from the server
  Serial.println("Disconnecting from server...");
  Serial.println("Disconnected from server");

void loop() {
  // This sketch doesn't do anything in the main loop

The last thing it prints in the IDE serial monitor is:

“Connecting to server…”

I get nothing in the server when using the iPhone hotspot, but it works when using my normal home WiFi router. This is the code I use for the server:

import socket

# Create a socket to listen for incoming connections
server_socket = socket.socket()
server_socket.bind(("", 12345))

# Loop indefinitely to handle incoming connections
while True:
  # Accept an incoming connection
  client_socket, client_address = server_socket.accept()

  # Receive the message from the client
  message = client_socket.recv(1024)

  # Print the received message
  print("Received message:", message)

  # Close the client socket

Using the iPhone hotspot prints nothing. Using the home WiFi router gives:

b’Hello, World!\r\n’

Any ideas for how to get this working with the iPhone personal hotspot would be appreciated! Thanks :slight_smile:

Hi Jacob,

It sounds like you’ve isolated the problem well to something about how the iPhone is setup. Hopefully, it’s something as simple as the iPhone defaulting to 5GHz which the ESP32 doesn’t support.

I’m not sure what else you could try with the iPhone hotspot to make it pass the data through, ultimately hotspots aren’t routers so there will be some quirks to how they behave which can limit what works effortlessly with a proper router.

1 Like

For anyone else who comes across this thread looking for solutions:

Not sure exactly what changed part of my setup made it work, but I am successfully using an iPhone hotspot to send output from ESP32 Thing Plus to an AWS EC2 Amazon Linux instance, running a Python server. It seems that using an AWS EC2 allowed it to work. Might have been my firewall.

1 Like