How To - 1-Wire sensors
This article will explain how to integrate 1-Wire sensors into OpenRemote 2.0 system.
You will need following to finish the integration:
- 1-Wire sensors + controller working on your system
- owserver from OWFS project configured to work with your network
- OpenRemote Online Designer account
- OpenRemote controller that supports 1-Wire protocol

To avoid confusion, whenever OWFS will be typed in all upper case, it refers to OWFS as whole project and suite of programs (such as owfs, owserver, owhttpd).
Every time owfs or owserver will be typed in italic, it refers to specific program.
1-Wire hardware
Current implementation of 1-Wire support in OpenRemote allows only read access to 1-Wire network. In general, if you can read value from 1-Wire device via OWFS, you can access this value via sensor in OpenRemote. In future it is expected that write functionality will be provided. This will, for example, allow users to control external system via relays.
owserver and owfs
Because OpenRemote uses owserver to communicate with physical 1-wire devices, we need to have this part configured and working first. You can find both the software and guide how to configure owfs/owserver on the homepage of the OWFS project.
Most typical usage pattern of OWFS is to use it as a filesystem. This is very nice and useful access method to 1-wire that provide easy way to test all the devices. In the examples you can find on the net, you will often see owfs connecting directly to your 1-wire hardware. This is fine for initial tests of 1-wire configuration, but for later use, it is preferred to use owserver as an intermediate layer. This will allow us to "share" 1-wire network access between many different applications (one of them will be our OpenRemote Controller and other still may be owfs or owhttpd). As you will find on OWFS project page, parameters for owfs and owserver are almost the same, so after you find best settings for your 1-wire network with owfs, you can use the same settings with owserver. This tutorial will not go into details about how to install OWFS on your system, but you can find plenty of information on links you can find at the bottom of this tutorial.
Let's assume you successfully installed OWFS and know how to connect to 1-Wire hardware.
First, we will start owserver:
This will start owserver that will access 1-wire controller on serial port /dev/ttyUSB0 and owserver will listen on port 4304 (this is default port, you can change it to whatever you need).
If your 1-wire network contains more sensors, it may be convenient to assign aliases to your devices. To do this, create new file that will contain mapping between device address and alias, for example:
(Optional) If you want to still have access to 1-Wire via filesystem (owfs), you can start it this way:
"-s localhost:4304" is important here, since instead of direct access to hardwire, owfs is instructed to access 1-Wire via owserver that we started on port 4304.
(Optional) It may be convinient to start owhttpd that allows you to browse your 1-wire network in web browser:
In this example, owhttpd will listen on port 18888.

Before you proceed to OpenRemote configuration, check if you can access your 1-wire devices via owfs or owhttpd. This way, you can verify paths to devices and attributes of these devices.
OpenRemote Online Designer
Now, let's create some screen in OpenRemote Online Designer. Online Designer already supports 1-Wire protocol, so all you need is account to log into it.
Our task will be to access temperature and humidity sensor values.
Create new Device
In "Building Modeler", create new device (New>New Device)

Create commands
Still in "Building Modeler", select device that was created in step 1 and click on New>New Command
Specify name and select "1-Wire Protocol" as protocol.

1-Wire specific settings:
- Hostname - ip address or hostname of owserver
- Port - port where owserver is listening
- Device Address - path to target 1-Wire device. For example, if we can access our device via owfs as /var/1-Wire/OW1_Kitchen/ (where owfs mountpoint is set to /var/1-Wire) then path to our device is "/OW1_Kitchen"
- Sensor attribute - name of attribute of 1-Wire device that we want to read. For thermometer, value is most usually "temperature", for humidity sensors it is "humidity".
- Minimum refresh time - to avoid hammering of the 1-Wire network with too many requests, value is cached as long as specified in this field.

Sensor attribute may point to any filename that you can see in owfs. For example, thermometer DS18B20 has (among others) following files in its directory: "temperature","temperature9","temperature10","temperature11",... you can use any of these as source for your command/sensor. You can find meaning of these files in OWFS documentation for DS18B20. Similarly, you can find there documentation for other device types.

Minimum refresh time is ignored in case when there is no correct cached value. If cached value is expired (older than specified time) and read from owserver fails, old value with "!" attached is stored but on next request, controller will retry read from owserver.
Since we are going to configure second command that will read humidity, click on "Submit and continue". This will store our current settings, but preserver filled-in values. We can then easily update settings without the need to re-enter all the values again.

In this command, we access device "OW2_Exterior" and it's attribute "humidity".
Since we are not going to add any other command, click on "Submit".
Create sensors
Now we will create sensor, that will use previously created commands to access values of our 1-Wire devices.
Click on "New>New Sensor"

We will call our first sensor "KitchenTemperature". Select command "GetKitchenTemperature" and choose Type "range" and specify min and max temperature for this sensor.

