Page 1 of 3
ESP32 User Configurable Network Details
Posted: Thu Sep 02, 2021 4:15 pm
by BenR
When creating a product using an
ESP32 device it is important that it can connect to the network of the person buying the product.
This is complicated as the
ESP32 requires that the network SSID and password be defined by the user and this requires a means of getting the data into the
ESP32 device.
Luckily as the
ESP32 features the ability to host it's own network we can use this to create a simple web interface where the user can enter their network details.
Here I've created a simple example that uses the Webserver component to allow a user to connect the
ESP32 to their own network and store the settings into none volatile EE memory.
On startup the firmware checks the EE memory and attempts to connect to the stored network. If successful then the program continues and WIFI communications can occur on the user's network.
If the connection was not successful then the ESP creates it's own open network called FlowcodeWifi. This SSID name can be reconfigured as required and even made so a specific password has to be entered to allow access.

- WIFICon1.jpg (14.43 KiB) Viewed 10200 times
If you connect to this network and then visit the URL 192.168.4.1 then you will be presented with a configuration page.

- WIFICon2.jpg (19.24 KiB) Viewed 10200 times
Upon filling out the details in the page and clicking submit the confirmation page below will be shown, the entered details will be stored and the
ESP32 will attempt to connect to the network. If successful then the FlowcodeWifi network will dissapear and the ESP will continue with the program as before.

- WIFICon3.jpg (17.41 KiB) Viewed 10200 times
If not successful then the FlowcodeWifi network will eventually reappear allowing you another attempt at connection.
Please note for this project to compile and work you will need the latest component updates via the library update system.
Hopefully this is useful and easy to follow. Let me know if there are any questions or problems encountered.
Re: ESP32 User Configurable Network Details
Posted: Thu Sep 02, 2021 4:37 pm
by medelec35
Thanks, Ben.
That is a brilliant idea!
I know, what I will be trying out!

