Orange Pi Zero - I2C Support

I am looking for a way to enable I2C support on the Orange Pi Zero. I tried almost every base image such as balenalib/orange-pi-zero-ubuntu, etc, but none will enable the i2c bus (no /dev/i2c*). Is there documentation that explains how to use i2c on the orange pi zero with balena?

Hello @mwolleben

Could you please share more details? Are your containers running on privileged mode?

You can read more here I2C and Other Interfaces - Balena Documentation

Let us know if this works!

Hello,

I did see the documentation you mentioned but it doesn’t cover the Orange Pi and it can not be adapted to work on the Orange either.

Here is the Dockerfile:

FROM balenalib/orange-pi-zero-ubuntu:focal-build
RUN install_packages i2c-tools
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
ENV UDEV=1
WORKDIR /usr/src/app
CMD [ "balena-idle" ]

And here is the docker-compose:

version: '2.1'
services:
  watchdog:
    build: ./watchdog
    privileged: true
    restart: always
    labels:
      io.balena.features.sysfs: '1'
      io.balena.features.supervisor-api: '1'
      io.balena.features.balena-api: '1'
      io.balena.features.kernel-modules: '1'

Inside the container I tried modprobe i2c-dev, which runs without error but does nothing, and modprobe gpio-sunxi, which complains that the module cannot be found. I think the gpio-sunxi module is the correct one to use for the Orange.

Running i2cdetect -l shows no i2c devices and there are also none listed in /dev.

Hi,

I have no experience with Orange Pi, but here they suggest you might need the module i2c-bcm2708 .

I think it’s usually a good starting point to first check if you can get devices to work in the Host OS before trying to use them from a container.

Ok, for anyone else interested in getting I2C and UART running on the Orange Pi Zero, follow the instruction here:

I can confirm that this can be used to get I2C as well as UART over the GPIO pins to work. Important to follow the instructions all the way to the end in order to end up with a permanent solution that persists between power cycles.

As container image I used: balenalib/orange-pi-zero:build and the Dockerfile should probably include ENV UDEV=1.

The docker-compose probably needs to include privileged: true for this container as well.

Hope this is helpful to anyone…