0.2.3 DS28CM00

This commit is contained in:
rob tillaart 2021-10-26 14:02:32 +02:00
parent dfbc898484
commit efc8668042
9 changed files with 87 additions and 34 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -2,14 +2,16 @@
// FILE: DS28CM00.cpp
// AUTHOR: Rob Tillaart
// PURPOSE: Library for the DS28CM00 unique identification chip.
// VERSION: 0.2.2
// VERSION: 0.2.3
// URL: https://github.com/RobTillaart/DS28CM00
//
// HISTORY:
// 0.1.0 2017-07-15 initial version
// 0.2.0 2020-04-11 refactor, #pragma once, ESP support, multiple Wire, ESP support (start)
// 0.2.1 2020-06-07 fix library.json
// 0.2.2 2020-12-20 add arduino-CI + unit test
// HISTORY:
// 0.1.0 2017-07-15 initial version
// 0.2.0 2020-04-11 refactor, #pragma once, ESP support, multiple Wire, ESP support (start)
// 0.2.1 2020-06-07 fix library.json
// 0.2.2 2020-12-20 add arduino-CI + unit test
// 0.2.3 2021-10-26 update build-CI + default Wire in constructor.
#include "DS28CM00.h"
@ -23,6 +25,7 @@ DS28CM00::DS28CM00(TwoWire *wire)
_wire = wire;
}
#if defined(ESP8266) || defined(ESP32)
DS28CM00::DS28CM00(const uint8_t dataPin, const uint8_t clockPin)
{
@ -85,4 +88,5 @@ bool DS28CM00::getUID(uint8_t *buffer)
return true;
}
// -- END OF FILE --

View File

@ -3,7 +3,7 @@
// FILE: DS28CM00.h
// AUTHOR: Rob Tillaart
// PURPOSE: Library for the DS28CM00 unique identification chip.
// VERSION: 0.2.2
// VERSION: 0.2.3
// HISTORY: See DS28CM00.cpp
// URL: https://github.com/RobTillaart/DS28CM00
//
@ -11,15 +11,17 @@
#include "Arduino.h"
#include "Wire.h"
#define DS28CM00_LIB_VERSION "0.2.2"
#define DS28CM00_I2C_MODE 0x00
#define DS28CM00_SMBUS_MODE 0x01
#define DS28CM00_MODE_UNKNOWN 0xFF
#define DS28CM00_LIB_VERSION (F("0.2.3"))
#define DS28CM00_I2C_MODE 0x00
#define DS28CM00_SMBUS_MODE 0x01
#define DS28CM00_MODE_UNKNOWN 0xFF
class DS28CM00
{
public:
explicit DS28CM00(TwoWire *wire);
explicit DS28CM00(TwoWire *wire = &Wire);
#if defined(ESP8266) || defined(ESP32)
explicit DS28CM00(const uint8_t dataPin, const uint8_t clockPin);
#endif

View File

@ -1,5 +1,7 @@
[![Arduino CI](https://github.com/RobTillaart/DS28CM00/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![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)
[![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)
@ -8,6 +10,7 @@
Arduino library for I2C DS28CM00 unique identification chip. \[48 bit\]
## Description
THe DS28CM00 IC has a 64 bit address consisting of one type byte, 0x50, 6 bytes unique serial and a CRC
@ -15,29 +18,47 @@ over the previous 7 bytes. This results in an 48 bits unique ID giving 281.474.9
If that number is not unique enough, you could use 2 or more of them with an I2C multiplexer.
The DS28CM00 IC has the same addressing scheme as the better known DS18B20, except for the type byte.
Therefor one could use an DS18B20 as an unique ID chip in a similar way and getting a temperature sensor
Therefore one could use an DS18B20 as an unique ID chip in a similar way and getting a temperature sensor
as bonus.
The DS28CM00 can work in 2 modes, I2C and SMBus mode. check datasheet for details.
The DS28CM00 can work in 2 modes, I2C and SMBus mode. Check datasheet for details.
## Interface
### Constructor
- **DS28CM00(TwoWire \*wire)**
- **DS28CM00(dataPin, clockPin)** ESP32, ESP8266
- **DS28CM00(TwoWire \*wire = &Wire)** Constructor, with default Wire as I2C bus.
- **DS28CM00(uint8_t dataPin, uint8_t clockPin)** Constructor for ESP32, ESP8266 et al.
### public
- **void begin()** initializes I2C bus, default DS28CM00_I2C_MODE
- **void begin()** initializes I2C bus, sets default DS28CM00_I2C_MODE.
- **bool getUID(uint8_t \*serial)** get unique 8 bytes serial number or error.
- **bool setI2CMode()** set DS28CM00_I2C_MODE (0x00)
- **bool setSMBusMode()** set DS28CM00_SMBUS_MODE (0x01)
- **bool getMode(uint8_t &mode)** returns mode set above
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.
## Operation
See examples.
The class is not tested extensively e.g. with ESP32 / ESP8266.
An example sketch for ESP32 exist and compiles. (feedback welcome)
An example sketch for ESP32 exist and compiles. Feedback welcome.
## Future
- **bool getUID4()** to read only 4 bytes to improve performance. Possible?
- **bool getUID(4)** number of bytes as parameter?
- **uint8_t getError()** add error handling? - I2C; #bytes; mode; ...
- measure performance I2C 400 500 600 kHz ...
- cache the serial? (costs 8 bytes)
- **bool isConnected()** check in begin.
- **bool begin()** return type upgrade.
- **uint8_t getMode()** if not connected error ..

View File

@ -5,3 +5,7 @@ compile:
# - leonardo
# - due
# - zero
# - m4
- esp32
# - esp8266
# - mega2560

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/DS28CM00.git"
},
"version": "0.2.2",
"version": "0.2.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"

View File

@ -1,5 +1,5 @@
name=DS28CM00
version=0.2.2
version=0.2.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for I2C DS28CM00 unique identification chip.

View File

@ -36,7 +36,7 @@ unittest_teardown()
}
unittest(test_constructor)
unittest(test_constructor_I)
{
uint8_t uid[8];
DS28CM00 DS28(&Wire);
@ -56,6 +56,20 @@ unittest(test_constructor)
assertEqual(DS28CM00_MODE_UNKNOWN, mode);
}
unittest(test_constructor_II)
{
fprintf(stderr, "DS28CM00_LIB_VERSION: %s\n", (char *) DS28CM00_LIB_VERSION);
uint8_t uid[8];
DS28CM00 DS28; // use default Wire
DS28.begin();
uint8_t mode;
assertFalse(DS28.getMode(mode)); // not connected...
assertEqual(DS28CM00_MODE_UNKNOWN, mode);
}
unittest_main()
// --------