Page 1 of 1

ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)

Posted: Tue Jan 10, 2017 1:17 am
by andrew_p
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

Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)

Posted: Tue Jan 10, 2017 1:36 am
by kolban
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.

Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)

Posted: Sat Jun 17, 2017 11:45 am
by MitchSF
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)

Posted: Tue Jul 04, 2017 2:29 pm
by Alterane
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:

Code: Select all

strcpy ((char *)wifi.sta.ssid, "SSID");
work but when a use :

Code: Select all

//myvar is a string fresh malloc and extract from nvs
strcpy ((char *)wifi.sta.ssid, myvar);
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 ?

Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)

Posted: Wed Jul 05, 2017 10:37 am
by preetam
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

Re: ESP32 as an Access Point with the ability to store WiFi credentials (and other configurational data)

Posted: Wed Jul 05, 2017 5:59 pm
by Alterane
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..?!