I2C 20x4 LCD
Hello world example
Wiring
Download fritzing
- fritzing parts ☞ h3_20x4lcd_i2c.fzz
- LCM1602 part ☞ lcm1602_iic.fzpz
- ODROID-H3 part ☞ odroid-h3.fzpz
Connection Check
If you have done the wiring well, you can see the device as the following commands.
Step 1. Install i2c-tools package.
sudo apt install i2c-tools
Step 2. Check the I2C bus number on your H3. That could be variable depending on your system.
The below i2cdetect -l output shows the system has assigned I2C bus numbers 1 and 2. The 20×4 LCD is using the Synopsys DesignWare I2C adapter.
- target
odroid@odroid-h3p:~$ sudo i2cdetect -l i2c-0 smbus SMBus I801 adapter at efa0 SMBus adapter i2c-1 i2c Synopsys DesignWare I2C adapter I2C adapter i2c-2 i2c Synopsys DesignWare I2C adapter I2C adapter i2c-3 i2c i915 gmbus dpa I2C adapter i2c-4 i2c i915 gmbus dpb I2C adapter i2c-5 i2c i915 gmbus dpc I2C adapter i2c-6 i2c i915 gmbus tc1 I2C adapter i2c-7 i2c i915 gmbus tc2 I2C adapter i2c-8 i2c i915 gmbus tc3 I2C adapter i2c-9 i2c i915 gmbus tc4 I2C adapter i2c-10 i2c i915 gmbus tc5 I2C adapter i2c-11 i2c i915 gmbus tc6 I2C adapter i2c-12 i2c AUX B/DDI B/PHY B I2C adapter
Step 3. Try the i2cdetect command with the I2C bus number which is appeared in Step 2.
sudo i2cdetect -y -r 1 # 1(one) is the I2C bus number it could be 2(two) in this examples.
The I2C address appears 0x27 like below.
- target
odroid@h2:~$ sudo i2cdetect -y -r 1 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: -- -- -- -- -- -- -- --
For this I2C 20×4 LCD module is possible to change an address from 0x20 until to 0x27 by wiring A0, A1, and A2 to the GND.
If you flip over the module, you can see the places with white silkscreen A0, A1, and A2 under the squared blue color variable resistor.
so, Since H3 has two I2Cs on the 24pin expansions, it is available two I2C 20×4 LCD module could be attached.
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
Install smbus package using pip tool.
sudo apt install pip sudo pip install smbus
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
python3
sudo python3 hello_world.py I2CBUS ADDRESS
sudo python3 hello_world.py 1 27
Or
sudo python3 hello_world.py 2 27
wiringPi
odroid-wiringpi version is 3.15.2 or later.
git clone https://github.com/hardkernel/wiringPi.git cd wiringPi/examples ./autogen.sh ./configure make
sudo i2c-lcd I2C-BUS ADDRESS
sudo i2c-lcd 1 27
Or
sudo i2c-lcd 2 27