OWFS/1Wire and Domotiga

Forum about Domotiga Open Source Home Automation for Linux.

Moderator: RDNZL

Post Reply
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

OWFS/1Wire and Domotiga

Post by klona »

Hi,
I am brand new on Domotiga.
I have a 1wire bus with temperature probes (DS1920) and relays for various stuff (DS2405).
Architecture is on 3 branches as I am using a old HobbyBoards 3 channels master hub.
I set up a VmWare VM with Ubnut 10.10, installed Domotiga as well as Digitemp (to test) and OWFS
With Digitemp I can get temperature in Domotiga, setting up a Digitemp interface and creating a 1wire devices.
But I cannot pilot DS2405 as Digitemp is read only.

With OWFS, I have OWFSHTTPD working, enabling a web interface to browse, read and pilot DS1820 & 2405 (
With OWFS I also have a Virtual Filesystem with all the DS1820/2405 and I can read easily value with a cat command :
For ex :
cat /var/1wire/1F.7BD304000000/main/10.208E39010800/temperature

now, How can I integrate that inot Domotiga ?

Can I create some virtual device that in fact reads value every minute from a cat command ?
Can I creat some virtual device that I can switch on or OFF and that do a write on filesystem or open a web page (http://127.0.0.1:4444/1F.8FD304000000/m ... PIO=CHANGE or http://127.0.0.1:4444/1F.8FD304000000/m ... PIO=CHANGE )

Or any other idea to integrate OWFS with Domotiga ?

Thanks in advance !

Klona
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: OWFS/1Wire and Domotiga

Post by RDNZL »

I almost finished adding basic support for OWFS to DomotiGa, now only reading of counters and temp sensors work.
Will try to release it the next days.

Can you supply me with a small list of the types of 1-Wire devices you have, and their path in the owfs filesystem.

I have now 10.49023A010800/temperature (DS18S20) and 1D.3AB905000000/counters.ALL (DS2423)

Will add switching devices too, but need more info for strings and values above.
I use writing/reading to 1-wire filesystem as method, not the http calls.
Regards, Ron.
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

Re: OWFS/1Wire and Domotiga

Post by klona »

Hi RDNZL,
That's really great (The project globaly and OWFS integration).
I did some work on my side and hack into digitemp code (that's why there is still digitemp refrences) to have some first stuff running.
All devices created in Domotiga are DS1820 using digitemp interface, just to test code.
My code runs differently from digitemp, as every xxxx msec only one 1wire interface is read; From experience it's much more stable not to burst on 1wire bus with requests on every devices at the same time.
Now, I read 1820 and 2405 from OW filesystem , and use owrite to switch 2405 directly from execute in Actions. Not the best, but first step.

I intended then to do a clean new module but this is the first time I ever do a sigle line of coding so it takes a bit of time :-)
then to add feature to switch on off directly devices instead of execute code ( /opt/owfs/bin/owwrite 1F.7BD304000000/main/05.393730000000/PIO
1)

Here is what I did : (Work in progress, so really not clean...)
I use a config file coming from ls 1F*/main/10*/temperature and ls 1F*/main/05*/temperature
I have also a DS2438 for humidity and light but not focus on it for now (1F.E7F404000000/main/26.0EB3A8000000)
as you can see I have branch in my 1Wire network and this way I can handle it.

Code: Select all

OWFS.list
1F.7BD304000000/main/10.086939010800/temperature
1F.7BD304000000/main/10.208E39010800/temperature
1F.7BD304000000/main/10.B9BE39010800/temperature
1F.8FD304000000/main/10.B47E6B010800/temperature
1F.E7F404000000/main/10.37766B010800/temperature
1F.E7F404000000/main/10.5E7839010800/temperature
1F.E7F404000000/main/10.852A3A010800/temperature
1F.E7F404000000/main/10.C77D6B010800/temperature
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




'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' start timer
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PUBLIC FUNCTION Run()

' IF first run, initialization
   IF NOT OWFSinit THEN OWFS_init()

  ' start poll timer for digitemp
  tDigitemp = NEW Timer AS "tDigitemp"
 tDigitemp.Delay = Main.iDigitempPollTime * 1000 ' multiply for seconds
  tDigitemp.Start

END

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Init Array with modules
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PUBLIC FUNCTION OWFS_init()
  
  DIM OWFSFile AS File
  DIM sLine AS String
  
 OWFSFile = OPEN "/etc/OWFS.list" FOR INPUT
n = -1
i = 0 

WHILE NOT Eof(OWFSFile)
    LINE INPUT #OWFSFile, sLine
    INC N
    aOWFSline.Add(sLine)
WEND 
  
END

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' gets called at each timer event
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PUBLIC SUB tDigitemp_Timer()

  CheckDigitemp()

END

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' run digitemp to get sensor data
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PUBLIC SUB CheckDigitemp()


  DIM iReadTime AS Integer
  DIM sCommand AS String
  DIM OWFSline AS String
  DIM OWFSFile AS File
  
 DIM iDeviceId AS Integer
 DIM ID_OW AS String
 DIM Val_OW AS Variant
DIM sLine AS String 


  
' For every probe in the list

' Run Owread for each DSxxxx
'sCommand = "/home/klona/scripts/temp_read " & OWFSLine
    sCommand = "/opt/owfs/bin/owread " & aOWFSLine[i]
    SHELL sCommand TO sLine
' Get ID and value
    ID_OW = Mid$(aOWFSLine[i], 22, 2) & Mid$(aOWFSLine[i], 25, 12)
    
    SELECT CASE Left$(ID_OW, 2) 
    CASE "10"
    Val_OW = Val(sLine)
    
    CASE "05"
   Val_OW = sLine
    END SELECT 
    
        
' Find DeviceID value
    iDeviceId = Devices.Find(ID_OW, Devices.FindInterface("Digitemp"), "Dallas DS18S20")
' And update it if device found
    IF iDeviceId = 0 THEN 
      Main.WriteDebugLog("OWFS: !!!!!!!! Pas de device enregistré dans DomotiGa ID " & ID_OW)
    ELSE
      Devices.ValueUpdate(iDeviceId, Val_OW, "", "", "")
      Main.WriteDebugLog("OWFS: " & ID_OW & " valeur :" & Val_OW & " ID : " & iDeviceId)
    ENDIF 

' code to be improove here :-)    
IF i = n THEN 
i = 0 
ELSE 
INC i 
END IF 


END
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

Re: OWFS/1Wire and Domotiga

Post by klona »

I am using 2405 to switch on/off some relays, but also to detect if a wire is open or closed (different wiring of the 2405)
I discovered that you need to check the "sensed" value for the second case, but though the full bus.0 path, or you ever get 0 as value.
So I change my config file and one line in code. And it's better in case you have several adapters

File OWFS.list :
bus.0/1F.7BD304000000/main/10.086939010800/temperature
....
bus.0/1F.8FD304000000/main/05.F10532000000/sensed


code changed : ID_OW = Mid$(aOWFSLine, 28, 2) & Mid$(aOWFSLine, 31, 12)

/klona
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

Re: OWFS/1Wire and Domotiga

Post by klona »

Hi ,
It's running for 2 weeks and stable.
I need now to do a separate module for OWFS instead of hacking into Digitemp one.
I find a post where it's explain how to set up a new module but it don"t seems so easy.
After that I would like to enable siwtch on/off of the device from this code but I have today no idea at all how to achieve that..

Where are you on your side on creating the OWFS module ? I have to say it would help me a lot to have the module already created.

CU,

Klona
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: OWFS/1Wire and Domotiga

Post by RDNZL »

The module basics are done and online already.

See here for browsing the code.. domotiga.nl/browser/trunk/DomotiGa/COWF ... OWFS.class

You need to set the basedir for your owfs tree, enable it, and create a device of correct type, you can specify only the OW ID as address, and the code wil find out the family and appropriate values to fetch.
Or you can add those to the address and it will use the user specified ones.

If you have a DS2405 - addressable switch it with set the value of /PIO to switch it if you made the device switchable.
But I haven't tested that, since I have no DS2405.

Please test and let me know.
Regards, Ron.
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

Re: OWFS/1Wire and Domotiga

Post by klona »

Hi Ron,
I am really sorry. I started my own company and just had no time to follow up on this topic..
Thank you for the OWFS support.
I did some tests from a clean install.
1wire fuse tree is on /home/klona/1wire

In my case I hace tree with 3 branches so I had to put 1F.7BD304000000/main/10.086939010800/temperature as 1-Wire ID to get the value
Regarding 2405, it's a bit different as you need to write a "1" in /home/klona/1wire/bus.0/1F.8FD304000000/main/05.300332000000/PIO
I set up an Action to put my 2405 to value1=1, plus an event time * * * * *, but not working. I have to wake early tomorrow so I can not investigate further right now but will do very soon !

/klona
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

Re: OWFS/1Wire and Domotiga

Post by klona »

Hi, this is working perfectly. DS2405 is fully supported.
To make it work I only had to remove the space at the end of the device ID. probably coming from a cut&paste..

I had to pu the full path in the ID description, and in fact I prefer.

DS1820 : /1F.E7F404000000/main/10.37766B010800/temperature

DS2405 :
To switch on or off : set value1 to ON or OFF, /1F.8FD304000000/main/05.300332000000/PIO
To know the status of the switch : bus.0/bus.0/1F.8FD304000000/main/05.300332000000/sensed where 1 means OFF and 0 means ON

I also made a humidity and light sensor (it's hobbyboard hardware (http://www.hobby-boards.com/catalog/pro ... ucts_id=57 )
/1F.E7F404000000/main/26.0EB3A8000000/humidity
/1F.E7F404000000/main/26.0EB3A8000000/VAD

With the thermostat add on on last version, this would be really perfect. Thanks a lot for your hard work.

/klona
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: OWFS/1Wire and Domotiga

Post by RDNZL »

Hi, can you tell me where exactly you had to remove a space?

I will add your notes to the wiki, thanks!
Regards, Ron.
klona
Starting Member
Starting Member
Posts: 16
Joined: Fri Dec 10, 2010 9:17 am

Re: OWFS/1Wire and Domotiga

Post by klona »

Hi Ron,
in fact i think I cut&paste "/1F.8FD304000000/05.300332000000/PIO " which do not work of course. With "/1F.8FD304000000/main/05.300332000000/PIO" it's ok...
To know the status of the switch : bus.0/bus.0/1F.8FD304000000/main/05.300332000000/sensed where 1 means it is OFF and 0 means ON".
And you can change the value with /1F.8FD304000000/main/05.300332000000/PIO

I would like to do a full tutorial with ubuntu on VM, gambas install + maverick update, Domotiga install, OWFS install, then 1wire configuration in Domotiga. Something that anybody can use, even if he never touch a linux before.
Time to move guys from windows + HS to real stuff !
Unfortunately, I have no time for that right now..

Anyway, just to help already those who want to try here is my notes :


--- Install Gambas

apt-get update
apt-get gambas2

--- update gambas2
add-apt-repository ppa:madnessmike/gambas
apt-get update
System>Administration>Update Manager
Settings, other software tab : Edit PPA madnessmikde (both) : change URL to ttp://ppa.launchpad.net/madnessmike/gambas/ubuntu
System>Administration>Synaptic Package Manager : filter "gambas", tick all, then update

--- install Domotiga
cd /home/klona/domotiga_install
svn co http://svn.domotiga.nl/domotiga/trunk/ domotiga
copy folder to /home/klona/domotiga

---- install SQL server :
sudo apt-get install mysql-server
sql password to choose during install
mysql -u root -p <~/domotiga/install/domotiga.sql


---- Install OWFS :

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-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

check last version here : http://sourceforge.net/projects/owfs/files/owfs/
UPDATED : last version is p13. Just change filename.

wget http://sourceforge.net/projects/owfs/fi ... z/download
mv download owfs-2.8p7.tar.gz
tar zxpf owfs-2.8p7.tar.gz
cd owfs-2.8p7
./configure --enable-owtraffic
make && sudo make install
modprobe fuse
mkdir /home/klona/1wire

-- check Version running :
/opt/owfs/bin/owfs -V

-- Start OWFS

/opt/owfs/bin/owserver -d /dev/ttyS0 --debug [to be adapted to your hardware]
/opt/owfs/bin/owhttpd --debug -s 127.0.0.1:4304 -p 4444
/opt/owfs/bin/owfs --debug -s 127.0.0.1:4304 -m /home/klona/1wire

--- Configuring Domotiga
Setup>interfaces>1-Wire>OWFS enable
Device> Add device
enable, choose a name, device type ds1820 or 2405
interface OWFS
adress : use full relative path to the value .
you can get easly these values by browsing though web or filesystem
To get an easy list if you have separate 1Wire branches :
ls 1F*/main/10*/temperature
ls 1F*/main/05*/PIO

address Examples :
DS1820 : /1F.7BD304000000/main/10.086939010800/temperature
DS2405 : /1F.7BD304000000/main/05.393730000000/PIO
if 2405, options tab, tick "device can be switched"

other : on Temp/solar/humidity board from hobby-boards
/1F.E7F404000000/main/26.0EB3A8000000/humidity
/1F.E7F404000000/main/26.0EB3A8000000/temperature (however it's better to get temp from the DS1820 also present on the board
/1F.E7F404000000/main/26.0EB3A8000000/S3-R1-A/illuminance for the solar value




Other stuff :


--- use OWFS directly :

http://IP_Adress_Domotiga:444

or

echo "1" > /home/klona/1wire/1F.8FD304000000/main/05.300332000000/PIO
cat /home/klona/1wire/1F.8FD304000000/main/05.300332000000/PIO

cat /home/klona/1wire/1F.E7F404000000/main/10.C77D6B010800/temperature
cat /home/klona/1wire/bus.0/1F.8FD304000000/main/05.F10532000000/sensed

or

/opt/owfs/bin/owread /bus.0/1F.8FD304000000/main/05.F10532000000/sensed





----- If you want easy direct access on the SQL base

--- install SQL GUI administration
System>Administration>Synaptic Package Manager
quick search mysql
install "mysql-admin"

--- Configure SQL for remote access
Edit /etc/mysql/my.cnf
change "bind-address = 127.0.0.1" to "bind-address = 0.0.0.0"
restart mysql
Applications>Programming>Mysql Administrator
localhost, port 3306, root and the password you set during install
"User Admninistration" , right click on domouser, add host
add IP (fixed) of your windows PC
Schema Privileges tab
click your Ip on the left frame, domotiga in the left panel, select all available privilege on the right window, and click the arrow.
do not forget to apply changes

On windows PC : Install HeidiSQL
Do not forget firewall configuration on Ubuntu





---- Install Digitemp : (Not needed at all, was just for testing)

apt-get install digitemp
Initialize :
digitemp_DS9097U -s/dev/ttyS0 -i
mv .digitemprc /etc/digitemp.conf
Edit file and add %R in file
Last edited by klona on Thu Sep 08, 2011 7:07 pm, edited 2 times in total.
djrm
Starting Member
Starting Member
Posts: 8
Joined: Sat Jul 16, 2011 7:02 pm

Re: OWFS/1Wire and Domotiga

Post by djrm »

I have some 1wire temperature sensors read by an OWFS system, they are now integrated into my DomotiGa system. I had no problems with the 18S20 devices but I had to modify the file COWFS.class to enable the 18B20 devices to be readable, the edit is at line 79 in the CheckOWFS function, see snippet below.

Code: Select all

            CASE "10" ' DS18S20 - temperature sensor
              sAddress &= "/temperature"
            CASE "28" ' DS18B20 - temperature sensor
              sAddress &= "/temperature"
hth David.
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: OWFS/1Wire and Domotiga

Post by RDNZL »

Thanks, added your code to SVN repos.
Regards, Ron.
Post Reply

Return to “DomotiGa Forum”