Connecting ESP32 to Hotspot Raspberry pi bookworm

Hi there,

I previously successfully connected ESP32 (WEMOS LOLIN32 lite) to my home WiFi (router) and a hotspot (2.4GHz) created from Ubuntu. But not able to connect it to my hotspot on Raspberry pi 4 (bookworm).
Hostpot is created with:

nmcli connection add type wifi ifname wlan0 con-name "$AP_SSID" autoconnect no ssid "$AP_SSID"
nmcli connection modify "$AP_SSID" 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared
nmcli connection modify "$AP_SSID" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "$AP_PASSWORD"

# Set static IP if given
if [ -n "$AP_IP" ]; then
    nmcli connection modify "$AP_SSID" ipv4.addresses "$AP_IP/24" ipv4.method shared
fi

nmcli connection modify "$AP_SSID" connection.autoconnect yes
nmcli connection modify "$AP_SSID" connection.autoconnect-priority 10

On Arduino:

void setupWiFi() {
  int retry = 0;

  // No change when using this
  // IPAddress local_IP(192, 168, 50, 42);
  // IPAddress gateway(192, 168, 50, 1);
  // IPAddress subnet(255, 255, 255, 0);

  // if (!WiFi.config(local_IP, gateway, subnet)) {
  //   Serial.println("[WiFi] ❌ Failed to configure static IP");
  // }

  WiFi.begin(ssid, password);
  Serial.print("[WiFi] Connecting");

  while (WiFi.status() != WL_CONNECTED && retry < 20) {
    delay(500);
    Serial.print(".");
    retry++;
  }

  if (WiFi.status() == WL_CONNECTED) {
    Serial.println(" ✅ OK");
    Serial.printf("[WiFi] Connected! MAC: %s, IP: %s\n", 
      WiFi.macAddress().c_str(), 
      WiFi.localIP().toString().c_str());
  } else {
    Serial.println(" ❌ Failed to connect");
    // Blink error LED forever
    while (true) {
      digitalWrite(LED_PIN, LOW); delay(500);
      digitalWrite(LED_PIN, HIGH); delay(500);
      retry++;
      if(retry > 60){// 60 seconds passed
        Serial.println("[WiFi] Retry limit reached. Restarting...");
        ESP.restart();
      }
    }
  }
}
void setup() {
  Serial.begin(115200);
  delay(5000);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH); // turn OFF for Lolin32 lite
  setupWiFi();
}

I never get connected with ESP32, but my computer and my Android phone are both able to connect to the hotspot on my Pi.

Any idea of solution?
Thanks.

Ok i found, seam like solved by this:

WiFi.setMinSecurity(WIFI_AUTH_WPA_PSK); 
WiFi.begin(ssid, password);
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.