I2C 20x4 LCD
Hello world example
Wiring
Download fritzing
- LCM1602 part ☞ lcm1602_iic.fzpz
- ODROID-H2 part ☞ odroid-h2.fzpz
- ODROID-H2+ part ☞ odroid-h2plus.fzpz
- fritzing parts(H2) ☞ 20x4lcd_i2c.fzz
- fritzing parts(H2+) ☞ h2plus_20x4lcd_i2c.fzz
Connection Check
If you have done the wiring well, you can see the device as the following commands.
sudo apt install i2c-tools
- If you're using an older kernel than 4.18, tap the “Old kernel version”.
kernel 4.18 or higher
When you have wired the I/O expander to Pin #18(SCL) and #20(SDA).
sudo i2cdetect -y -r 2
When you have wired the I/O expander to Pin #13(SCL) and #15(SDA).
sudo i2cdetect -y -r 3
- target
odroid@h2:~$ sudo i2cdetect -y -r 2 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
Old kernel version
When you have wired the I/O expander to Pin #18(SCL) and #20(SDA).
sudo i2cdetect -y -r 5
When you have wired the I/O expander to Pin #13(SCL) and #15(SDA).
sudo i2cdetect -y -r 6
- target
odroid@h2:~$ sudo i2cdetect -y -r 5 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
If you have done the wiring well, you can see the device as the following commands.
sudo apt install i2c-tools
When you have wired the I/O expander to Pin #18(SCL) and #20(SDA).
sudo i2cdetect -y -r 5
When you have wired the I/O expander to Pin #13(SCL) and #15(SDA).
sudo i2cdetect -y -r 6
- Kernel 4.18 must access the I2C channel #6 via /dev/i2c-2.
- target
odroid@h2:~$ sudo i2cdetect -y -r 2 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
Install & build python packages
sudo apt install git python3-dev libi2c-dev python3-smbus
If you got this error on your Ubuntu.
E: Unable to locate package python3-smbus
Build the python3-smbus package.
git clone https://github.com/tkurbad/python3-smbus.git cd python3-smbus python3 setup.py build python3 setup.py install
Get source code
git clone https://github.com/hardkernel/i2c_20x4_lcd.git
Edit lcddriver.py if you need to change the host bus address and/or device address.
Run the example
sudo python3 hello_world.py I2CBUS
- If you're using an older kernel than 4.18, tap the “Old kernel version”.
kernel 4.18 or higher
sudo python3 hello_world.py 2
Or
sudo python3 hello_world.py 3
Old kernel version
sudo python3 hello_world.py 5
Or
sudo python3 hello_world.py 6
System Monitor
Thanks to djjproject
Install requirement packages
sudo apt install git python3-dev libi2c-dev python3-smbus sudo apt install python3-psutil lm-sensors hdparm
Get the source code
git clone https://github.com/djjproject/odroidh2_i2c_lcd.git
Change I2C bus and Ethernet port
You may need to change to the I2C bus and Ethernet port name you are using.
Ethernet : https://github.com/djjproject/odroidh2_i2c_lcd/blob/master/hello_world.py#L8
I2C bus : https://github.com/djjproject/odroidh2_i2c_lcd/blob/master/lcddriver.py#L9
Run
sudo python3 hello_world.py