1-Wire Support

There are three ways to use your 1-wire devices with DomotiGa, one is using the Midon TEMP08 interface, another is using a DS9079 interface together with digitemp and the last one is using OWFS. You can also build your own DS9079 compatible interface, see the links below for information.


I use an Midon TEMP08 1-wire interface to measure the temperatures of my boiler/heating system. To do this I have placed several DS1820 temperature sensors on the pipes of my heating system, and connected them to the Midon TEMP08.
This device reports every x minutes the values automatically so I don't have to poll it.

It supports a lot of different 1-wire sensors, but I only ported code for DS1820 sensors, since I don't have any other sensors to test with.

Setup TEMP08

Before you can use it you have to tweak some settings.

The very first time you use your TEMP08, erase all settings:

ERA
Are you sure? (y/n) 

Set the clock:

SCK 04,20,39,13

Version:
VER
TEMP08 v2.04 2006-07-03
[[MidonDesign]].com 1517

Set poll minutes to 1 minute:
SPT 1

Set Celsius:
STD C

Next use the INI command to search for any 1-Wire
devices connected to the 1-Wire bus.
INI
...

Disable some sensors:
DIS
01 4D0000004FC78A26 DS2438 OK P56 4F 4C 6D 69 64 6F 6E FE ! V
02 1D00000005B5E51D DS2423 OK M ?

Update interval = 01 minutes
Temp display = C
Serial # display = On
Wind dirn reverse = On
Debug = Off
Some temp sensors Parasitic powered
Qty of DS1820=00
Qty of DS1822=00
Qty of DS18B2=00
Qty of DS2438=01
WED 20:50:52

Debug off:

DEB OFF

WED 20:54:21
Reading Sensors...
Voltage #1[4D0000004FC78A26]=00.60V 04.98V
Temp #1[4D0000004FC78A26]=24.31C

Install and Setup digitemp

Install digitemp like do:

$ sudo apt-get install digitemp

Note: You cannot use device by serial id, it will generate a segmentation fault. (too long I guess)
But you can create a symbolic link like so:
$ sudo ln -s /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0 /dev/digitemp

Then connect your interface to the serial port, and determine it's serial device.
Now you can check if sensors are seen, by walking the 1-wire bus.

$ digitemp_DS9097U -s /dev/digitemp  -w
[[DigiTemp]] v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Turning off all DS2409 Couplers
...
Devices on the Main LAN
1049023A01080011 : DS1820/DS18S20/DS1920 Temperature Sensor
0956F3B001000081 : DS2502/DS1982 1Kbit Add only memory
1D3AB905000000DB : DS2423 4Kbit RAM + Counter

The first one is a temp sensor I have connected, the second device is the memory chip build into it, the third a dual counter.
If all devices are connected and seen on the 1-wire bus, initialize digitemp so it creates a config file.

 digitemp_DS9097U -s /dev/digitemp -i
DigiTemp v3.5.0 Copyright 1996-2007 by Brian C. Lane
GNU Public License v2.0 - http://www.digitemp.com
Turning off all DS2409 Couplers
....
Searching the 1-Wire LAN
1051F071010800BE : DS1820/DS18S20/DS1920 Temperature Sensor
10F13FC0010800B1 : DS1820/DS18S20/DS1920 Temperature Sensor
10F940C001080012 : DS1820/DS18S20/DS1920 Temperature Sensor
ROM #0 : 1051F071010800BE
ROM #1 : 10F13FC0010800B1
ROM #2 : 10F940C001080012
Wrote .digitemprc

The created file looks like this:
TTY /dev/digitemp
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F" 
CNT_FORMAT "%b %d %H:%M:%S Sensor %s #%n %C" 
HUM_FORMAT "%b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%" 
SENSORS 2
ROM 0 0x10 0x49 0x02 0x3A 0x01 0x08 0x00 0x11
ROM 1 0x1D 0x3A 0xB9 0x05 0x00 0x00 0x00 0xDB

Move it to a central place.
$ sudo mv ~/.digitemprc /etc/digitemp.conf

Important, edit the file so the serial id is also displayed in the output (add the %R to every FORMAT line)
it looks like this afterwards.

TTY /dev/digitemp
READ_TIME 1000
LOG_TYPE 1
LOG_FORMAT "%R %b %d %H:%M:%S Sensor %s C: %.2C F: %.2F" 
CNT_FORMAT "%R %b %d %H:%M:%S Sensor %s #%n %C" 
HUM_FORMAT "%R %b %d %H:%M:%S Sensor %s C: %.2C F: %.2F H: %h%%" 
SENSORS 2
ROM 0 0x10 0x49 0x02 0x3A 0x01 0x08 0x00 0x11
ROM 1 0x1D 0x3A 0xB9 0x05 0x00 0x00 0x00 0xDB

Now we can call digitemp with
$ digitemp_DS9097U -a -q -c /etc/digitemp.conf
1049023A01080011 Nov 23 13:21:19 Sensor 0 C: 17.62 F: 63.73
1D3AB905000000DB Nov 23 13:21:19 Sensor 1 #0 1
1D3AB905000000DB Nov 23 13:21:19 Sensor 1 #1 1

So now you need to configure the devices as type 1-Wire and with the serial ID (for example 1049023A0108001) as address in DomotiGa to get the readings of this sensor.

As of DomotiGa version 0.1.174 there is no device type 'Digitemp' anymore, they are type 1-Wire like the Midon TEMP08 ones.
You have to change the address of existing Digitemp Devices from Sensor # to their serial IDs.
Thanks to Timo for the changes.

If people have sample digitemp output of other 1-Wire type devices, please sent them so can add them to the Digitemp.module!

Install and Setup OWFS

OWFS is an open project that allow full control of 1Wire bus and devices, through a filesystem, a web interface a remote network access or a nice bunch of languages
(perl, python, php, tcl, Java, C)
Please check this great project on OWFS Homepage
OWFS allow like no other to manage 1Wire buses, even those with muliple branches, like using 6 channel Hub from Hobby-boards

Of course it works well also if you have a very simple bus with one controller and one device like a temperature DS1820.
To install OWFS you must have first some packages installed:

$ apt-get update
$ apt-get install automake
$ apt-get install autoconf
$ apt-get install autotools-dev
$ apt-get install gcc
$ apt-get install g++
$ apt-get install libtool
$ apt-get install libusb-1.0.0-dev
$ apt-get install fuse-utils
$ apt-get install libfuse-dev
$ apt-get install swig
$ apt-get install tcl8.4-dev
$ apt-get install php5-dev 

Then check the latest version of OWFS on: http://sourceforge.net/projects/owfs/files/owfs/
And modify version accordingly in the following commands:

!! Beware !! Do not use root account or you will get priviledge problems when running OWFS. use you standard account and "sudo" when needed.

$ mkdir /home/[YOURUSERDIRECTORY]/owfs
$ cd /home/[YOURUSERDIRECTORY]/owfs
$ wget http://sourceforge.net/projects/owfs/files/owfs/2.8p7/owfs-2.9p3.tar.gz/download 
$ mv download owfs-2.9p3.tar.gz
$ tar zxpf owfs-2.9p3.tar.gz
$ cd owfs-2.9p3
$ ./configure --enable-owtraffic
$ make
$ sudo make install
$ modprobe fuse 
$ mkdir /home/[YOURUSERDIRECTORY]/1wire

To start OWFS:

$/opt/owfs/bin/owserver -d /dev/ttyS0  --debug  [to be adapted to your hardware]

This start the OWFS server, that controls the bus

/opt/owfs/bin/owhttpd --debug -s 127.0.0.1:4304 -p 4444

This start the http server, on port 4444.
Even if not needed by Domotiga, this allow to browse easlily your 1Wire bus and discover devices, their name, their values names, values itself
You can also change values (like switch on/off a DS2405 switch)
Really useful during configuration and tests.
--debug option is not mandatory of course.

/opt/owfs/bin/owfs --debug -s 127.0.0.1:4304 -m /home/[YOURUSERDIRECTORY]/1wire

This start the filesystem, used by DomotiGa.

You can check your 1wire bus, listing directory and files in /home/[YOURUSERDIRECTORY]/1wire
In the following example, this a 3 branches bus, with various devices
DS1820 : temperature : we check value of device 10.DBBA6B010800 on branch 1F.7BD304000000
DS2405 : Switch : we check status of device 05.393730000000 on same branch 1F.7BD304000000

$ cd /home/[YOURUSERDIRECTORY]/1wire
$ ls
1F.7BD304000000  1F.E7F404000000  settings    structure  uncached
1F.8FD304000000  bus.0            statistics  system
~/1wire$ cd 1F.7BD304000000/
~/1wire/1F.7BD304000000$ ls
address   branch.1     control    event.1     id         r_id       sensed.ALL
alias     branch.ALL   crc8       event.ALL   locator    r_locator  sensed.BYTE
aux       branch.BYTE  discharge  event.BYTE  main       sensed.0   type
branch.0  clearevent   event.0    family      r_address  sensed.1
~/1wire/1F.7BD304000000$ cd main
~/1wire/1F.7BD304000000/main$ ls
05.393730000000  05.D04430000000  10.DBBA6B010800
05.972B30000000  10.086939010800  alarm
05.CE2D30000000  10.208E39010800  simultaneous
~/1wire/1F.7BD304000000/main$ cd 10.DBBA6B010800/
~/1wire/1F.7BD304000000/main/10.DBBA6B010800$ ls
address  crc8    family  locator  r_address  r_locator    temphigh  type
alias    errata  id      power    r_id       temperature  templow
~/1wire/1F.7BD304000000/main/10.DBBA6B010800$ cat temperature
       22.25
~/1wire/1F.7BD304000000/main/10.DBBA6B010800$ cd ..
~/1wire/1F.7BD304000000/main$ ls
05.393730000000  05.D04430000000  10.DBBA6B010800
05.972B30000000  10.086939010800  alarm
05.CE2D30000000  10.208E39010800  simultaneous
~/1wire/1F.7BD304000000/main$ cd 05.393730000000/
~/1wire/1F.7BD304000000/main/05.393730000000$ ls
address  crc8    id       PIO        r_id       sensed
alias    family  locator  r_address  r_locator  type
~/1wire/1F.7BD304000000/main/05.393730000000$ cat PIO
0

To switch on value on the DS2405 05.393730000000, you just need:

$ echo "1" > /home/[YOURUSERDIRECTORY]/1wire/1F.7BD304000000/main/05.393730000000/PIO

To list all temperatures and switch devices you have, you can use easily:

ls 1F*/main/10*/temperature and ls 1F*/main/05*/PIO 
$ /home/[YOURUSERDIRECTORY]/1wire
~/1wire$ ls 1F*/main/10*/temperature
1F.7BD304000000/main/10.086939010800/temperature
1F.7BD304000000/main/10.208E39010800/temperature
1F.7BD304000000/main/10.DBBA6B010800/temperature
1F.8FD304000000/main/10.B47E6B010800/temperature
1F.E7F404000000/main/10.37766B010800/temperature
1F.E7F404000000/main/10.852A3A010800/temperature
1F.E7F404000000/main/10.C77D6B010800/temperature
~/1wire$ ls 1F*/main/05*/PIO
1F.7BD304000000/main/05.393730000000/PIO
1F.7BD304000000/main/05.972B30000000/PIO
1F.7BD304000000/main/05.CE2D30000000/PIO
1F.7BD304000000/main/05.D04430000000/PIO
1F.8FD304000000/main/05.300332000000/PIO
1F.8FD304000000/main/05.A10832000000/PIO
1F.8FD304000000/main/05.D60932000000/PIO
1F.8FD304000000/main/05.E00432000000/PIO
1F.8FD304000000/main/05.F10532000000/PIO

To configure OWFS bus in DomotiGa:
OWFS Setup in Domotiga is easy.
Just tick "enable" in Setup>interfaces>1-Wire>OWFS
Then you need to add devices.
Device> Add device
Choose a name, device type "1-Wire" and interface "OWFS"
Choose now your Device type "Dallas DS18S20" for example and tick "enable"
For the 1-Wire-ID, just use the full path to the value, "1F.7BD304000000/main/10.086939010800/temperature" for example
In case of a DS2405 (the switch) do not forget to go in the Options tab and tick "Device can be switched"
You can now see your device in the "Devices" tab, and even on/off DS2405 switches from the control Tab
Enjoy!

Resources

Updated by: rdnzl, Updated about 2 years ago
Access count: 78810 since 2011-08-25

Attached Files

temp08.jpg (4.53 KB) rdnzl, 08/23/2011 12:17 PM

temp08-box.jpg (4.14 KB) rdnzl, 08/23/2011 12:17 PM

ds9097.jpg (16.8 KB) rdnzl, 08/23/2011 12:19 PM

ds1820.pdf (154 KB) rdnzl, 04/24/2012 02:16 PM

Also available in: PDF HTML TXT