.. | ||
.github | ||
examples | ||
test | ||
.arduino-ci.yml | ||
CHANGELOG.md | ||
DS2401.h | ||
keywords.txt | ||
library.json | ||
library.properties | ||
LICENSE | ||
README.md |
DS2401
Library for the DS2401 1-wire unique identification chip.
Description
The DS2401 is an ID chip that uses the oneWire (1-Wire) protocol. In fact it just returns its address as these are (quite) unique.
Every oneWire device has a unique 48 bit number which together with the device family byte and an 8 bits CRC forms 8 byte unique code. The family byte adds to the uniqueness however the CRC does not. Although the CRC does not add to the uniqueness, it is taken into the UID as it allows to check the other 7 bytes for integrity.
As there are at least 8 device types / families known, there are thus at least 51 bits of uniqueness. This gives in total more than 10^15 bit patterns, which should be sufficient for most applications.
The library is meant for DS2401 chips but allows all oneWire devices to be used as an unique ID (UID). This implies that functionality like e.g. temperature sensing is not available with this library.
Known family bytes, there are many other 1-Wire devices with unknown family.
byte | device | description |
---|---|---|
0x01 | DS2401 | UID device |
0x26 | DS2438 | Battery monitor |
0x2D | DS2807 | EEPROM |
0x22 | DS1822 | thermometer |
0x3B | DS1825 | thermometer |
0x28 | DS18B20 | thermometer |
0x10 | DS18S20 | thermometer |
0x42 | DS28EA00 | thermometer |
Related
- https://github.com/RobTillaart/DS2401
- https://github.com/RobTillaart/DS28CM00 (I2C)
- https://github.com/RobTillaart/UUID
- https://github.com/RobTillaart/DS18B20_INT
- https://github.com/RobTillaart/DS18B20_RT
- https://github.com/milesburton/Arduino-Temperature-Control-Library
Interface
#include "DS2401.h"
Core
This DS2401 library supports only one device per pin, and no parasite mode. The class supports getting an UID and compare an UID.
- DS2401(OneWire * ow) constructor needs a reference to OneWire object.
- bool begin() resets oneWire and search fot the address. Returns true if address / UID of the device is found.
- void getUID(uint8_t * buffer) copies the found UID in begin() to buffer.
- bool compareUID(uint8_t * buffer) compares the buffer with the internal UID. Returns true if they are identical.
Operation
This library supports only one DS2401 per Arduino / MCU pin.
// BOTTOM VIEW
//
// PIN MEANING
// /---+
// / o | 1 GND
// | o | 2 DATA
// \ o | 3 VCC
// \---+
(always check datasheet)
Connect a pull-up resistor 4.7 KΩ between pin3 and pin2. When the wires are longer this resistor needs to be smaller.
Future
Must
- Improve documentation.
Should
- example of compare function.
- test with different hardware.
Could
- performance test. (mainly fetching)
- use only 48 unique bits instead of all 64?
- add getUID48() and compareUID48()
Wont
- get any subset of the 8 bytes? => user can do this.
Support
If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.
Thank you,