1. Configure SSH server
sudo systemctl enable ssh
sudo systemctl start ssh2. Setup POWER BUTTON
The GPIO3 and GND is used for POWER button, which is pin5 and pin6.
#!/usr/bin/env python
import RPi.GPIO as GPIO
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)
subprocess.call(['shutdown', '-h', 'now'], shell=False)Next make this script run on boot
sudo mv power.py /usr/local/bin/
sudo chmod +x /usr/local/bin/power.pyCreate another script to start/stop the script power.sh :
sudo vi power.sh
#! /bin/sh
### BEGIN INIT INFO
# Provides: power.py
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# If you want a command to always run, put it here
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting power.py"
/usr/local/bin/power.py &
;;
stop)
echo "Stopping power.py"
pkill -f /usr/local/bin/power.py
;;
*)
echo "Usage: /etc/init.d/power.sh {start|stop}"
exit 1
;;
esac
exit 0Also make it executable. Place it in /etc/init.d
sudo mv power.sh /etc/init.d/
sudo chmod +x /etc/init.d/power.shNow register script to run on boot
sudo update-rc.d power.sh defaultsStart the script
sudo /etc/init.d/power.sh start# This if information is taken from https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi?utm_source=youtube&utm_medium=referral&utm_campaign=power-button-video&utm_content=description
3. WIFI configuration
As a regulatory Raspberry OS requires to set country for wifi utilization, thus we need to set it up:
sudo raspi-config
follow up and choose "US america" for example. Then create PSK(PreSharedKey) from SSID and PASSWORD by running following command:
sudo su
wpa_passphrase "MyWIFI" "MyPASSWord" >> /etc/wpa_supplicant/wpa_supplicant.conf
The output should be like:
network={
ssid="MyWIFI"
#psk="MYPASSWord"
psk=6ffa0771c5e58c89dfceaf58a7370e569579a156f8b411c7e81039cd7249982f
}
Lastly run :
wpa_cli -i wlan0 reconfigure
If you have multiple choice of WIFI, like home and school wifi, then config can be as follows:
network={
ssid="HomeOneSSID"
psk="passwordOne"
priority=1
id_str="homeOne"
}
network={
ssid="HomeTwoSSID"
psk="passwordTwo"
priority=2
id_str="homeTwo"
}

Comments
Post a Comment