Publishing 1-Wire temperature sensors to Emoncms via a Raspberry Pi part 3

Last time, we installed OWFS to read the DS18B20 sensors connected to the 1-Wire bus and represent the temperatures as a file system. We now need to be able to publish them to the Emoncms to log and display the data.

Publishing to Emoncms is very easy – it has been designed to work with lightweight embedded devices with limited memory. A simple Python, Perl or C program could form a JSON request and post the data periodically. However, my Raspberry Pi is already using an RFM12Pi to receive data from my network of sensors. This uses a demon-ised Python script called oem_gateway to listen to the RFM12Pi and send the data to Emoncms.

You can install oem_gateway by following the instructions supplied on the github page.

I decided to modify oem_gateway instead of rolling my own script. The changes can be seen here, in my github repo.

A new OemGatewayListener called OemGatewayOWFSListener was created. This requires a number of settings in oemgateway.conf:

# Listener for OWFS 1-Wire sensors
  type = OemGatewayOWFSListener
        # The path where the 1-Wire FS is located
        path = /mnt/1wire
        # The node to send as
        node = 9
        # How frequently we should send
        interval = 10
        # What resolution should we read the sensors with
        resolution = 11
        # A list of sensor IDs in full
        # sensorX must be unique
        # ID has 28. (family) and 0000 (blank CRC bits)
        sensor1 = 28.33F749050000
        sensor2 = 28.DB564A050000
        sensor3 = Dummy
        sensor4 = 28.AB1663050000

These are relatively self-explanatory, probably with the exception of “Dummy” sensors. oem_gateway sends all sensor values using numerical indices i.e. {1:18.7,2:18.6,3:19.2} by iterating through a list of values. There are no names or explicit indices, so if one of the data values isn’t present, the indices change, and Emoncms has issues. Rather than change all listeners to have named sensor values, I decided to allow “Dummy” sensors to be placed in the list of DS18B20 IDs.

This means that we can unplug a sensor without impacting the indices, so that Emoncms shifting all the values incorrectly.

This has been publishing temperatures to Emoncms for a number of weeks with no issue now.

DS18B20 in EmonCMS


Whilst this is neat, I would much prefer to use an Arduino to poll the DS2482 and send the data wirelessly to this node – for next time!

One thought on “Publishing 1-Wire temperature sensors to Emoncms via a Raspberry Pi part 3

  1. Permalink  ⋅ Reply

    Erik Johnsen

    August 12, 2014 at 1:00pm

    Hey Mr.

    An idea id like to forward, could one make the sensor id “sensor1 = 28.33F749050000” include the path and type. ie like this : sensor1 = /mnt/1wire/28.13343B040000/temperature
    sensor2 = /mnt/1wire/28.13343B040000/humidity
    sensor3 = /mnt/1wire/28.13343B040000/counter A
    sensor4 = /mnt/1wire/26.3D2292010000/VDD
    sensor5 = /mnt/1wire/26.3D2292010000/temperature

Leave a Reply

Your email will not be published. Name and Email fields are required.

This site uses Akismet to reduce spam. Learn how your comment data is processed.