# Orange Pi Zero - I2C Support

**URL:** <https://forums.balena.io/t/orange-pi-zero-i2c-support/349942>\
**Category:** balenaOS\
**Tags:** support\
**Created:** [November 4, 2021, 12:24am UTC](https://forums.balena.io/t/orange-pi-zero-i2c-support/349942 "2021-11-04T00:24:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwolleben](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mwolleben](https://forums.balena.io/u/mwolleben)\
**Post date:** [November 4, 2021, 12:24am UTC](https://forums.balena.io/t/orange-pi-zero-i2c-support/349942/1 "2021-11-04T00:24:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [November 4, 2021, 10:50am UTC](https://forums.balena.io/t/orange-pi-zero-i2c-support/349942/2 "2021-11-04T10:50:09Z")

</div>

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](https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/)

Let us know if this works!

---

<div class="post-metadata">

**Author:** ![mwolleben](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mwolleben](https://forums.balena.io/u/mwolleben)\
**Post date:** [November 4, 2021, 4:11pm UTC](https://forums.balena.io/t/orange-pi-zero-i2c-support/349942/4 "2021-11-04T16:11:26Z")

</div>

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:

```auto
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:

```auto
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`.

---

<div class="post-metadata">

**Author:** ![TJvV](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@TJvV](https://forums.balena.io/u/TJvV)\
**Post date:** [November 5, 2021, 8:25am UTC](https://forums.balena.io/t/orange-pi-zero-i2c-support/349942/5 "2021-11-05T08:25:44Z")

</div>

Hi,

I have no experience with Orange Pi, but [here](https://sites.google.com/site/orangepizero/logitech-media-server/lcd-i2c) 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.

---

<div class="post-metadata">

**Author:** ![mwolleben](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@mwolleben](https://forums.balena.io/u/mwolleben)\
**Post date:** [November 5, 2021, 8:13pm UTC](https://forums.balena.io/t/orange-pi-zero-i2c-support/349942/6 "2021-11-05T20:13:46Z")

</div>

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

> <https://github.com/balena-os/balena-allwinner/issues/102>
>
> Hello,
> 
> I am having trouble connecting a UART device to the OrangePi Zero from… the onboard pins. When physically connected, the /dev/ttyS1 does not present itself to the kernel and it does not show that a device is connected. It appears that these ports are not enabled. Any help on this would be great!
> 
> Thank you

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…
