-
1Libraries Installation
Open terminal of Raspbain and install libraries (BCM2835, wiringPi, Python) as below
#Installing wiringPi libraries, sudo apt-get install wiringpi #For Pi 4, you need to update it cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v #Installing python libraries #python2 sudo apt-get update sudo apt-get install python-pip sudo apt-get install python-pil sudo apt-get install python-numpy sudo pip install RPi.GPIO sudo pip install spidev #python3 sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil sudo apt-get install python3-numpy sudo pip3 install RPi.GPIO sudo pip3 install spidev
Get the script from the github repo
-
2Run the script as a service on boot
To run the script on startup, run the following commandsudo vim /lib/systemd/system/btc_stats.service
Add this to the file:
[Unit] Description=BTC Stats After=multi-user.target [Service] ExecStart=/usr/bin/python3 /home/pi/path-to-script/stats.py [Install] WantedBy=multi-user.target
Make sure you change the path to the actual path to your script and also make sure that the python 3 file is pointing to the correct location of python3
Now the unit file has been defined we can tell systemd to start it during the boot sequence :
sudo systemctl daemon-reload sudo systemctl enable btc_stats.service
Reboot the Pi and your custom service should run:
sudo reboot
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.