avaldebe / RpiHWmonitor

Raspberry Pi hardware monitoring display

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System Info Display

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.

Testing on emulated hardware

Test/modify the layout and system calls on a full Linux machine. The information is displayed on a small x-window for 15 seconds.

Installation for python3

luma.emulator

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

Display when script is changed

.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

SSD1306 on a Raspberry Pi

After .sys_info.py is called, the display will be updated once a minute.

Installation for python3

luma.olded

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

Start after boot

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

Run as a cronjob

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.

Run as a service

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.

About

Raspberry Pi hardware monitoring display

License:MIT License


Languages

Language:Python 100.0%