|Sunday, 30-Apr-2017 00:09:27 BST|
1-wire is defined as a single-wire (plus ground) communications protocol. It was developed by Dallas Semiconductors to provide a convenient way of adding sensors to a single bus complete with integrated power source. I first came across this technology when I was looking for a weather station which would integrate with Homeseer (My home automation software). The basic Dallas 1-wire weather station provided wind speed, direction and temperature which connected via a special adaptor to a spare serial port on the PC. I soon found out that additional devices were available including rain gauges, barometers, humidity & lightning, all converted to 1-wire for use on a single bus. All sensors in my house use a 1-wire network.
Each 1-wire device has a unique 16 bit address. When connected to a 1-wire bus, it is polled to obtain data from the sensor. This polling is derived normally from the interface between the bus and the PC.
Depending on the sensor, there are two ways to power a 1-wire device:
In parasitic power mode, the 5V required to supply the device is obtained from the DQ (data) wire. In this configuration, only two wires are required. It is important that when using this mode, you should connect the sensor's Vdd pin to its ground pin.
In external power mode, a 3rd wire is used to supply 5V directly to each sensor and is recommended for large networks.
Two of the most used 1-wire devices in home automation are the DS1820 Family for temperature and the DS2405 Family for input/outputs.
The DS1820 is the most common 1-wire temperature sensor used for home automation. Maxim (Dallas semiconductors) have recently stopped manufacture of this device but the DS18S20 is a direct replacement with better stability & accuracy. This also is becoming obsolete, being replaced with the DS18B20 which has programmable 9-12 bit output data resolution.
This is a programmable input/output device which has limitless possibilities for home automation. This can be polled to detect something like a contact change or with minimal extra components, to drive a relay.
Data sheets for these two devices are available from the document library on my home automation server.
There are many more sensors available but are outside the scope of this article.
When running a 1-wire bus, Dallas recommend that you use unshielded CAT5 cabling for the bus. However if you have few sensors and short runs, telephone cable will work just as well. Do not use shielded cable as the capacitance increase will upset the network.
If you intend to have a large 1-wire network, it is important that you design the network correctly, otherwise you will have problems with timing/reflection issues and loss of data. For very small networks, it is possible to connect each sensor in a star or radial arrangement. This means that each sensor is connected via its own cable back to a central point and then connected to the 1-wire to serial adaptor. However, it is strongly recommend that you connect each sensor to a single continuous cable which loops from sensor to sensor in turn (daisy chain). This will reduce potential mis-reads due to reflections in the cable. Each sensor should have a maximum of 50mm (2") of cable connected off the main highway. Even using this method, connecting more than 10-15 sensors will still cause problems due to loading of the data bus. To minimise this effect, always place a 100-120 ohm resistor in the data leg of each sensor before connecting to the network. The choice of 1-wire to PC adaptors will also affect the reliability of the network.
Obviously we need to read the 1-wire bus and convert this data for the PC. The most common serial adaptor is the DS9097U which is all that is necessary for small networks. For more complex and reliable communications, a replacement for the 9097 is a device called THE LINK (or Link45, Link45i). This uses an advanced bus interface and intelligent algorithms to make 1-Wire communications more reliable at short and long distances. Another seral adaptor is the HA7E manfactured by Embedded data systems.
As serial ports are now not so popular with motherboard manufacturers, the DS9490R addresses this problem by providing a USB interface or the S4 USB to 1-Wire interface.
Other interfaces include the HA7Net which provides a Ethernet to 1-Wire interface
All these devices provide an RJ11/12 or RJ45 sockets for connection to the 1-wire bus.
RJ11/RJ12 and RJ45 connectors are normally used for 1-wire installations for simplicity and looping between sensors.
For a RJ11 socket, Pin 2 is used for the DQ (data) and pin 3 as the return or ground. For some commercial 1-wire devices, the 5V supply is normally connected to Pin 1 and supply ground to Pin 4.
For a RJ12 socket, Pin 3 is used for the DQ (data) and pin 4 as the return or ground. As per the RJ11, the 5V supply is normally connected to Pin 2 and supply ground to Pin 5.
These pins are actually in the same positions (so you can plug a RJ11 in a RJ12 socket) for both connectors but the RJ12 has six pins whereas the RJ11 only has four.
RJ45 (standard network connectors) are the latest method to connect 1-wire devices:
Pin 1 (White/Green) - Power return or ground
Pin 2 (Green) - +5V
Pin 3 (White/Orange) - Power return or ground
Pin 4 (Blue) - DQ (data)
Pin 5 (White/Blue) - 1-Wire return or ground
Pin 6 (Orange) - No Connection
Pin 7 (White/Brown) +12V to +24V unregulated supply
Pin 8 (Brown) - Power return or ground
(Cable colours assume the T568A network wiring standard)
One of the problems with these adaptors is that the critical timing required by the bus is derived by the PC drivers and can put heavy load on the CPU. As an alternative, Midon design have produced the TEMP08 which takes the load off the PC by providing all the timing within its hardware and just passing the information to the serial port when required. They also produce a LOG08 which has built in logging facilities (even when the PC is off) BUT does not support the reading of the DS2405 switches.
If you only wish to use 1-wire temperature sensors, then Quaser electronics produce a kit that supports four DS18S20 sensors for interface to a serial port. This company will also supply the DS18S20 sensors if required.
(This section describes interfacing with Homeseer's Home automation software only)
Providing you have a DS9097U, 'THE LINK' or a DS9490R, the easiest way to check your network is to download the ibutton viewer and drivers. This will give you visual indication that all sensors have been detected and provide any necessary data readings from the sensor. If you only have a TEMP08 then you can check 1-wire functionality using a terminal program.
There are several software solutions available for Homeseer users to read the 1-wire data. Michael McSharry has written the McsTemperature plugin which can read from all hardware devices mentioned. This is available via the Homeseer updater.
He has also written a xAP plugin for use with a DS9097U/DS9490 which can integrate with any xAP application or plugin. This includes Homeseer, Misterhouse etc or standalone via xAP desktop.
UltraJones has written Ultra1Wire plugin for Homeseer. This interfaces to the HA7E, HA7Net adnd Temp08 interfaces.
There is one Homeseer plugin's available for the Quasar 3145 logger from pjcPlugins
The TEMP08/LOG08 can easily be read from a script available at Midon Design's web site. As a simple test, this Homeseer script will display in the homeseer log, all data from the hardware:
You need to put this script in the startup.txt script. Make sure you change the port number to suit your installation:
'*****Set Com port 8 open for TEMP08*****
if e<> "" then
hs.writelog "Error opening COM 8 ",e
hs.writelog "COM 8 ","TEMP08 setup complete"
Next create a script called 'TEMP08.txt' , copy the code below and save it in the scripts folder:
hs.writelog "TEMP08 RECEIVED",data
Before this script will work, please be aware that you need to set up the TEMP08 using a terminal program and the command set that comes with the unit. This includes the polling duration and device detection.
Every time the TEMP08 polls itself, the resulting data is passed to the TEMP08.txt which is displayed in the Homeseer log.
The variable 'data' can be parsed to obtain values for Homeseer to use. So for the TEMP08 built in 1-wire temperature sensor, you could expand the script as follows:
'*****Get temperature of TEMP08 sensor*****
if hs.StringItem(data,1,"[")="Temp #01" then
hs.setdevicestring "z47","TEMP08 Temperature: " & Temperature1 & " șC ",true
'hs.writelog "TEMP08 RECEIVED",data
Please note that if you have set the TEMP08 to Fahrenheit then the 'C' highlighted in white should be changed to 'F'
Finally, if you require a 1-wire weather station, then Brian Hamilton's weather display software allows all sensors to be passed to Homeseer via the supplied scripts. The program supports an additional 10 1-wire temperature devices in addition to all the normal 1-wire weather sensors.
Marc Merlins 1-wire - Complex 1-wire setup with temperature monitoring & graphing using Misterhouse
TMEX drivers & 1-wire viewer - 1-wire drivers with iButton Viewer (self-extracting executable).
1-Wire SDK for M$ Windows - SDK for Microsoft Windows
1-wire API for JAVA - API for Java Virtual Machine
pjcPlugins - Phil's Quaser 3145 plugin.
Ultra1Wire - Forum discussion on this Homeseer plugin
LogTemp - Free application for Logging & Charting Temperature/Humidity
Quasar Electronics - Supplier of the 3145 temperature logger kit
Midon Design - Manufacturer & supplier of the TEMP/LOG08.
Sheepwalk Electronics - Small home based business in Yorkshire UK selling 1-Wire products
AAGElectronica - Manufacturer & supplier of 1-wire products and port converters.
Weather Display - Weather Display software.
xAP 1-Wire Plugin - xAP 1-Wire Plugin software.
xAP Desktop - xAP Desktop software.
hobby-boards.com - Cheap source of 1-wire hobbist boards in the USA.
'The LINK' - PDF datasheet for this device.
Embedded Data Systems - Manufacturer of the HA7E and HA7NET
Elbatech.com - Manufacturers of the S4 USB to 1-wire interface
Text © Jon00 2004 - Last updated October 2012