At this moment, type is ignored and min/max values are not taken into account.
When all values are entered, click on "Submit" to save sensor.
Again, click on "New>New Sensor" to create sensor for exterior humidity.

Name of second sensor will be "KitchenTemperature". Command to get value from 1-Wire network is set to be "GetExteriorHumidity".
Type of sensor is range. Since this is relative humidity, it can be any value between 0 and 100 (%).
Submit this dialog to save the sensor.
Use sensor in UI Designer
Now we have configured everything necessary to use sensor value in UI Designer. To display sensor value, you can create Label and select sensor "KitchenTemperature" or "ExteriorHumidity".
Useful links
Following links may be useful for 1-Wire beginners:
OWFS Project homepage
1-Wire and Ubuntu
(If you have any article that helped YOU to get 1-Wire up and running, please share it with others!)
Comments (12)
Feb 28
Alex Dom says:
Thank you guys!! I can't wait till write functionality will be provided.. But ap...Thank you guys!! I can't wait till write functionality will be provided.. But approximately.. Is this suppose to happen in the nearest future or fare
?
Feb 29
Marcus Redeker says:
Should be doable What exactly do you want to control?Should be doable
What exactly do you want to control?
May 14
Alex Dom says:
I want to control everything!) First of all my kitchen lights using DS2413 1-wir...I want to control everything!
) First of all my kitchen lights using DS2413 1-wire double-chanel switch
May 14
Alex Dom says:
What does it mean: "At the moment, "official" OpenRemote Controller does not su...What does it mean:
"At the moment, "official" OpenRemote Controller does not support 1-Wire protocol. To get 1-Wire protocol support, download this snapshot..."
I've downloaded the latest OpenRemote revision. Should I download and install the snapshot mentioned in this manual in addition? Or 1-wire support is already included in the latest revision of OpenRemote?
The reason why I'm asking is.. I can't read the temperature from my DS18B20. Shows up in Web-panel with "N/A". However it sows up in OWFS. And I did it exactly as it is described in the above manual.
May 14
Alex Dom says:
"Device Address - path to target 1-Wire device. For example, if we can access ou..."Device Address - path to target 1-Wire device. For example, if we can access our device via owfs as /var/1-Wire/OW1_Kitchen/ (where owfs mountpoint is set to /var/1-Wire) then path to our device is "/OW1_Kitchen""
What if my mount point for OWFS is different, for example /mnt/1-wire/ ?
May 14
Juha Lindfors says:
No need for the snapshot anymore, it is included in the released distributable. ...No need for the snapshot anymore, it is included in the released distributable.
I've deleted that section of this page.
May 15
Alex Dom says:
Thanks! Do you know, what to do and how to read the data from the sensors, if...Thanks!
Do you know, what to do and how to read the data from the sensors, if my mount point for OWFS is different, for example /mnt/1-wire/ ? Not the /var/1-Wire , as it said above?
May 15
Marcus Redeker says:
No need for owfs. OpenRemote is connecting directly to owserver. Path to your de...No need for owfs. OpenRemote is connecting directly to owserver.
Path to your device would only be "/OW1_Kitchen".
May 15
Alex Dom says:
Hm...:-\ You see. I have my sensors(DS18B20) visible within the OWFS, but the t...Hm...:-\
You see. I have my sensors(DS18B20) visible within the OWFS, but the temperatures appear as N/A in iPhone or Web-panel after I read from them the way described in here.
The only difference is I don't assign the aliases to my sensors the way it described here above. So my device address looks the way like: "\28.25E9E3010000". I don't think it could occur any issues.
The only thing I'm still hesitating is: "Hostname - ip address or hostname of owserver". Is this address complies to the IP of my server(mainly Synology DS). Is this local address or 127.0.0.1?
May 15
Marcus Redeker says:
Do you have OWSERVER running? OpenRemote does not work with OWFS. Owfs is only o...Do you have OWSERVER running? OpenRemote does not work with OWFS. Owfs is only optional and has to be configured to connect to owserver.
If OpenRemote controller and owserver run on the same machine you can use localhost otherwise host is the ip of the machine where owserver is running. The port is the one given with -p parameter when starting owserver.
No alias is fine, but use a "/" for the device address.
By the way, the current implementation supports a toggle for 1-wire switches. If you create a command with "sensor attribute = PIO.A" you should be able to assign this command to a button and use that to toggle the switch.
We should eventually move this discussion to the forum
May 15
Alex Dom says:
Ok.. I did it already. Look at the forum article: 1-Wire and OpenRemote. But y...Ok.. I did it already
. Look at the forum article: 1-Wire and OpenRemote.
But you should have mentioned in this article that OWFS is not to be run to avoid the interaction with OpenRemote.. Because it somehow contradicts the information above.
May 15
Alex Dom says:
For the discussion continuation look the forum topic 1-Wire and OpenRemoteFor the discussion continuation look the forum topic 1-Wire and OpenRemote