Skip to content

souvikroyc/oled_project

Repository files navigation

OLED Stats Display for Raspberry Pi

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.

Features

  • 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.

Hardware Requirements

  • 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

Software Requirements

  • Python 3 (already included with Raspberry Pi OS)
  • Git for cloning the repository
  • I2C-tools for detecting the OLED display

Installation

1. Enable I2C on Your Raspberry Pi 5

Open the Raspberry Pi configuration tool:

sudo raspi-config

Navigate to Interfacing Options and enable I2C.

2. Install Git (if using Lite OS)

If you are using Raspberry Pi OS Lite, you need to install Git:

sudo apt-get update sudo apt-get install -y git

3. Download Repository from GitHub

Clone the repository and navigate to the project directory:

git clone https://github.com/souvikroyc/oled_project.git cd oled_project

4. Execute the Installation Script

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

5. Reboot (if necessary)

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).

5.2 Reload systemd and Start the Service

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

6. OpenWeatherMap API key setup:

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.

6.1 Generate an API Key

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.

Troubleshooting

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).

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.

Acknowledgements

This project uses the luma.oled library for handling the OLED display and psutil for system stats.

About

Repository for OLED project files including fonts and scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published