Banana PI M5 with OLED SSD1306 via I2C

Dear Forum, I have a Banana Pi M5 and i am trying to find a solution to display some information on a small OLED screen connected in the I2C PINs. I have followed the BPI-M5 wiki page installed the Wiring and RPi.GPIO for Amlogic and still no possibility to see the display connected.

Here are my OS details:

PRETTY_NAME="Armbian 22.08.7 Bullseye" 
NAME="Debian GNU/Linux" 
VERSION_ID="11" 
VERSION="11 (bullseye)" 
VERSION_CODENAME=bullseye 
ID=debian 
HOME_URL="https://www.debian.org/" 
SUPPORT_URL="https://www.debian.org/support" 
BUG_REPORT_URL="https://bugs.debian.org/"

Here are my questions:

  • What dts file you are using?
  • What overlay you are using to enable the i2c to be able to read and write through?
  • Did someone use Adafruit Blinka with this board? By default armbian-config showed: i2cA and i2cB overlays but there is no registry. I tried to port and create other i2c0 - i2c4 to try to enable it but without any success.

If i run i2cdetect -l

i2c-1	i2c       	DesignWare HDMI                 	I2C adapter 
i2c-0	i2c       	Meson I2C adapter               	I2C adapter 

if i run i2cdetect -y 0

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

if i run gpiodetect

gpiochip0 [periphs-banks] (85 lines)  
gpiochip1 [aobus-banks] (15 lines)  

If i try to use Adafriut and Blinka example i have this error:

python3 stats.py 
Traceback (most recent call last):
  File "/pi-app/oled-test/OLED_Stats/stats.py", line 6, in <module>
    import board
  File "/pi-app/oled-test/.env/lib/python3.9/site-packages/board.py", line 137, in <module>
    from adafruit_blinka.board.bananapi.bpim5 import *
  File "/pi-app/oled-test/.env/lib/python3.9/site-packages/adafruit_blinka/board/bananapi/bpim5.py", line 12, in <module>
    SCL = pin.i2cPorts[0][1]
IndexError: tuple index out of range

Did somebody on this forum manage to connect an OLED to BPI-M5 and make it display some information like, hostname, load, etc?
Thank you very much for your time and help,
KR,
Dino

Hello friend and greetings to all. I am also in your same situation with i2c display. But I can not see only the i2c-0 bus which seems to be used for HDMI. Could you please indicate how you installed RPi.GPIO for Amlogic?

Hi Stefano,
You have 2 possibilities:

  1. Just use the https://wiki.banana-pi.org/Getting_Started_with_M5/M2Pro#RPi.GPIO steps.If you have compilation issues try install gcc 9 and symlink the gcc used during build from 10 version to 9. That worked for me
  2. Try installing it with pip install RPi.GPIO

The issue i see it in case of BPI-M5 is the that there is no documentation about device tree and how to work with them and overlays, also how to use fdtget and fdtput to enable/disable components in the device tree.
Good luck!
If will work for you please share here also how :slight_smile:
KR,
Dino

Hello everybody,

unfortunately after numerous attempts I too can not use i2c. I tested a version of ubuntu mate where i2c works but the GPIOs don’t. Some idea?

Hi Stefano, You mean you can use the I2C pins on the 40 pin layout? Or you just can see the i2c-0, the HDMI one with registry 0x30?

Thank you, Dino

root@bananapi:/home/pi# i2cdetect -y 0
 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- 71 -- -- -- -- -- --  

On ubuntu mate, i see the my device connected to the 40 pins.