README.md in Simplified Chinese in Github
README.md in Simplified Chinese faster link in China
Python script to control the MagPi Rain Detector project. See raspberypi.org/magpi issue #74 for more details.
Make sure gpiozero is installed.
sudo apt install python3-gpiozero
cd
git clone https://github.com/mrpjevans/rainbot.git
mkdir ~/rainbot
cd rainbot
nano rainbot.py
Now cut and paste (or manually enter) the code.
cd ~/rainbot
python3 rainbot.py
Create the following file as a superuser:
sudo nano /lib/systemd/system/rainbot.service
Add in the following text:
[Unit]
Description=Rainbot
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/rainbot/rainbot.py
[Install]
WantedBy=multi-user.target
Ctrl+X to save and quit out of nano. Now issue the following commands:
sudo chmod 644 /lib/systemd/system/rainbot.service
sudo systemctl enable rainbot.service
sudo systemctl daemon-reload
The script will now start in the background on reboot.