Re: ESP32 User Configurable Network Details
Posted: Fri Sep 03, 2021 2:57 pm
by stefan.erni
Hi Ben
Nice software.
I tried on my tablet with chrome
I can connect to the webserver and fill my network and pw. When I press register there is a message: page can not be reached.
So I get a notebook with windows and there it's working. I can press register and it confirm.
But how can I connect now to the ESP32 (maybe it's connected to my network)
regards
Stefan
Re: ESP32 User Configurable Network Details
Posted: Fri Sep 03, 2021 3:32 pm
by BenR
Hi Stefan,
Odd about the tablet, I'll see if I can replicate that here.
Yes once the ESP is on your network you need to find the local IP address of the ESP to do further communications, you could show the IP address on a display but this is not ideal for most situations. An alternate method is to do a scan of your network by logging onto your your router or using a mobile phone app such as Fing to scan your network and find the ESP device.
The next project I want to do is a TCP broadcast which hopefully should allow us to find and communicate with specific devices on a local network with ease.
Re: ESP32 User Configurable Network Details
Posted: Fri Sep 03, 2021 3:53 pm
by stefan.erni
Hi Ben
I used a Android-Tablet with Chrome......
TCP broadcast can you do this (found) with the Appdevelopper?
For a test I loadet a complet new program in the
ESP32 and read the EEprom and send it to the USB-C.
I received realy my password.....
I will use your webserver for many other parameters soon.
And I saw that the
ESP32 has a RTC. So there will be a way to set time and date by wlan ...
regards
Stefan

- wifi2021-09-03_16-30-46.png (9.82 KiB) Viewed 10157 times
Re: ESP32 User Configurable Network Details
Posted: Fri Sep 03, 2021 4:05 pm
by BenR
TCP broadcast can you do this (found) with the Appdevelopper?
I'm not 100% at the moment but yes it looks like it should be possible.
As for the RTC I'll get it on the list. I think once your connected to a network that has internet syncing up the RTC with a time server and getting the time/date should be simple.
Re: ESP32 User Configurable Network Details
Posted: Tue Sep 07, 2021 11:25 pm
by BenR
RTC and SNTP support for the
ESP32 has now been done and is working well.

- Log.jpg (34.12 KiB) Viewed 10099 times
I'll post the component to the update system tomorrow along with an example.
Re: ESP32 User Configurable Network Details
Posted: Wed Sep 08, 2021 9:27 am
by stefan.erni
Hi Ben
Great, I would like to use it.
thanks a lot.
What about a component for the ESP32 poweroption?
few comand to set to one of the powermode and few option to "wakeup"
regards
• Active mode
• Modem-sleep mode
• Light-sleep mode
• Deep-sleep mode
• Hibernatation mode
from esp32_technical_reference_manual_en.pdf
31.3.9 Predefined Power Modes
In ESP32, we recommend that you always use the predefined power modes first, before trying to tune each power
control signal. The predefined power modes should cover most scenarios:
• Active mode
– The CPU is clocked at XTAL_DIV_N (40 MHz/26 MHz) or PLL (80 MHz/160 MHz/240 MHz).
– The chip can receive, transmit, or listen.
• Modem-sleep mode
– The CPU is operational and the clock is configurable.
– The Wi-Fi/Bluetooth baseband is clock-gated or powered down. The radio is turned off.
– Current consumption: ∼30 mA with 80 MHz PLL.
– Current consumption: ∼3 mA with 2 MHz XTAL.
– Immediate wake-up.
• Light-sleep mode
– The internal 8 MHz oscillator, 40 MHz high-speed crystal, PLL, and radio are disabled.
– The clock in the digital core is gated. The CPUs are stalled.
– The ULP coprocessor and touch controller can be periodically triggered by monitor sensors.
– Current consumption: ∼ 800 μA.
– Wake-up latency: less than 1 ms.
• Deep-sleep mode
– The internal 8 MHz oscillator, 40 MHz high-speed crystal, PLL and radio are disabled.
– The digital core is powered down. The CPU context is lost.
– The supply voltage to the RTC core drops to 0.7V.
– 8 x 32 bits of data are kept in general-purpose retention registers.
– The RTC memory and fast RTC memory can be retained.
– Current consumption: ∼ 6.5 μA.
– Wake-up latency: less than 1 ms.
– Recommended for ultra-low-power infrequently-connected Wi-Fi/Bluetooth applications.
• Hibernatation mode
– The internal 8 MHz oscillator, 40 MHz high-speed crystal, PLL, and radio are disabled.
– The digital core is powered down. The CPU context is lost.
– The RTC peripheral domain is powered down.
– The supply voltage to the RTC core drops to 0.7V.
Re: ESP32 User Configurable Network Details
Posted: Wed Sep 08, 2021 10:06 am
by BenR
Hello Stefan,
Another great suggestion I'll get it on the list.
The component is now on the library update system and there is a simple example here.
The internal clock of the
ESP32 can drift a bit, worst case I believe a few hundred seconds over the course of a day so in the example I re-sync the internal clock with the time server once at the start of every hour.
I beleive you can add a 32.768KHz crystal to the
ESP32 and enable it by editing the config file to improve the overall accuracy of the internal clock.
Re: ESP32 User Configurable Network Details
Posted: Wed Sep 08, 2021 2:36 pm
by stefan.erni
Hi Ben
Perfect working!
What I'm missing are some set command to set the TimeDate with Touchscreen, Bluetooth or USB
The RTC1 component (Real Time Clock Internal, DS1307, DS3231, DS3232) is supporting a lot of set command
but for me is a setcommand for all in one go also possible even without a separator like.
"yyyyMMddHHmmss"
regards
Stefan
The RTC1 component with a lot of set commands:

- rtc1_2021-09-08_15-19-16.png (14.95 KiB) Viewed 10077 times
Working perfect received string from the
ESP32 (set by wifi) and my computertime:

- RTC_2021-09-08_11-53-36.png (288.7 KiB) Viewed 10077 times