Hi All,

I am new to the mailing list and am hoping someone out there might be able to 
help us.  We are currently working on a set of devices for monitoring 
endangered animal habitats and we need to try to read multiple 1wire temp 
sensor readings via RPI3. Specifically I am hoping to find someone with 
experience using OWFS on the Balena.io platform and Docker templates.  I am 
looking for an example of OWFS measuring 1wire thermocouples via i2c hat 
running on Balena.io via a Dockerfile? The key here is to get it to work on 
Balena via a Dockerfile.template with i2c enabled as that is how we will manage 
fleets of these devices.

For those of you who aren't familiar with Balena.io it used to be called 
Resin.io until a few years ago.  Balena is a great fleet management and 
deployment platform for managing multiple IOT devices. We use it for many RPI 
implementations.  I highly recommend taking a few hours to learn how to deploy 
a device on their platform as once you start using it you won't go back.  But 
my biggest hope is for one of you experts at OWFS to deploy OWFS via Balena 
onto a RPI3 with an i2c 1-wire hat so that you can share a solution on how to 
properly build a Dockerfile and python file for it that works.  I have been 
trying to figure it out for days and getting nowhere.  I am trying to use 
pyownet which might be part of my problem but I don't have to use that if you 
can think of a better way to do this. I would also like to stick to Python3 as 
Balena is dropping support for Python2 soon.

I am sure Balena will be adopted by folks more and more moving forward so 
solving this would be a great investment in furthering the 1wire and owfs 
platform to be deployed in fleets.  In this situation, it is also going towards 
a good cause of helping endangered animals.

Below is my dockerfile & python code which I just can't get to work properly. I 
continue to get this error: pyownet.protocol.ConnError: [Errno 111] Connection 
refused

This is the i2c device I am using: 
https://www.abelectronics.co.uk/kb/article/3/owfs-with-i2c-support-on-raspberry-pi

Thanks so much,

Greg

----------------------------------------
DOCKERFILE CODE BELOW
----------------------------------------
FROM balenalib/raspberrypi3-python:3.7.6

ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NOWARNINGS yes

RUN     apt-get update -y; \
        apt-get upgrade -y; \
        apt-get clean all

RUN sudo apt-get update -y;\
        apt-get install -qy apt-utils \
        python3-pip \
        python3 \
        libtool \
        python3-dev \
        python3-smbus\
        libtool \
        rpi-update \
        raspi-config \
        owfs \
        owserver \
        ow-shell \
        python-ow \
        python3-rpi.gpio \
        && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN sudo pip3 install setuptools --upgrade

RUN sudo pip3 install --upgrade pip

RUN sudo 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", "1wire_temp_test.py"]

----------------------------------------
PYTHON CODE BELOW
----------------------------------------
import time
from pyownet import protocol

temp_type = 'F'
tc_1_mac = 'FF8AD3641402'  ### This is obviously my thermocouple so enter your 
own mac address here ###

owproxy = protocol.proxy(host="localhost", port=4304)
sensor_file_1 = '/28.' + tc_1_mac + '/temperature'

def main():
                while True:
                                try:
                                                thetext = 
owproxy.read(sensor_file_1)
                                                heater_temp_1 = 
round((float(thetext[2:])*(9/5)+32),2)
                                                print ('SENSOR #1 =', 
heater_temp_1, temp_type)
                                except IOError:
                                                print ('SENSOR #1 READ FAIL')
                                time.sleep(10)

if __name__ == '__main__':
                main()
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to