Displaying Pi Output on an LCD

A few weeks ago, I shared an article about leveraging the Meraki API and a Raspberry Pi to create a Dummy Light for My Network. Today’s article expands on this slightly by adding a 16×2 LCD Display for additional output flexibility. For the sake of demonstration, we will continue to use the Meraki API as the source of what will be displayed. An example of what I have built is shown immediately below in this short video.


To accomplish this, I added the HD44780 to my Raspberry Pi (Pi 2 Model B) using the following pinout.

#connect LCD Pin 1 (VSS) to Ground
#connect LCD Pin 2 (VDD) to 5v rail
#connect LCD Pin 3 (VO) to potentiometer
#connect LCD Pin 4 (RS) to 37
#connect LCD Pin 5 (RW) to Ground
#connect LCD Pin 6 (E) to 35
#connect LCD Pin 12
#connect LCD Pin 13
#connect LCD Pin 14
#connect LCD Pin 15
#connect LCD andode (a) to 5v rail (Phy Pin 2)  with resistance
#connect LCD cathode (k) to Ground Rail (Phy Pin 6)
#connect potentiometer to 5v and ground rails

Next, I wrote the following Python Script.

import requests
import json
import RPi.GPIO as GPIO
import time
import datetime
import Adafruit_CharLCD as LCD

#define the connections to the LCD
lcd_rs = 26 #GPIO 25 - Phy Pin 37
lcd_en = 19 #GPIO 24 - Phy Pin 35
lcd_d4 = 13 #GPIO 23 - Phy Pin 33
lcd_d5 = 16 #GPIO 27 - Phy Pin 36
lcd_d6 = 20 #GPIO 28 - Phy Pin 38
lcd_d7 = 6  #GPIO 22 - Phy Pin 31
lcd_backlight = 2

# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows = 2

#user definable variables 

url = "https://dashboard.meraki.com/api/v0/networks/" + mynetwork + "/devices/" + mydevice + "/performance"

headers = {
    'x-cisco-meraki-api-key': mydashkey,
    'content-type': "application/json",
    'cache-control': "no-cache",

lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7, lcd_columns, lcd_rows, lcd_backl$
lcd.message(' Connecting to \n   Meraki...   ')

response = requests.request("GET", url, headers=headers)
jsondata = response.json()
score = jsondata['perfScore']
currtime = datetime.datetime.now()

#capture a log
with open(logfile, "a") as myfile:
    myfile.write("Dashboard Score is " + str(score) + " at " + str(currtime) + "\n")
print("Dashboard Score is " + str(score) + " at " + str(currtime) + "\n")

#clear the LCD then print Perfscore
lcd.message('Perfscore is ' + str(score) + '\n 100 Is Worst ')

#clear LCD and notify user that will check again later
lcd.message('Will Check Again\n  Momentarily')
lcd.message(' Going to Sleep\n******bye*******')

Finally, I scheduled this to run every three minutes via cron.


Similar to my previous example, I’m not sure how useful this is. However, there is something empowering about being able to build and develop things that can interact with the cloud and physical world. There’s an enormous amount of flexibility and power to be realized as developers start messing around with the GPIO and the compute capabilities of these small computers.

Disclaimer: This article includes the independent thoughts, opinions, commentary or technical detail of Paul Stewart. This may or may does not reflect the position of past, present or future employers.

About Paul Stewart, CCIE 26009 (Security)

Paul is a Network and Security Engineer, Trainer and Blogger who enjoys understanding how things really work. With over 15 years of experience in the technology industry, Paul has helped many organizations build, maintain and secure their networks and systems.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply