본문 바로가기

Computer/Linux

라즈베리파이 - I2C 1602 LCD module

https://youtu.be/fR5XhHYzUK0


GND →  Ground (6)

VCC → 5v ( 2)

SDA → GPIO2 

SCL → GPIO3



I2C Enable

sudo raspi-config

Advanced option > I2C > Enable


Install smbuns and i2c-tools

sudo apt-get update

sudo apt-get install -y python-smbus i2c-tools



Checking if I2c is enabled.

lsmod | grep i2c_



Checking I2C address

sudo i2cdetect -y 1


I2C address from following example is 0x3f, this I2C address is important. 


     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3f

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --


Source code from

wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/lcd_i2c.py



sudo nano lcd_i2c.py


Change I2C address to "0x3f" if it needs to be adjusted.

#Define some device parameters

I2C_ADDR  = 0x3f # I2C device address


Change to backlight option
#LCD_BACKLIGHT  = 0x08  # On
LCD_BACKLIGHT = 0x00  # Off