Reputation: 17
I would need help from colleagues. I have an Adafruit OLED library installed on raspberrypi working perfectly. I installed it on a rockpi 4, it installs perfectly, but when I run the program, it gives an error as shown below
error:
Traceback (most recent call last): File "test.py", line 7, in i2c = busio.I2C(7, board.SDA, board.SCL) File "/usr/local/lib/python3.8/dist-packages/busio.py", line 35, in init self.init(scl, sda, frequency) File "/usr/local/lib/python3.8/dist-packages/busio.py", line 123, in init raise ValueError( ValueError: No Hardware I2C on (scl,sda)=(7, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cdcd0>) Valid I2C ports: ((0, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cdd60>, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cdcd0>), (1, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cdf10>, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cdeb0>), (7, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cde50>, <adafruit_blinka.microcontroller.generic_linux.sysfs_pin.Pin object at 0x7f851cddc0>))
Code:
import mraa
import time
import board
import busio
i2c = busio.I2C(7, board.SDA, board.SCL)
import adafruit_ssd1306
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# initialise gpio 23
gpio_1 = mraa.Gpio(37)
# initialise gpio 24
gpio_2 = mraa.Gpio(24)
# set gpio 23 to output
gpio_1.dir(mraa.DIR_OUT)
# set gpio 24 to output
gpio_2.dir(mraa.DIR_OUT)
# toggle both gpio's
while True:
gpio_1.write(1)
gpio_2.write(0)
time.sleep(1)
gpio_1.write(0)
gpio_2.write(1)
time.sleep(1)
Installed:
apt-get install -y rockpi4-dtbo
apt-get install libmraa
apt-get install python3-pip
apt-get install python3-pil
apt-get install python3-numpy
pip3 install adafruit-circuitpython-ssd1306
testing rockpi 4 commands linux
mraa-i2c detect 0
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- ---- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
found oled display 0x3c
enabled and turned on i2c display on rockpi 4 i2c7
Upvotes: 0
Views: 710
Reputation: 1
As it's not listed in your installed list, I believe you will need this python library too - it's also required for busio:
https://github.com/adafruit/Adafruit_Blinka
You should install this library using PyPi, as instructed here: https://github.com/adafruit/Adafruit_Blinka#installing-from-pypi
Upvotes: 0