HI All,
I have 2 ESP32 CAM AI thinkers working, one in AP mode and one in STA mode, both on same SSID. I can view both on individual IP addresses just fine.
On the AP board, I'm trying to flash the little red built-in LED GPIO33, when the STA one is connected.
void loop() {
delay(500);
uint8_t clientCount = WiFi.softAPgetStationNum();
if (clientCount == 0) {
LED_BLINKER = 0; // STOP LED blink
digitalWrite(LED_BUILTIN, LOW); // built-in LED ON (LED has pull-up)
} else {
LED_BLINKER = 1; // make LED blink
}
Serial.println(WiFi.softAPgetStationNum());
// =======================================================
// ALL GOOD ???? FLASH BUILT IN LED GPIO33 ???
// =======================================================
if (LED_BLINKER == 1) { // WiFi OK ?
if (millis() - LED_Flasher >= 500) {
digitalWrite(LED_BUILTIN, HIGH); // built-in LED OFF (LED has pull-up)
}
if (millis() - LED_Flasher >= 1000) {
digitalWrite(LED_BUILTIN, LOW); // built-in LED ON (LED has pull-up)
LED_Flasher = millis();
}
}
}
So, switch on the AP board and GPIO33 LED comes ON and WiFi.softAPgetStationNum() is 0 on the serial monitor.
Then switch on the STA board and when it connects, GPIO33 LED starts flashing ok and WiFi.softAPgetStationNum() shows as 1 on the serial monitor.
However, when I switch the STA board OFF, WiFi.softAPgetStationNum() stays as 1, doesn't go to 0. This leaves the LED still flashing !!!
Any ideas ???
Thank you
Trevor

