This is a simple web-based interface that allows you to connect your Raspberry Pi to a Wi-Fi network. It checks if the Pi is connected to a network and if not, shows a portal to select a Wi-Fi network and enter the password.
Make sure you have the following installed on your Raspberry Pi:
- Python 3
pip3
(Python package manager)
- Install required dependencies:
sudo apt update
sudo apt install python3-pip python3-dev wireless-tools
- Install Python libraries:
sudo pip3 install flask wifi
-
Clone or download the repository to your Raspberry Pi.
-
Navigate to the project folder and run the application:
sudo python3 app.py
The web portal will be available at http://your-pi-ip:80
To ensure the application starts automatically on boot using systemd, follow these steps:
-
Create a new systemd service file:
sudo nano /etc/systemd/system/wifi-setup.service
-
Add the following content to the file:
[Unit]
Description=WiFi Setup Portal
After=network.target
[Service]
ExecStart=/usr/bin/python3 /path/to/your/project/app.py
WorkingDirectory=/path/to/your/project
User=pi
Group=pi
Restart=always
[Install]
WantedBy=multi-user.target
Make sure to replace /path/to/your/project/ with the actual path to your project directory.
- Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable wifi-setup.service
sudo systemctl start wifi-setup.service
- Check the status of the service:
sudo systemctl status wifi-setup.service
Your application will now automatically start on boot and be available on port 80.
The portal will be available on port 80, and you can access it via any device connected to the Raspberry Pi's network. If the Pi is already connected to a network, it will display a "Connected" message.