LCD 1602 and Pi – Part 2: Configuring and Orange Pi for 1602 LCD with i2c

Part 1 is here: http://www.mintrix.net/blog/2019/08/07/1602-lcd-displaying-interface-ip-addresses-for-a-headless-raspberry-pi-part-1/

So previously, I talked about how to set up a Raspberry Pi with LCD 1602 via i2c. It was extremely easy on Raspian. you simply have to enable the i2c support and boom you can run the python script and it works. However, Orange Pi is a clone of RPi and it doesn’t run Raspbian, so it takes few more steps to get that working. So here is the step by step on how to set the sucker up and at the end of the day, it should be pretty much exactly the same as the Raspberry Pi setup.

TL; DR: just watch the video at the end….

So just follow these simple step

STEP 1: apt-get install -y python-smbus i2c-tools python-dev
Download the required modules.
python-smbus
i2c-tools
python-dev

These files are necessary for the python script to run in the near future.

STEP 2: edit /etc/modules file with “nano /etc/modules
add “i2c-dev” in the file no quotes!!

STEP 3: edit /boot/armbianEnv.txt file with “nano /boot/armbianEnv.txt
add “overlays=i2c0 i2c1 i2c2

By default, I2C buses are not enabled, except for the s_i2c .
To enable other i2C buses, you need to edit the overlays in the /boot/armbianEnv.txt
overlays=i2c0 i2c1 i2c2
Then, reboot. After you will have 4 buses in /dev/i2c-*.
You can then scan the buses with “i2cdetect -y n”, where “n” is the bus number.

ref: https://forum.armbian.com/topic/4154-not-armbian-orangepi-zeroplus-h5-i2c/

STEP 4: reboot and test io
reboot

After OrangePi reboots, you will have 4 buses in /dev/i2c-*.
You can then scan the buses with “i2cdetect -y n”, where “n” is the bus number.

i2cdetect -y 0
i2cdetect -y 1

STEP 5: test with script
Download the lcd_i2c python script from Matt Hawkins.
type :
wget https://bitbucket.org/MattHawkinsUK/rpispy-misc/raw/master/python/lcd_i2c.py

and run the script by typing

python lcd_i2c.py

woo hoo!!! you are done!!!

References:

https://www.abelectronics.co.uk/kb/article/1061/i2c–smbus-and-armbian-linux

https://forum.armbian.com/topic/4377-using-16×2-1602-lcd-with-i2c-connector-with-orange-pi-pc/