by default, the Raspberry Pi's network management system (wpa_supplicant
or NetworkManager
, depending on your setup) will automatically attempt to connect to known Wi-Fi networks during boot. If you’ve configured known networks in the wpa_supplicant.conf
file or using NetworkManager or raspi-config
, the Pi will try to connect to these networks without requiring additional scanning logic in a script.
The key idea here is to detect whether the Pi successfully connected to any network and, if not, start the hotspot. This simplifies the script, as you don't need to handle Wi-Fi scanning yourself—just check the connection status.
This script assumes the Raspberry Pi will attempt to connect to known networks on its own. It checks if the Pi is connected to a network, and if not, starts the hotspot.