2021-01-29 12:31:58 +01:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/DS28CM00/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
2021-10-26 14:02:32 +02:00
|
|
|
[![Arduino-lint](https://github.com/RobTillaart/DS28CM00/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DS28CM00/actions/workflows/arduino-lint.yml)
|
|
|
|
[![JSON check](https://github.com/RobTillaart/DS28CM00/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DS28CM00/actions/workflows/jsoncheck.yml)
|
2023-09-21 22:02:33 +02:00
|
|
|
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/DS28CM00.svg)](https://github.com/RobTillaart/DS28CM00/issues)
|
|
|
|
|
2021-01-29 12:31:58 +01:00
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DS28CM00/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DS28CM00.svg?maxAge=3600)](https://github.com/RobTillaart/DS28CM00/releases)
|
2023-09-21 22:02:33 +02:00
|
|
|
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/DS28CM00.svg)](https://registry.platformio.org/libraries/robtillaart/DS28CM00)
|
2021-01-29 12:31:58 +01:00
|
|
|
|
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
# DS28CM00
|
2021-01-29 12:31:58 +01:00
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
Arduino library for I2C DS28CM00 unique identification chip. \[48 bit\]
|
|
|
|
|
2021-10-26 14:02:32 +02:00
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
## Description
|
2021-01-29 12:31:58 +01:00
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
THe DS28CM00 IC has a 64 bit address consisting of one type byte, 0x50, 6 bytes unique serial and a CRC
|
|
|
|
over the previous 7 bytes. This results in an 48 bits unique ID giving 281.474.976.710.656 combinations.
|
|
|
|
If that number is not unique enough, you could use 2 or more of them with an I2C multiplexer.
|
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
Since version 0.3.0 the library supports reading only the first n bytes from the serial.
|
|
|
|
Sometimes less bytes are sufficient, and less bytes takes less time.
|
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
The DS28CM00 IC has the same addressing scheme as the better known DS18B20, except for the type byte.
|
2021-10-26 14:02:32 +02:00
|
|
|
Therefore one could use an DS18B20 as an unique ID chip in a similar way and getting a temperature sensor
|
2020-11-27 11:10:47 +01:00
|
|
|
as bonus.
|
|
|
|
|
2021-10-26 14:02:32 +02:00
|
|
|
The DS28CM00 can work in 2 modes, I2C and SMBus mode. Check datasheet for details.
|
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
#### Related
|
|
|
|
|
|
|
|
- https://github.com/RobTillaart/UUID
|
|
|
|
|
|
|
|
|
2021-01-29 12:31:58 +01:00
|
|
|
## Interface
|
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
```cpp
|
|
|
|
#include "DS28CM00.h"
|
|
|
|
```
|
2021-10-26 14:02:32 +02:00
|
|
|
|
2021-01-29 12:31:58 +01:00
|
|
|
### Constructor
|
|
|
|
|
2021-10-26 14:02:32 +02:00
|
|
|
- **DS28CM00(TwoWire \*wire = &Wire)** Constructor, with default Wire as I2C bus.
|
|
|
|
|
2021-01-29 12:31:58 +01:00
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
### Public
|
2021-10-26 14:02:32 +02:00
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
- **bool begin()** initializes I2C bus, sets default DS28CM00_I2C_MODE.
|
|
|
|
Returns false if mode cannot be set.
|
|
|
|
- **bool begin(uint8_t dataPin, uint8_t clockPin)** Constructor for ESP32, ESP8266 et al.
|
|
|
|
Returns false if mode cannot be set.
|
|
|
|
- **bool getUID(uint8_t \* buffer, uint8_t size = 8)** copy unique serial number into buffer.
|
|
|
|
Size is default 8, maximum size, size = 0 returns false.
|
|
|
|
Less unique bytes can be enough sometimes.
|
2021-10-26 14:02:32 +02:00
|
|
|
Returns false if action failed.
|
|
|
|
- **bool setI2CMode()** set DS28CM00_I2C_MODE (0x00). Returns false if action failed.
|
|
|
|
- **bool setSMBusMode()** set DS28CM00_SMBUS_MODE (0x01). Returns false if action failed.
|
|
|
|
- **bool getMode(uint8_t &mode)** returns mode set above. Returns false if action failed.
|
|
|
|
|
2021-01-29 12:31:58 +01:00
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
| value | mode |
|
|
|
|
|:-------:|:-----------------------:|
|
|
|
|
| 0x00 | DS28CM00_I2C_MODE |
|
|
|
|
| 0x01 | DS28CM00_SMBUS_MODE |
|
|
|
|
| 0xFF | DS28CM00_MODE_UNKNOWN |
|
|
|
|
|
|
|
|
|
2020-11-27 11:10:47 +01:00
|
|
|
## Operation
|
|
|
|
|
|
|
|
See examples.
|
|
|
|
|
2021-01-29 12:31:58 +01:00
|
|
|
The class is not tested extensively e.g. with ESP32 / ESP8266.
|
2021-10-26 14:02:32 +02:00
|
|
|
An example sketch for ESP32 exist and compiles. Feedback welcome.
|
|
|
|
|
|
|
|
|
|
|
|
## Future
|
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
#### Must
|
|
|
|
|
|
|
|
- test with ESP32 and other platforms. (feedback welcome).
|
|
|
|
|
|
|
|
#### Should
|
|
|
|
|
2021-12-17 13:06:20 +01:00
|
|
|
- only extend on request / bugs
|
2021-10-26 14:02:32 +02:00
|
|
|
- measure performance I2C 400 500 600 kHz ...
|
2022-11-02 11:55:17 +01:00
|
|
|
|
2023-09-21 22:02:33 +02:00
|
|
|
#### Could
|
|
|
|
|
|
|
|
- cache the serial? (costs 8 bytes) + one flag.
|
|
|
|
- If (cached filled) => faster!
|
|
|
|
|
|
|
|
#### Wont
|
2021-12-17 13:06:20 +01:00
|
|
|
|
|
|
|
- **uint8_t getError()** add error handling? - I2C; #bytes; mode; ...(too much for simple device)
|
2023-09-21 22:02:33 +02:00
|
|
|
- **bool setMode()** public? no.
|
|
|
|
|
|
|
|
## 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,
|
2021-01-29 12:31:58 +01:00
|
|
|
|