100% found this document useful (1 vote)
176 views

LCD I2c

This document provides instructions for connecting an LCD screen to a Raspberry Pi using the I2C interface. It involves 5 steps: 1) Connecting the LCD to the Pi's I2C pins, 2) Enabling I2C on the Pi, 3) Installing I2C libraries, 4) Testing the hardware connection, and 5) Running a Python script to display text on the LCD. The instructions provide commands to run and changes to make to configuration files to properly set up I2C communication between the Pi and LCD screen.

Uploaded by

death914
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
176 views

LCD I2c

This document provides instructions for connecting an LCD screen to a Raspberry Pi using the I2C interface. It involves 5 steps: 1) Connecting the LCD to the Pi's I2C pins, 2) Enabling I2C on the Pi, 3) Installing I2C libraries, 4) Testing the hardware connection, and 5) Running a Python script to display text on the LCD. The instructions provide commands to run and changes to make to configuration files to properly set up I2C communication between the Pi and LCD screen.

Uploaded by

death914
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Drive i2c LCD Screen with Raspberry Pi

Caution: To make sure this project works properly, you should use a MicroSD
card with fresh-installed Raspbian OS.
Step 1: Circuit Connection Graph:

PiI2C Pin

GND(Pin 39 or Pin 9) GND


5V(Pin 2) VCC
SDA(Pin 3/GPIO 2) SDA
SCL(Pin 5/GPIO 3) SCL

Step 2: Enable i2c using raspi-config utility


In terminal, type the following command:
sudo raspi-config

Select Advanced Option -> I2C -> Enable I2C ->Finish


The Pi will reboot after you click the Finish Button

After rebooting the Pi, we need to modify the module's config file. Type
the following command in terminal:
sudo nano /etc/modules
Add following two lines in modules file if they do not exist:
i2c-bcm2708
i2c-dev
Then Type Ctrl X and Yes to save the file.

Step 3: Step 3 Install smbus and i2c python library


Type following command in terminal:
sudo apt-get update
sudo apt-get install -y python-smbus i2c-tools
sudo reboot

After rebooting the system, type the following command in order to check
software installation:
lsmod | grep i2c_
You should see i2c_bcm2708 in a list, this means the library has been
installed successfully. Otherwise you might need to find another Raspbian
OS MicroSD card and repeat Step 2 and 3.

Step 4:Testing Hardware


Depending on your Raspberry Pi version, please run one of following
commands in terminal:

sudo i2cdetect -y 1
or
sudo i2cdetect -y 0

You should see something as follows:


0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 27
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

If you can only see "-- -- --" sign in the list without any numbers, it
means either your circuit connection is wrong or your software is not
properly installed.

Step 5: Download Python Code and run the project:


in terminal window, type the following commands:

wget http://osoyoo.com/driver/i2clcda.py
sudo python i2clcda.py

If there is any runtime writing error, it might be caused by the LCD I/O
address mismatching. try the following commands:

wget http://osoyoo.com/driver/i2clcdb.py
sudo python i2clcdb.py

Now your LCD should display the following messages:

Created by
Osoyoo.com

> Tutorial Url:


> http://osoyoo.com

If your Pi does not show any runtime error but LCD still does not display
any messages, you can use a screw driver to adjust the contrast screw on
the back of the LCD until you see the message.

You might also like