This project displays system stats (IP address, CPU usage, RAM usage, temperature, and storage usage) on a 0.96-inch OLED screen connected to a Raspberry Pi. The display is driven by the luma.oled library, which is compatible with the Raspberry Pi 5.
- IP Address: Displays the current IP address of the Raspberry Pi.
- CPU Usage: Shows the CPU usage percentage.
- RAM Usage: Displays the current RAM usage along with the percentage.
- Temperature: Displays the CPU temperature in Celsius.
- Storage Usage: Shows the total and used storage with the usage percentage.
- Raspberry Pi 5 with Raspberry Pi OS 64-bit Lite installed
- 0.96-inch OLED Display (128x64 resolution, with top line yellow and remaining blue text)
- I2C Interface enabled on the Raspberry Pi
- Python 3 (already included with Raspberry Pi OS)
- Git for cloning the repository
- I2C-tools for detecting the OLED display
Open the Raspberry Pi configuration tool:
sudo raspi-config
Navigate to Interfacing Options and enable I2C.
If you are using Raspberry Pi OS Lite, you need to install Git:
sudo apt-get update
sudo apt-get install -y git
Clone the repository and navigate to the project directory:
git clone https://github.com/souvikroyc/oled_project.git
cd oled_project
Convert line endings of the install.sh script to Unix format and make it executable:
sudo apt-get install -y dos2unix
dos2unix install.sh
chmod +x install.sh
Run the installation script:
./install.sh
After the script completes successfully, your Raspberry Pi should start displaying the stats on the OLED screen. If not, try rebooting:
sudo reboot
5.1 If the display does not show any text, means the systemd need to be setup manually, you can create it:
cd oled_project
sudo nano /etc/systemd/system/oled_stats.service
Add the following content:
[Unit]
Description=OLED Stats Service
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/oled_project/oled_stats2.py
WorkingDirectory=/home/pi/oled_project
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
Note: Replace pi with the appropriate username if it is different. Save and exit the editor (Ctrl + X, then Y, and Enter).
a) Reload systemd to recognize the new service file:
sudo systemctl daemon-reload
b) Enable and start the service:
sudo systemctl enable oled_stats.service
sudo systemctl start oled_stats.service
c) Check the status of the service:
sudo systemctl status oled_stats.service
This is optional if you are interested to run oled_stats3.py code. Remember you must modify step 5.1 at line number 8 with the respective python file name.
The user needs to edit the config.py file and provide their OpenWeatherMap API key and city name:
cd ./oled_project
sudo nano config.py
update the respective informations as mentioned.
In your OpenWeatherMap account dashboard, generate an API key. This key is required for authentication when you send requests to the OpenWeatherMap servers. The free tier typically provides enough calls (e.g., 60 requests/min) for basic applications, but you can upgrade if needed.
ModuleNotFoundError: No module named 'psutil': Install psutil using
pip3 install psutil
ModuleNotFoundError: No module named 'luma': Install luma.oled using
pip3 install luma.oled
No output on OLED display: Ensure the I2C interface is enabled and that the OLED display is correctly wired and detected (i2cdetect -y 1).