Introduction: LCD IP/ Clock

This instructable will show you how to build an LCD display that shows you the current time and the IP/ host of the RPi.


  1. Raspberry Pi
  2. SD card with raspbian
  3. WiFi Connection
  4. Geek PI IIC/I2C 2004 2 Arduino UNO Raspberry Pi LCD display (20x4)
  5. 4x Female to female jumper wires
  6. Keyboard and mouse

Step 1: Step 1: Wiring

  1. Connect the ground pin of the LCD to a ground pin on the RPi
  2. Connect the VCC pin of the LCD to a 5v pin on the RPi
  3. Connect the SDA pin of the LCD to the SDA 2 pin on the RPi
  4. Connect the SCL pin of the LCD to the SCL 3 pin on the RPi

As shown in the pictures

Step 2: Step 2: Cloning Git Repo

  1. Boot the RPI
  2. Open terminal
  3. Type the following
sudo apt-get update
sudo apt-get upgrade<br>
git clone</a>
sudo reboot

Step 3: Step 3: Installing Python3


Just input the following lines of code into the terminal

sudo apt-get install python3
sudo apt-get install python3-pip
sudo reboot
sudo apt-get update
sudo apt-get full-upgrade

Step 4: Step 4: Testing Code

So you now have everything installed ready to run. So go to the place where the files you cloned are and type:


This program shows that the LCD works. Now you can run the next demo:


This program runs a basic clock setup. The time should be displayed on the screen and changes when the time changes.

Step 5: Step 5: the Code

This step will show you how to code the clock and IP python program.

The code starts by importing all the relevant libraries.

import lcddriver
import time
import datetime
import socket

display = lcd.driver.lcd()

Now you can get the IP and hostname:

testIP = ""

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

s.connect((testIP, 0))

ipaddr = s.getsockname()[0]

host = socket.gethostname()

This code will get the IP from the RPi and set it as "ipaddr".

Now you can get the text to print:

text = str(input("Input Text:"))

This code gets some text from the user (you will need a keyboard and display for this). Next you can output everything to the display:

print("Writing to display") display.lcd_display_string(text, 1) # Write line of text to first line of display display.lcd_display_string(ipaddr, 3) display.lcd_display_string(host, 4) while True: display.lcd_display_string(str(, 2) # Write just the time to the display # Program then loops with no delay (Can be added with a time.sleep)

except KeyboardInterrupt: # If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup
print("Cleaning up!") display.lcd_clear()

This part of the code outputs all the variables to the LCD Display and refreshes the time as it goes up.