Skip to content

cololaborde/raspberry-I2C-LCD-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry Pi I2C LCD Logger

This repository provides a utility for logging useful information from a Raspberry Pi onto an I2C LCD screen. The utility utilizes a Python driver for the I2C LCD, simplifying the process of interfacing with the LCD display.

Contents

  • lcd_driver.py: This file contains the Python class lcd which provides methods for controlling the LCD display via I2C communication.
  • log-data.py: An example usage of the lcd class. This script continuously displays the Raspberry Pi's IP address and CPU temperature on the connected LCD screen.

Schema

Alt text of the image

Requirements

  • Python 3.x
  • smbus Python library (usually pre-installed on Raspberry Pi OS)
  • I2C_LCD_driver.py (for the log_data.py example)

Installation

  • Ensure your Raspberry Pi has the I2C interface enabled.
  • Clone this repository to your Raspberry Pi:
git clone git@github.com:cololaborde/raspberry-I2C-LCD-logger.git

Usage

  1. Connect your I2C LCD to the Raspberry Pi following the previous schema.
  2. Import the lcd class from lcd_driver.py into your Python script.
  3. Initialize the lcd object.
  4. Use the provided methods to control the LCD display.

Driver example usage:

from time import sleep
from lcd_driver import lcd

mylcd = lcd()

while True:
    # Get IP address
    # (Replace this with your method of obtaining the IP address)
    ip = "192.168.1.100"

    # Get CPU temperature
    # (Replace this with your method of obtaining the CPU temperature)
    temp = "Temp: 45C"

    # Display IP address and CPU temperature on LCD
    mylcd.lcd_display_string(ip, 1)
    mylcd.lcd_display_string(temp, 2)

    sleep(5)  # Update every 5 seconds

Auto-starting the Script

  1. Create a new systemd service file:
sudo nano /etc/systemd/system/lcd_display.service
  1. Add the following contents to the file:
[Unit]
Description=LCD Display Service
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python3 /path/to/log_data.py

[Install]
WantedBy=multi-user.target

Replace /path/to/log_data.py with the actual path to your log_data.py script.

  1. Save the file and exit the editor.
  2. Reload systemd to read the new service file:
sudo systemctl daemon-reload
  1. Enable the service to start on boot:
sudo systemctl enable lcd_display.service

Credits

  • Original code for the I2C interface and LCD control was compiled, modified, and made available by Denis Pleic under the GNU General Public License.
  • Example usage script (log_data.py) utilizes the lcd class provided in this repository along with some system commands to display IP address and CPU temperature.

License

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

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages