When you move a Raspberry Pi between wifi networks and you want it to behave like an appliance, one way to set the wifi network easily as a user rather than a developer is to have it create an access point itself that you can connect to with a phone or laptop, enter the wifi information in a browser, and then reconnect to the proper network. Balena have a video explaining the idea.
Andrew Nicolaou has written things to do this periodically as part of Radiodan. His most recent suggestion was to try Resin (now Balena)’s wifi-connect. Since Andrew last tried, there’s a bash script from Balena to install it as well as a Docker file, so it’s super easy with just a few tiny pieces missing. This is what I did to get it working:
Provision an SD card with Stretch e.g. using Etcher or manually
Enable ssh e.g. by
Share your network with the pi via ethernet, ssh in and enable wifi by setting your country:
then Localisation Options -> Set wifi country.
bash <(curl -L https://github.com/balena-io/wifi-connect/raw/master/scripts/raspbian-install.sh)
Add their bash script
curl https://raw.githubusercontent.com/balena-io/wifi-connect/master/scripts/start.sh > start-wifi-connect.sh
Add a systemd script to start it on boot.
sudo nano /lib/systemd/system/wifi-connect-start.service
[Unit] Description=Balena wifi connect service After=NetworkManager.service [Service] Type=simple ExecStart=/home/pi/start-wifi-connect.sh Restart=on-failure StandardOutput=syslog SyslogIdentifier=wifi-connect Type=idle User=root [Install] WantedBy=multi-user.target
Enable the systemd service
sudo systemctl enable wifi-connect-start.service
Reboot the pi
and a wifi network should come up called “Wifi Connect”. Connect to it, add in your details into the captive portal, and wait. The portal will go away and then you should be able to ping your pi over the wifi: