diff --git a/libraries/MCP9808_RT/.arduino-ci.yml b/libraries/MCP9808_RT/.arduino-ci.yml index cecf5850..25980972 100644 --- a/libraries/MCP9808_RT/.arduino-ci.yml +++ b/libraries/MCP9808_RT/.arduino-ci.yml @@ -1,3 +1,18 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: @@ -9,3 +24,4 @@ compile: - esp32 # - esp8266 # - mega2560 + - rpipico diff --git a/libraries/MCP9808_RT/CHANGELOG.md b/libraries/MCP9808_RT/CHANGELOG.md new file mode 100644 index 00000000..1815a7c4 --- /dev/null +++ b/libraries/MCP9808_RT/CHANGELOG.md @@ -0,0 +1,44 @@ +# Change Log MCP9808_RT + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + + +## [0.2.2] - 2022-11-17 +- add RP2040 in build-CI +- add changelog.md +- edit readme.md + + +## [0.2.1] - 2021-12-21 +- update library.json +- update license +- minor edits + +## [0.2.0] - 2021-11-19 +- fix #7 negative temperature + +---- + +## [0.1.4] - 2021-11-08 +- update build-CI, badges +- default offset for offset +- default Wire for I2C bus - setAddress() + +## [0.1.3] - 2021-01-01 +- Arduino-ci + unit test + +## [0.1.2] - 2020-11-16 +- removed hasAlert +- removed setAlertPin, +- added 2 alert examples +- refactor low level + +## [0.1.1] - 2020-11-12 +- refactor + +## [0.1.0] - 2020-05-03 +- initial version. + diff --git a/libraries/MCP9808_RT/README.md b/libraries/MCP9808_RT/README.md index 6af97975..ad0c27a6 100644 --- a/libraries/MCP9808_RT/README.md +++ b/libraries/MCP9808_RT/README.md @@ -21,19 +21,19 @@ of electronics if the temperature hits a predefined value or zone. ### MCP9808 breakout board ``` // -// Adafruit MCP9808 breakout board -// +----------+ -// |0 ALERT |---------------+--[ 4K7 ]---- +5V -// | A2 |---- GND | -// | A1 |---- GND +--[ LED ]---- GND // or other electronics. -// | A0 |---- GND -// | SDA |---- I2C MCU -// | SCL |---- I2C MCU -// | GND |---- GND MCU -// |0 VCC |---- +5V -// +----------+ +// Adafruit MCP9808 breakout board +// +----------+ +// |0 ALERT |---------------+--[ 4K7 ]---- +5V +// | A2 |---- GND | +// | A1 |---- GND +--[ LED ]---- GND // or other electronics. +// | A0 |---- GND +// | SDA |---- I2C MCU +// | SCL |---- I2C MCU +// | GND |---- GND MCU +// |0 VCC |---- +5V +// +----------+ // -// address above is 24 +// address above is 24 // ``` @@ -50,7 +50,7 @@ Default I2C bus is Wire. #### Address -There ar max 8 sensors on one I2C bus. +There are max 8 sensors on one I2C bus. Normal address = 0011xxx where xxx = A2, A1, A0 | Address | HEX | A2 | A1 | A0 | @@ -80,11 +80,11 @@ The value returned by **getStatus()** is the last value read by the call to **Ge There are three bits, see table below. A value of 6 == mask == 110 means that TA is above the upper and above the critical temperature. -| Bit | Mask | Description | Notes | -|:----:|:------:|:------------|:----------------| -| 0 | 0x01 | TA < TLOWER | lower | -| 1 | 0x02 | TA > TUPPER | larger | -| 2 | 0x04 | TA ≥ TCRIT | larger or equal | +| Bit | Mask | Description | Notes | +|:-----:|:------:|:--------------|:-----------------| +| 0 | 0x01 | TA < TLOWER | lower | +| 1 | 0x02 | TA > TUPPER | larger | +| 2 | 0x04 | TA ≥ TCRIT | larger or equal | ### Resolution @@ -92,12 +92,12 @@ A value of 6 == mask == 110 means that TA is above the upper and above the criti - **void setResolution(uint8_t resolution = 3)** set the resolution, if resolution > 3, it is not set. - **uint8_t getResolution()** returns the resolution set. -| Value | Resolution | Conv time (ms) | Samples/s | Notes | -|:------:|:-----------|:--------------:|:---------:|:-------:| -| 0 | 0.5°C | 30 | 33 | | -| 1 | 0.25°C | 65 | 15 | | -| 2 | 0.125°C | 130 | 7 | | -| 3 | 0.0625°C | 250 | 4 | default | +| Value | Resolution | Conv time (ms) | Samples/s | Notes | +|:-------:|:-------------|:----------------:|:-----------:|:--------:| +| 0 | 0.5°C | 30 | 33 | | +| 1 | 0.25°C | 65 | 15 | | +| 2 | 0.125°C | 130 | 7 | | +| 3 | 0.0625°C | 250 | 4 | default | Note: for the same resolution it is about 3x faster than a DS18B20. @@ -112,7 +112,7 @@ Note: for the same resolution it is about 3x faster than a DS18B20. |:-----:|:------:|:-----------|:----------------|:-------| | 0 | 0x0001 | ALT MOD | alert mode | **0 = comparator output**, 1 = interrupt output | 1 | 0x0002 | ALT POL | alert polarity | **0 = active low**, 1 = active high -| 2 | 0x0004 | ALT SEL | alert select | **0 = upper+lower+crit**, 1 = crit only +| 2 | 0x0004 | ALT SEL | alert select | **0 = upper+lower+crit**, 1 = critical only | 3 | 0x0008 | ALT CNT | alert control | **0 = OFF**, 1 = ON | 4 | 0x0010 | ALT STAT | alert status | **0 = OFF**, 1 = ON (read!) | 5 | 0x0020 | INT CLR | interrupt clear | **0 = none**, 1 = clear interrupt @@ -163,8 +163,19 @@ See examples ## Future +#### must - update documentation -- do unit test -- add more examples for the **ALERT** -- + - compare DS18B20? +- test more + - negative temperatures + +#### should +- do unit test +- check for optimizations + +#### could +- add examples + - for the **ALERT** + - multi sensor + diff --git a/libraries/MCP9808_RT/library.json b/libraries/MCP9808_RT/library.json index aae538a9..d99f434e 100644 --- a/libraries/MCP9808_RT/library.json +++ b/libraries/MCP9808_RT/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/MCP9808_RT.git" }, - "version": "0.2.1", + "version": "0.2.2", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/MCP9808_RT/library.properties b/libraries/MCP9808_RT/library.properties index 6585c815..1269902f 100644 --- a/libraries/MCP9808_RT/library.properties +++ b/libraries/MCP9808_RT/library.properties @@ -1,5 +1,5 @@ name=MCP9808_RT -version=0.2.1 +version=0.2.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino Library for I2C MCP9808 temperature sensor diff --git a/libraries/MCP9808_RT/mcp9808.cpp b/libraries/MCP9808_RT/mcp9808.cpp index 1c6823c9..2e2c7435 100644 --- a/libraries/MCP9808_RT/mcp9808.cpp +++ b/libraries/MCP9808_RT/mcp9808.cpp @@ -1,22 +1,10 @@ // // FILE: mcp9808.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.2.1 +// VERSION: 0.2.2 // PURPOSE: Arduino Library for I2C mcp9808 temperature sensor // DATE: 2020-05-03 // URL: https://github.com/RobTillaart/MCP9808_RT -// -// HISTORY: -// 0.1.0 2020-05-03 initial version -// 0.1.1 2020-11-12 refactor -// 0.1.2 2020-11-16 removed hasAlert, removed setAlertPin, -// added 2 alert examples, refactor low level -// 0.1.3 2021-01-01 Arduino-ci + unit test -// 0.1.4 2021-11-08 update build-CI, badges -// default offset for offset -// default Wire for I2C bus - setAddress() -// 0.2.0 2021-11-19 fix #7 negative temperature -// 0.2.1 2021-12-21 update library.json, license, minor edits #include "mcp9808.h" @@ -33,16 +21,16 @@ /* - 0000 = RFU, Reserved for Future Use (Read-Only register) - 0001 = Configuration register (CONFIG) - 0010 = Alert Temperature Upper Boundary Trip register (TUPPER) - 0011 = Alert Temperature Lower Boundary Trip register (TLOWER) - 0100 = Critical Temperature Trip register (TCRIT) - 0101 = Temperature register (TA) - 0110 = Manufacturer ID register - 0111 = Device ID/Revision register - 1000 = Resolution register - 1xxx = Reserved(1) + 0000 = RFU, Reserved for Future Use (Read-Only register) + 0001 = Configuration register (CONFIG) + 0010 = Alert Temperature Upper Boundary Trip register (TUPPER) + 0011 = Alert Temperature Lower Boundary Trip register (TLOWER) + 0100 = Critical Temperature Trip register (TCRIT) + 0101 = Temperature register (TA) + 0110 = Manufacturer ID register + 0111 = Device ID/Revision register + 1000 = Resolution register + 1xxx = Reserved(1) */ @@ -195,7 +183,7 @@ uint16_t MCP9808::getRFU() //////////////////////////////////////////////////////////////// // -// PRIVATE +// PRIVATE // void MCP9808::writeFloat(uint8_t reg, float f) { @@ -214,7 +202,7 @@ float MCP9808::readFloat(uint8_t reg) { _status = (val & 0xE000) >> 13; } - if (val & 0x1000) // negative value + if (val & 0x1000) // negative value { return ((val & 0x0FFF) * 0.0625) - 256.0; } @@ -224,7 +212,7 @@ float MCP9808::readFloat(uint8_t reg) void MCP9808::writeReg8(uint8_t reg, uint8_t value) { - if (reg > MCP9808_RES) return; // see p.16 + if (reg > MCP9808_RES) return; // see p.16 Wire.beginTransmission(_address); Wire.write(reg); Wire.write(value); @@ -234,7 +222,7 @@ void MCP9808::writeReg8(uint8_t reg, uint8_t value) uint8_t MCP9808::readReg8(uint8_t reg) { - if (reg > MCP9808_RES) return 0; // see p.16 + if (reg > MCP9808_RES) return 0; // see p.16 Wire.beginTransmission(_address); Wire.write(reg); Wire.endTransmission(); @@ -245,18 +233,18 @@ uint8_t MCP9808::readReg8(uint8_t reg) void MCP9808::writeReg16(uint8_t reg, uint16_t value) { - if (reg > MCP9808_RES) return; // see p.16 + if (reg > MCP9808_RES) return; // see p.16 Wire.beginTransmission(_address); Wire.write(reg); - Wire.write(value >> 8); // hi byte - Wire.write(value & 0xFF); // lo byte + Wire.write(value >> 8); // hi byte + Wire.write(value & 0xFF); // lo byte Wire.endTransmission(); } uint16_t MCP9808::readReg16(uint8_t reg) { - if (reg > MCP9808_RES) return 0; // see p.16 + if (reg > MCP9808_RES) return 0; // see p.16 Wire.beginTransmission(_address); Wire.write(reg); Wire.endTransmission(); diff --git a/libraries/MCP9808_RT/mcp9808.h b/libraries/MCP9808_RT/mcp9808.h index f2d8a2a7..53cd11c6 100644 --- a/libraries/MCP9808_RT/mcp9808.h +++ b/libraries/MCP9808_RT/mcp9808.h @@ -2,7 +2,7 @@ // // FILE: mcp9808.h // AUTHOR: Rob Tillaart -// VERSION: 0.2.1 +// VERSION: 0.2.2 // PURPOSE: Arduino Library for I2C mcp9808 temperature sensor // DATE: 2020-05-03 // URL: https://github.com/RobTillaart/MCP9808_RT @@ -12,16 +12,16 @@ #include "Arduino.h" #include "Wire.h" -// VALID ADDRESSES, -// max 8 sensors on one bus -// 24..31 == 0x18..0x1F +// VALID ADDRESSES, +// max 8 sensors on one bus +// 24..31 == 0x18..0x1F -#define MCP9808_LIB_VERSION (F("0.2.1")) +#define MCP9808_LIB_VERSION (F("0.2.2")) -// CONFIGURATION REGISTER MASKS -// check the datasheet for exact usage +// CONFIGURATION REGISTER MASKS +// check the datasheet for exact usage #define MCP9808_THYSTERESIS 0x0600 #define MCP9808_SHUTDOWN 0x0100 #define MCP9808_CRIT_LOCK 0x0080 @@ -38,7 +38,7 @@ class MCP9808 { public: #if defined(ESP8266) || defined(ESP32) - // dataPin and clockPin can be used for ESP8266 + // dataPin and clockPin can be used for ESP8266 MCP9808(const uint8_t address, const uint8_t dataPin = 255, const uint8_t clockPin = 255); #else MCP9808(const uint8_t address); @@ -61,8 +61,8 @@ public: float getOffset(); float getTemperature(); - // getStatus() returns 0..7 - // to get latest status, getTemperature() must be called first + // getStatus() returns 0..7 + // to get latest status, getTemperature() must be called first uint8_t getStatus(); void setResolution(uint8_t resolution = 3); @@ -72,13 +72,13 @@ public: uint8_t getDeviceID(); uint8_t getRevision(); - // Reserved Register, not used + // Reserved Register, not used uint16_t getRFU(); private: float _offset = 0; - uint8_t _status = 0; // 0..7 + uint8_t _status = 0; // 0..7 uint8_t _address; TwoWire* _wire;