tpetar
Advanced Member level 7
- Joined
- Sep 27, 2010
- Messages
- 6,417
- Helped
- 1,713
- Reputation
- 3,456
- Reaction score
- 1,673
- Trophy points
- 1,393
- Location
- Pancevo-Belgrade, Serbia
- Activity points
- 37,363
OneWire Library 2.0
OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy
Version 2.0 fixes bugs in the search function and interrupt safety.
I recommend you use OneWire 2, a spiritual successor to the original OneWire library. PJRC has developed this library to fix many of the original bugs found in OneWire. If you find OneWire to be unreliable I would highly recommend this drop-in replacement.
Basic Usage
OneWire myWire(pin)
Create the OneWire object, using a specific pin. Even though you can connect many 1 wire devices to the same pin, if you have a large number, smaller groups each on their own pin can help isolate wiring problems. You can create multiple OneWire objects, one for each pin.
myWire.search(addrArray)
Search for the next device. The addrArray is an 8 byte array. If a device is found, addrArray is filled with the device's address and true is returned. If no more devices are found, false is returned.
myWire.reset_search()
Begin a new search. The next use of search will begin at the first device.
myWire.reset()
Reset the 1-wire bus. Usually this is needed before communicating with any device.
myWire.select(addrArray)
Select a device based on its address. After a reset, this is needed to choose which device you will use, and then all communication will be with that device, until another reset.
myWire.skip()
Skip the device selection. This only works if you have a single device, but you can avoid searching and use this to immediatly access your device.
myWire.write(num);
Write a byte.
myWire.write(num, 1);
Write a byte, and leave power applied to the 1 wire bus.
myWire.read()
Read a byte.
myWire.crc8(dataArray, length)
Compute a CRC check on an array of data.
OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy
Version 2.0 fixes bugs in the search function and interrupt safety.
I recommend you use OneWire 2, a spiritual successor to the original OneWire library. PJRC has developed this library to fix many of the original bugs found in OneWire. If you find OneWire to be unreliable I would highly recommend this drop-in replacement.
Basic Usage
OneWire myWire(pin)
Create the OneWire object, using a specific pin. Even though you can connect many 1 wire devices to the same pin, if you have a large number, smaller groups each on their own pin can help isolate wiring problems. You can create multiple OneWire objects, one for each pin.
myWire.search(addrArray)
Search for the next device. The addrArray is an 8 byte array. If a device is found, addrArray is filled with the device's address and true is returned. If no more devices are found, false is returned.
myWire.reset_search()
Begin a new search. The next use of search will begin at the first device.
myWire.reset()
Reset the 1-wire bus. Usually this is needed before communicating with any device.
myWire.select(addrArray)
Select a device based on its address. After a reset, this is needed to choose which device you will use, and then all communication will be with that device, until another reset.
myWire.skip()
Skip the device selection. This only works if you have a single device, but you can avoid searching and use this to immediatly access your device.
myWire.write(num);
Write a byte.
myWire.write(num, 1);
Write a byte, and leave power applied to the 1 wire bus.
myWire.read()
Read a byte.
myWire.crc8(dataArray, length)
Compute a CRC check on an array of data.