Display basic system information on a OLED display (using luma.oled), or in a x-window (using luma.emulator).
This is a re-implementation of "Raspberry Pi hardware monitoring display with icons" by plukas and "SSD1306 with Python" by Peter Scargill.
Based on the sys_info example.
Test/modify the layout and system calls on a full Linux machine. The information is displayed on a small x-window for 15 seconds.
sudo apt install python3-dev python3-pip build-essential
sudo apt install libsdl-dev libportmidi-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev libsdl-image1.2-dev
sudo pip3 install --upgrade luma.emulator
.sys_info.py
will show the emulated display only for 15 seconds.
The following commands will execute the script every time the file is saved
while inotifywait -qqre modify ./sys_info.py; do
./sys_info.py
done
After .sys_info.py
is called, the display will be updated once a minute.
sudo apt install python3-dev python3-pip libfreetype6-dev libjpeg-dev build-essential
sudo -H pip3 install --upgrade luma.oled
Additional dependencies on Raspbian Stretch Lite
sudo apt install libopenjp2-7 libtiff5
sudo -H pip3 install psutil
There are different options to start a job after boot, see here. This are the ones I have tried/plan to try out.
- cronjob: easy to set-up, need to reboot to update the script
- service: harder to set-up, easy to start/stop
Add the following lines to your crontab (crontab -e
)
@reboot bash -lc $HOME/RpiHWmonitor/sys_info.py &
The bash -l
is needed to get the right $PATH
for iwconfig
,
which in turn is needed for the wifi signal strength.
The systemd
service file (RpiHWmonitor.service)
defines a new service called RpiHWmonitor,
which is to be launched once the multi-user environment is available.
# copy the service file
sudo cp RpiHWmonitor.service /lib/systemd/system/
# set the required permissions
sudo chmod 644 /lib/systemd/system/RpiHWmonitor.service
# enhable new service
sudo systemctl daemon-reload
# start/stop/reload service
sudo systemctl start RpiHWmonitor
#sudo systemctl stop RpiHWmonitor
sudo systemctl reload-or-restart RpiHWmonitor
# check service status
systemctl status RpiHWmonitor
# start after reboot
sudo systemctl enable RpiHWmonitor # start after reboot
#sudo systemctl dishable RpiHWmonitor # don't start
sudo reboot
For more info about systemctl
usage, see this tutorial,
and this article about auto restart crashed services.