This is my first post so I apologize if I'm missing all required info about my Arduino setup. I'm a little new to this type of development.
Arduino 1.8.9
ESP32 Dev Module on /dev/cu.SLAB_USBtoUART
Mac OSX High Sierra 10.13.
I'm using the AutoConnect by Hieromon Ikasama v1.1.3 library to create an access point (AP), but the SSID (network name) is not being broadcasted even with the simplest code example.
Why isn't "ESP-78e9" showing up in my network list on my MAC or iPhone?
⸮⸮⸮8Y8⸮
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[E][Preferences.cpp:38] begin(): nvs_open failed: NOT_FOUND
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:381] _eventCallback(): STA IP: 192.168.1.192, MASK: 255.255.255.0, GW: 192.168.1.1
WiFi connected: 192.168.1.192 on ESP-78e9
Full code sample below, written with the Arduino IDE
#include <WiFi.h>
#include <WebServer.h>
#include <AutoConnect.h>
WebServer Server;
AutoConnect Portal(Server);
AutoConnectConfig Config;
void rootPage() {
char content[] = "Hello, world";
Server.send(200, "text/plain", content);
}
void setup() {
Config.apid = "ESP-" + String((uint32_t)(ESP.getEfuseMac() >> 32), HEX);
Config.psk = "Password1";
Portal.config(Config);
delay(5000);
Serial.begin(9600);
Serial.println();
Server.on("/", rootPage);
if (Portal.begin()) {
// Serial.println("WiFi connected: " + WiFi.localIP().toString());
Serial.println("WiFi connected: " + WiFi.localIP().toString() + " on " + Config.apid);
}
}
void loop() {
Portal.handleClient();
}
I've tried looking into why "nvs_open failed: NOT_FOUND" is occurring as that feels like the next step, but can't find any information on how to fix it.
I've also tried this on two boards of the same model.
Any ideas?
** Update ** I've modified the code to include the following, but still no AP and captive portal.
https://hieromon.github.io/AutoConnect/advancedusage.html#on-demand-start-the-captive-portal
According to the link above, that SHOULD start a captive portal before attempting to connect to WiFi.
Config.autoRise = false;
Config.immediateStart = true;
Instead I get the debug text here:
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 14 - AP_STOP
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:337] _eventCallback(): Event: 2 - STA_START
Update 2
There may be a bug in the documentation. I changed "autoRise" to true and the SSID was broadcasted.
Config.autoRise = true;
Config.immediateStart = true;
1 Answer 1
It looks like your ESP32 is already successfully connecting to an access point as a STA (station) and does not start its own Access Point (AP). You probably have already previously configured an SSID and password and the ESP32 is successfully reusing those, so it will not start the Captive Portal (as its own AP).
You should force AutoConnect to start up the Captive Portal or to forget its pre-programmed SSID and password. This can be achieved by On-demand starting of the Captive Portal like described on this page. According to the documentation you should put the following lines in your code (I have not tested this myself):
Config.autoRise = true;
Config.immediateStart = true;
Portal.config(Config);
....
Portal.begin();
NOTE: The documentation actually states Config.autoRise = false but it seems this does not have the desired effect.
-
Thanks @StarCat . You'd think that would work according to the docs, but it doesn't. AP_STOP and then STA_START occurs :/ See update in my post.Will Lovett– Will Lovett2020年02月06日 18:40:14 +00:00Commented Feb 6, 2020 at 18:40
-
You might try to disable your regular Wifi temporarily and see if the portal comes up when the ESP cannot get a Wifi connection itself. What if you connect your browser to the IP address it shows in the serial output?StarCat– StarCat2020年02月06日 18:50:07 +00:00Commented Feb 6, 2020 at 18:50
-
Thanks for the tips. Looks like the autoRise = false is a bug and it should be autoRise = true. I'll mark yours as accepted, but that may fool people in the future.Will Lovett– Will Lovett2020年02月06日 19:09:40 +00:00Commented Feb 6, 2020 at 19:09
-
Thank you. I'll change it in my answer, but this comes from the documentation on the author's website.StarCat– StarCat2020年02月06日 19:10:33 +00:00Commented Feb 6, 2020 at 19:10