What is 1-Wire
1-Wire bus is a communication system developed by Dallas Semiconductor. It is quite similar to I2C, except for the data rate, which is lower, the costs, which are very low, and the range, which is higher. The 1-Wire protocol allows the communication among several devices produced by Dallas Semiconductors/Maxim, such as:
- temperature, humidity, and pressure sensors, thermocouples
- LCD, counters
- eeprom and rom memory, encryption (IP protection)
- identification devices (electronic keys)
The main applications of 1-Wire devices are as follows:
- Print Cartridge ID
- Medical Consumable ID
- Rack Card Calibration and Control
- Printed Circuit Board (PCB) identification and authentication
- Accessory/Peripheral Identification and Control
- IP Protection, Secure Feature Control, Clone Prevention
- Consumer electronics
- Access control
- Electronic cash
- Gaming devices
1-Wire is a half-duplex, bi-directional bus, and the communication is established among a device, the master, which controls through the bus one or more slave(s). The following figure shows the block diagram of the 1-Wire communication bus, with a detail of the master (HOST in the picture) and a generic slave.
The master device is connected to the bus through an open-drain configuration and to the supply power (Vcc, which ranges from 2.8 to 5.25 V) through the pull-up resistor R (normally its value is 4.7 Kohm). On the other hand, the slave receives all the power it needs from the bus, which is the only wire present. As visible in the above figure, the capacitor inside each slave (usually it is a 800 pF capacitor) will be charged when the bus is in the idle state (corresponding to a high or positive level of the 1-Wire bus). When, instead, the bus is at a low level, that is when the communication between master and slave is taking place, the slave uses the energy stored in the capacitor to power itself. Differently from other bus protocols such I2C or SPI, the 1-Wire bus requires that each slave be physically connected to the bus: if a slave is disconnected, it cannot be operative any longer, thus entering a reset state; when it is connected again to the bus, it wakes up and, receiving the supply power directly from the bus, can declare its presence to the bus controller (the master device).
The principal advantages of the 1-Wire technology are:
- Inexpensive devices, simple wiring, parasitic power
- Unique addresses, individually addressable
- USB, serial and i2c adapters
- Mature technology, consulting and aftermarket support
- iButton steel sealed devices
- Single Contact Sufficient for Control and Operation
- Unique ID Factory-Lasered in Each Device
- Power Derived from Signal Bus ("Parasitically Powered")
- Multidrop Capable: Supports Multiple Devices on Single Line
- Exceptional ESD Performance
- IP Protection, Secure Feature Control, Clone Prevention
Each slave connected to a 1-Wire bus has a unique and unalterable serial number: through this ID, it can be univocally selected and addressed by the master device. The 64-bit ROM number is written during the manufacturing process and it includes the following fields: an 8-bit Family Code which identifies the slave type and functionality (up to 256 slave types are supported), a 48-bit Serial Number, an 8-bit CRC. No clock is necessary in 1-Wire bus, since time synchronization is performed by the slaves on the falling edge of the bus wire controlled by the master. There are two kinds of data rate: standard, with a transmission speed up to about 16 Kbps, and overdrive, which increases the speed by a factor of 10.
The first operation to be executed by an application on the 1-Wire bus is the selection of the slave device. Once a slave has been selected, the master sends specific commands on the bus to write data to or read data from the slave. The reset command is accepted by all the slaves connected to the bus.
OWFS: a nice open-source project related to 1-Wire
Owfs (acronym of One Wire File System) is a project created by Paul H. Alfille and The Owfs Team (Owfs homepage: http://owfs.sourceforge.net/). It is an open-source project developed under Linux operating system with the following purpose: access any 1-Wire device as if it were a regular file belonging to the file system. So, to perform a read operation from all 1-Wire temperature sensors connected to the bus, a shell command like "cat */temperature" would be enough. For instance, the collection of temperature sensors above are all on one bus, individually addressable, and will reconfigure on the fly as items are added or removed. OWFS is an original and useful way to work and experiment the powerful 1-Wire devices of Dallas Semiconductor/Maxim. Moreover, shell commands are powerful and can be organized in script files to be executed (also automatically or on a batch basis) during the development, testing, and validation phases of a 1-wire application.
The main characteristics of Owfs are:
- Filesystem access
- Web access (through the application owhttpd)
- Remote network access (through the application owserver)
- Direct language support for perl, python, php, tcl, C (libow, ownet)
- Bootable CD
- Support for many processors and OS
- Free under GPL license
Universal 1-Wire COM Port Adapter
Dallas Semiconductor-Maxim offers an interesting tool (DS9097U) for 1-Wire testing and debugging. It connects to the RS232 serial port of a PC (both DB-9 and DB-25 connectors are supported) and, together with a TMEX software driver, allows reading and writing on 1-Wire devices which are connected through a RJ-11 port; both regular and overdrive data rates can be used. With the DB-9 connector it is possible to communicate only with non-eeprom 1-Wire devices, whereas the DB-25 connector allows also to write on 1-Wire eeprom even though an external power supply is requested in that case. The DS9097U adapter is based on the DS2480B Serial 1-Wire Line Driver chip.
Drivers can be freely downloaded from: http://www.ibutton.com/software/tmex/index.html.
Read the Italian version: OWFS: un file system Linux per i dispositivi 1-Wire