In order to connect to the WiFi network a proper configuration needs to be provided. This tutorial shows how to do this using the wpa_supplicant tool and the systemd service manager.
First, create the /etc/wpa_supplicant directory and the /etc/wpa_supplicant/wpa_supplicant-wlan0.conf file with the following configuration:
- sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
ssid="<NETWORK_SSID>"
psk="<NETWORK_PASSWORD>"
key_mgmt=WPA-PSK
proto=WPA2
pairwise=CCMP TKIP
group=CCMP TKIP
scan_ssid=1
}
The network in the example is protected with the WPA2 standard and requires a password. The <NETWORK_SSID> and <NETWORK_PASSWORD> fields need to be changed according to the existing network configuration.
Create the /etc/systemd/network/25-wlan.network file:
- sudo nano /etc/systemd/network/25-wlan.network
[Match]
Name=wlan0
[Network]
DHCP=ipv4
Enable the wpa_service for the wlan0 interface:
- sudo systemctl enable wpa_supplicant@wlan0.service
Restart the systemd-networkd and wpa_supplicant services:
- sudo systemctl restart systemd-networkd.service && sudo systemctl restart wpa_supplicant@wlan0.service
and check the interface status:
- ip a
The wireless network (wlan0) should now be enabled and configured after each system boot.
- sudo apt-get -y install python-rpi.gpio
- sudo systemctl enable pigpiod
- sudo nano /etc/init.d/pigpiod
#!/bin/bash
### BEGIN INIT INFO
# Provides: pigpiod
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start GPIO
# Description: Enable GPIO library for rapberry pi
### END INIT INFO
/usr/bin/pigpiod
exit 0
- sudo nano /etc/init.d/control
#!/bin/bash
### BEGIN INIT INFO
# Provides: control
# Required-Start: pigpiod
# Required-Stop: pigpiod
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start temprature monitoring at boot time
# Description: Enable environment logging
### END INIT INFO
case "$1" in
start)
echo "Starting script /usr/bin/control.py"
python /usr/bin/control.py > /dev/null &
;;
stop)
echo "Stopping script /usr/bin/control.py || pkill python"
pkill python &
;;
*)
echo "Usage: /etc/init.d/control {start|stop}"
exit 1
;;
esac
exit 0
- sudo chmod +x /etc/init.d/control
- sudo systemctl enable control
- ssh-keygen Add key to github account with repo, admin:public_key admin:something packages:delete permissions
- sudo ln -s /usr/bin/control.py $PWD/control.py
- sudo chmod +x /usr/bin/control.py
Read first lines of control.py to setup the database etc