PDA

View Full Version : Support for Dallas 1-wire devices?


imjustabrian
04-04-2009, 10:06 PM
Has anyone yet looked into connecting to Dallas Semiconductor's 1-Wire and iButton parts?

They have some interesting sense (temp and humidity mostly), ID, memory and other modules that are useful for hobbyist and data logging projects. 1-wire sends and receives on a single signal line, and many devices can connect to the same bus because they're uniquely addressable. They're also hot-pluggable and support auto-discovery, so you can add sensors on the fly without needing to configure them.
General information here:
http://en.wikipedia.org/wiki/1-Wire
http://www.maxim-ic.com/products/1-wire/index.cfm?CMP=WP-7

(Maybe the neatest device is the 1-wire Weather Station, which was developed by Dallas as a tech demonstrator platform and is now available through AAG Electronica of Mexico for about $100:
http://www.aag.com.mx/aagusa/index1.html )

The protocol is similar to I2C, so I would think it might require some fast custom-made C functions in order to work on the SNAPpy modules. There are already working libraries like pyonewire (http://code.google.com/p/pyonewire ) but these use a USB-to-1wire converter on a PC (this does more than just level conversion, it's a protocol converter too); on an embedded device it makes more sense to wire a GPIO pin directly to the 1-wire data line, so pyonewire probably won't work as-is.

I'd really like to see these devices supported, but I don't code in C myself :/
I might be able to help modify the I2C functions if I had the source, or I can also help test code for others as we have several 1wire devices on hand. Let me (or Synapse) know if you're interested. Thanks!

Brian

mgenti
04-06-2009, 11:19 AM
We've only had 1 or 2 other people talk about using 1-Wire devices. Since we don't currently have builtin support for this, the best option would be to buy a I2C device that can talk 1-Wire. Check out this post for more info.

kactamus
08-03-2011, 07:32 PM
I found this I2C to 1Wire convertor on http://www.maxim-ic.com
The DS2482 has 3 versions, i.e 1 Channel, 1Channel with sleep and 8 Channel version.
See here for the 1 Channel version. I reckon it'll do the trick.
http://www.maxim-ic.com/datasheet/index.mvp/id/4382
Kac

John Payson
09-02-2011, 12:49 PM
If you have a UART that isn't being used for anything else, and it can be configured for 115,200 baud, it may be possible to use it--albeit a little slowly--for one-wire communication. Wire the ibutton device to the Rx pin, and connect the Tx pin via ~1K resistor.

To reset the iButton, set it for 9600 baud, output a zero byte, and wait for a zero byte to be received. Then set the UART to 115,200 baud.

To output a "1" data bit, send a 0xFF; expect and ignore one received byte.

To output a "0" data bit, send a 0x00; expect and ignore one received byte.

To read one bit, send a 0xFF; expect and receive one byte. Bit 0 of the received byte will be the data.

To expedite processing, it may be possible for all stages of communication except the match-ROM command, to send out eight 0xFF/0x00 bytes as a group and wait for eight bytes in response. The match-ROM algorithm could with a little care send/receive most bytes in groups of three (send two 0xFF bytes to read two bits from the bus, decide whether to output a one or zero, then for each subsequent bit except the last, either send three 0xFF's, or a 0x00 followed by two 0xFF. For the last bit, just send a 0x00 or 0xFF.