In the IoT context there are many devices build based on micro controllers like esp or stm32. If it comes to integration into your wifi at home all these devices offer its own access point where one can connect to configure everything, mostly include the “real” wifi and your done. Very easy. Also amazons echo devices work like that.
Why not configure a raspberry pi based “device” the same way?
When you ask google about “access point raspberry pi” it guides you in the right direction but more or less every article out there is about turning a pi into a routing access point that does routing and nat and all. We don’t need all that.
We basically need 3 things:
- An access point: we use hostapd for that.
- A very tiny dhcp server that hands out an ip. we use udhcpd.
- A tiny http server that offers some configuration page. at least for configuring wifi itself. we use lighttpd and s small cgi script.
As soon as we have a working wifi we stop the three above.
So automating this works simply like this:
- Some time after boot, with some script check if then wlan0 interface has a valid ip address
- if not start the 3 services mentioned above to gather config.
- with user input write a wpa_supplicant.conf to /etc/wpa_supplicant and reboot.
To be continued …
9 Antworten auf Configure Wifi on a headless Raspberry Pi with your own access point