docs icon indicating copy to clipboard operation
docs copied to clipboard

Docs on I2C on the Raspberry Pi are outdated

Open lmbarros opened this issue 1 year ago • 6 comments

Our docs that explain how to use I2C with the Raspberry Pi family are outdated: they still assume a single container app, while we have been recommending multi-container apps for some time now. The example project we link to is also very old.

(Our docs on multiple containers give some hints on the right way to go, but don't spell out the solution clearly enough either.)

I am not completely sure what a modern I2C example would look like, but here's what I can see for now:

# docker-compose.yml
version: "2"

services:
  my-service:
    # ...
    devices:
      - "/dev/i2c-1:/dev/i2c-1"
      # - "/dev/mem:/dev/mem" # <--- not sure if needed, I don't think so
    cap_add:
      - SYS_RAWIO # <--- not sure if this us the right capability to add. Alternatively, using `privileged: true` should work.)
    labels:
      io.balena.features.kernel-modules: '1'

lmbarros avatar May 23 '23 20:05 lmbarros

[lmbarros] This has attached https://jel.ly.fish/2c01bec6-5d4a-4c5b-9668-9e5fdee085d0

jellyfish-bot avatar May 23 '23 20:05 jellyfish-bot

Thanks @lmbarros for pointing this out. Maybe we can work with @acostach to figure out the best way to modernize these examples. @acostach What do you think the improvements can be?

vipulgupta2048 avatar May 29 '23 07:05 vipulgupta2048

@vipulgupta2048 why not link to https://github.com/balena-labs-projects/balena-sense ? It's modern and updated, supports a variety of i2c sensors and is multi-container too

acostach avatar May 29 '23 08:05 acostach

Sounds good to me! @acostach Let's do that, will you make the PR?

vipulgupta2048 avatar May 29 '23 12:05 vipulgupta2048

balena sense would be a better example than the one we currently provide, for sure.

FWIW, last Friday I started a little experiment to try these things out myself. For now it is not a good example to share (not documented, and I still have doubts about how it really works), but maybe someday it can become a more focused I2C example. I mean, IMHO, balena sense may be a bit too big as an I2C example. (For example, if you look at the docker-compose.yml , how do you know if some config is required to support I2C or something else used by the project?)

lmbarros avatar May 29 '23 20:05 lmbarros

@lmbarros your project doesn't look far from being used as a focused example. Looking at balena-sense's docker-compose I believe privileged was used to allow for the sensors to be used with any device-type, regardless of the i2c busses used. Anyway, I opened https://github.com/balena-io/docs/pull/2723 to link to it until a more focused example will be available.

acostach avatar May 31 '23 10:05 acostach