ESP32 provides a great API for managing WiFi connections and I'm looking for code example/snippets, which would allow to accomplish the following:
1. When ESP32 starts if verifies if there is any configurational data stored.
2. If there is NO configurational data, then it runs in a WiFi Access Point mode and serves HTML page, where a user can specify WiFi credentials and other configurational data in key-value pairs format (NVS?)
3. if there IS configurational data stored, then ESP32 runs in a standard WiFi mode (as a station) and performs common tasks using stored configurational data.
Do you guys have / know any code examples which can help? I did try access point example (thanks Neil!), it works fine, just need a bit more (how to serve HTML page and store data?).
Essentially I want to have something what ESP32-Duktape provides at the very first setup step (again, Neil!), but I want to have my custom HTML page with a custom configurational data, so ESP32 can use that data for common tasks (let's say I want to specify # of LEDs to blink or URL to perform HTTP request etc.)
- Andrew
ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)
Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)
Howdy Andrew,
Might this be a partial starting point?
https://github.com/nkolban/esp32-snippe ... g/bootwifi
It feels like the core bit you need might be an HTTP server. In C, my goto on that is the Mongoose project.
Might this be a partial starting point?
https://github.com/nkolban/esp32-snippe ... g/bootwifi
It feels like the core bit you need might be an HTTP server. In C, my goto on that is the Mongoose project.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)
I would LOVE to have a library that does this! I'm working on two projects that require configuration data to be saved, in addition to ssid and password. A bonus would be the ability to specify field types such as text, numeric, drop down box, radio button, and data validation with error messages. Maybe that's asking too much, but with the ESP32, MKR1000 and many other Internet connected products, I'm surprised that nothing like this exists yet. For sure, I can't do it myself.
Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)
Hi, i have manage to make a http server who do some part of what you want.
Now, the esp start with an AP not hidden with an SSID DEFAULT, and a server http with dhcp on 192.168.1.1.
The http server avec an page with a form, asking for ssid name for the next AP, ssid name for the STA to connect and password.
I receive an process the POST request store value on nvs, BUT..
The AP start well with the same code.
I cannot manage to start STA with (char *) i don't know why...
I use:
work but when a use :
That didn't work :'(...
I have check the string is perfect, right length and right data.
Can we start a wifi sta with mallocated ssid extract from nvs ?
Now, the esp start with an AP not hidden with an SSID DEFAULT, and a server http with dhcp on 192.168.1.1.
The http server avec an page with a form, asking for ssid name for the next AP, ssid name for the STA to connect and password.
I receive an process the POST request store value on nvs, BUT..
The AP start well with the same code.
I cannot manage to start STA with (char *) i don't know why...
I use:
Code: Select all
strcpy ((char *)wifi.sta.ssid, "SSID");
Code: Select all
//myvar is a string fresh malloc and extract from nvs
strcpy ((char *)wifi.sta.ssid, myvar);
I have check the string is perfect, right length and right data.
Can we start a wifi sta with mallocated ssid extract from nvs ?
Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)
Hi Andrew,
I assume you are storing in nvs using nvs_set_str (as a string) , in that please check whether the string is zero terminated.
Thank you
Paul
I assume you are storing in nvs using nvs_set_str (as a string) , in that please check whether the string is zero terminated.
Thank you
Paul
Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)
Thank you, but it worst than that...
I forgot the esp_wifi_connect().
Shame on me :/
But for sure if the string is store on a (const char *) in the code you don't need to use esp_wifi_connect(), after esp_wifi_start() the program connects itself ...
Weird..?!
I forgot the esp_wifi_connect().
Shame on me :/
But for sure if the string is store on a (const char *) in the code you don't need to use esp_wifi_connect(), after esp_wifi_start() the program connects itself ...
Weird..?!
Who is online
Users browsing this forum: No registered users and 70 guests