Getting OWFS to Work on New Balena Base Images Instead of Legacy Resin Images

Hi Everyone,

I would appreciate help on an issue I am wasting too much time on my own trying to figure it out. We have a few RPIs that we use i2c 1-wire hats on for reading temperatures with DS18B20+ sensors . Here is one of the hats we use https://www.abelectronics.co.uk/p/60/1-wire-pi-plus

We use OWFS along with Pyownet and this has been working fine with a Docker build that is tied to legacy Resin base image. Stuck in quarantine I have decided to finally try to upgrade these devices to the new Balena base images. In trying to do so I can no longer get OWFS to work. My first suspicion is it might have something to do with OWFS possibly using systemd INITSYSTEM… but I also don’t know too much about the whole INIT world so it could also be something different. I want to start by seeing if there is anyone else using similar i2c 1-wire boards out there and using OWFS that can try to help on this as i think you would actually need the board to make sure it is fully working? Of if there is anyone you can potentially help without having one of the boards that would be great too?

Here is a link to how they suggest programming the setup: https://www.abelectronics.co.uk/kb/article/3/owfs-with-i2c-support-on-raspberry-pi

Below is what I had for a resin docker file that was working fine. When i change the base image to balena it stops working and returns a connerror.

FROM resin/raspberrypi3-python:latest
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NOWARNINGS yes
RUN apt-get update -y &&
apt-get upgrade -y &&
apt-get clean all
RUN apt-get update -y &&
apt-get install -qy apt-utils
python3
libtool
python3-dev
libtool
rpi-update
raspi-config
owfs
owserver
ow-shell
python-ow
python3-rpi.gpio
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN pip3 install smbus
RUN pip3 install pyownet
RUN sed -i ‘20i\server: device=/dev/i2c-1’ /etc/owfs.conf
RUN sed -i ‘s/^server: FAKE = DS18S20,DS2405/#server: FAKE = DS18S20,DS2405/’ /etc/owfs.conf
RUN sed -i ‘s/^ftp: port = 2120/#ftp: port = 2120/’ /etc/owfs.conf
COPY . ./
ENV INITSYSTEM on
CMD modprobe i2c-dev && owserver -d /dev/i2c-
CMD [“python3”, “TempReader.py”]

Hi @tofino,

Typically, the container must run in privileged mode (privileged: true in your docker-compose.yml) to get device access. Can you confirm that? If the device /dev/i2c-1 is visible in the Host OS, but not accessible in the container, that could be an issue. You might also try to run the modprobe command from a bash script rather than in the Dockerfile itself. Is that something you’ve tried?

John

John,

I finally had a chance to dig into this today. My docker-compose.yml file does have this container as privledged. But for the life of me can’t figure out how to see if the i2c device is visible. I tried i2cdetect -y 0 from the host OS Terminal but it claims “command not found”. I also am too rookie to understand how to make a bash script tied to the Dockerfile. I have searched the forum and docs and can’t find an example. Any other advice for me?

Update - Good news! I ended up getting it to work by leaving the CMD modbus line in the Dockerfile but re-wrote it this way:

CMD sudo modprobe i2c-bcm2798 && modprobe i2c-dev

Then I created a bash script to start the owserver:

CMD bash entry.sh


contents of entry.sh

service owserver start
python3 1wire_temp_test.py


Thanks!
Carl