0.1.13 DS18B20_RT

This commit is contained in:
rob tillaart 2022-11-02 15:21:25 +01:00
parent e5bd3dad2e
commit e8438b99b2
8 changed files with 113 additions and 39 deletions

View File

@ -1,10 +1,30 @@
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: compile:
# Choosing to run compilation tests on 2 different Arduino platforms # Choosing to run compilation tests on 2 different Arduino platforms
platforms: platforms:
- uno - uno
- leonardo
- due - due
- zero - zero
- leonardo
# - m4
# - esp32
# - esp8266
# - mega2560
- rpipico
# Declaring Dependent Arduino Libraries (to be installed via the Arduino Library Manager) # Declaring Dependent Arduino Libraries (to be installed via the Arduino Library Manager)
libraries: libraries:
- "OneWire" - "OneWire"
@ -13,6 +33,7 @@ unittest:
# These dependent libraries will be installed # These dependent libraries will be installed
libraries: libraries:
- "OneWire" - "OneWire"
- "util/crc16"
# fix the #include "util/crc16" problem here? # fix the #include "util/crc16" problem here?

View File

@ -0,0 +1,60 @@
# Change Log DS18B20_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.1.13] - 2022-11-02
- add changelog.md
- add rp2040 to build-CI
- update unit test constants
## [0.1.12] - 2021-12-17
- update library.json
- update license
- minor edits
## [0.1.11] - 2021-10-03
- add dependency
- fix build-CI
## [0.1.10] - 2021-06-14
- add retries parameter to begin()
## [0.1.9] - 2021-05-26
- add oneWire.reset() in begin()
## [0.1.8] - 2021-04-08
- clear scratchpad before read
- update readme.md
## [0.1.7] - 2020-12-20
- add Arduino CI + unit test
## [0.1.6] - 2020-06-07
- fix library.json
## [0.1.5] - 2020-04-29
- #4 added set/getConfig
- add DEVICE_CRC_ERROR
- add example
## [0.1.4] - 2020-04-23
- #2 add retry in begin() to support Wemos
## [0.1.3] - 2020-04-22
- #1 fix library.json file
## [0.1.2] - 2020-04-11
- #pragma once
- refactor
## [0.1.1] - 2020-02-18
- added getAddress()
## [0.1.0] - 2017-07-25
- initial version

View File

@ -1,37 +1,24 @@
// //
// FILE: DS18B20.cpp // FILE: DS18B20.cpp
// AUTHOR: Rob.Tillaart@gmail.com // AUTHOR: Rob.Tillaart@gmail.com
// VERSION: 0.1.12 // VERSION: 0.1.13
// DATE: 2017-07-25 // DATE: 2017-07-25
// PUPROSE: library for DS18B20 temperature sensor with minimal footprint // PUPROSE: library for DS18B20 temperature sensor with minimal footprint
// URL: https://github.com/RobTillaart/DS18B20_RT // URL: https://github.com/RobTillaart/DS18B20_RT
// //
// HISTORY: // HISTORY: see changelog.md
// 0.1.0 2017-07-25 initial version
// 0.1.1 2020-02-18 added getAddress()
// 0.1.2 2020-04-11 #pragma once, refactor
// 0.1.3 2020-04-22 #1 fix library.json file
// 0.1.4 2020-04-23 #2 add retry in begin() to support Wemos
// 0.1.5 2020-04-29 #4 added set/getConfig + DEVICE_CRC_ERROR + example
// 0.1.6 2020-06-07 fix library.json
// 0.1.7 2020-12-20 add Arduino CI + unit test
// 0.1.8 2021-04-08 clear scratchpad before read + update readme.md
// 0.1.9 2021-05-26 add oneWire.reset() in begin()
// 0.1.10 2021-06-14 add retries parameter to begin()
// 0.1.11 2021-10-03 add dependency + fix build-CI
// 0.1.12 2021-12-17 update library.json, license, minor edits
#include "DS18B20.h" #include "DS18B20.h"
// OneWire commands // OneWire commands
#define STARTCONVO 0x44 #define STARTCONVO 0x44
#define READSCRATCH 0xBE #define READSCRATCH 0xBE
#define WRITESCRATCH 0x4E #define WRITESCRATCH 0x4E
// Scratchpad locations // Scratchpad locations
#define TEMP_LSB 0 #define TEMP_LSB 0
#define TEMP_MSB 1 #define TEMP_MSB 1
#define HIGH_ALARM_TEMP 2 #define HIGH_ALARM_TEMP 2
@ -43,11 +30,11 @@
#define SCRATCHPAD_CRC 8 #define SCRATCHPAD_CRC 8
// Device resolution // Device resolution
#define TEMP_9_BIT 0x1F // 9 bit #define TEMP_9_BIT 0x1F // 9 bit
#define TEMP_10_BIT 0x3F // 10 bit #define TEMP_10_BIT 0x3F // 10 bit
#define TEMP_11_BIT 0x5F // 11 bit #define TEMP_11_BIT 0x5F // 11 bit
#define TEMP_12_BIT 0x7F // 12 bit #define TEMP_12_BIT 0x7F // 12 bit
DS18B20::DS18B20(OneWire* ow) DS18B20::DS18B20(OneWire* ow)
@ -135,7 +122,7 @@ void DS18B20::setResolution(uint8_t resolution)
_oneWire->reset(); _oneWire->reset();
_oneWire->select(_deviceAddress); _oneWire->select(_deviceAddress);
_oneWire->write(WRITESCRATCH); _oneWire->write(WRITESCRATCH);
// two dummy values for LOW & HIGH ALARM // two dummy values for LOW & HIGH ALARM
_oneWire->write(0); _oneWire->write(0);
_oneWire->write(100); _oneWire->write(100);
switch (resolution) switch (resolution)

View File

@ -2,32 +2,32 @@
// //
// FILE: DS18B20.h // FILE: DS18B20.h
// AUTHOR: Rob.Tillaart@gmail.com // AUTHOR: Rob.Tillaart@gmail.com
// VERSION: 0.1.12 // VERSION: 0.1.13
// DATE: 2017-07-25 // DATE: 2017-07-25
// PUPROSE: library for DS18B20 temperature sensor with minimal footprint // PUPROSE: library for DS18B20 temperature sensor with minimal footprint
// URL: https://github.com/RobTillaart/DS18B20_RT // URL: https://github.com/RobTillaart/DS18B20_RT
// //
// BOTTOM VIEW // BOTTOM VIEW
// //
// PIN MEANING // PIN MEANING
// /---+ // /---+
// / o | 1 GND // / o | 1 GND
// | o | 2 DATA // | o | 2 DATA
// \ o | 3 VCC // \ o | 3 VCC
// \---+ // \---+
// //
#define DS18B20_LIB_VERSION (F("0.1.12")) #define DS18B20_LIB_VERSION (F("0.1.13"))
#include <OneWire.h> #include <OneWire.h>
// Error Code // Error Code
#define DEVICE_DISCONNECTED -127 #define DEVICE_DISCONNECTED -127
#define DEVICE_CRC_ERROR -128 #define DEVICE_CRC_ERROR -128
// config codes // config codes
#define DS18B20_CLEAR 0x00 #define DS18B20_CLEAR 0x00
#define DS18B20_CRC 0x01 #define DS18B20_CRC 0x01

View File

@ -89,7 +89,7 @@ Note: thicker wires require smaller resistors (typically 1 step in E12 series)
| 100cm (3'4") | 3K3 | 2K2 | | 100cm (3'4") | 3K3 | 2K2 |
| 200cm (6'8") | 2K2 | 1K0 | | 200cm (6'8") | 2K2 | 1K0 |
| 500cm (16'8") | 1K0 | \* | | 500cm (16'8") | 1K0 | \* |
| longer | * | \* | | longer | \* | \* |
\* = no info, smaller \* = no info, smaller

View File

@ -23,7 +23,7 @@
"version": "^2.3.5" "version": "^2.3.5"
} }
], ],
"version": "0.1.12", "version": "0.1.13",
"license": "MIT", "license": "MIT",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": "*", "platforms": "*",

View File

@ -1,5 +1,5 @@
name=DS18B20_RT name=DS18B20_RT
version=0.1.12 version=0.1.13
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for the DS18B20 temperature sensor. sentence=Arduino library for the DS18B20 temperature sensor.

View File

@ -40,7 +40,13 @@ unittest_teardown()
} }
// TODO constants unittest(test_constants)
{
assertEqual(-127, DEVICE_DISCONNECTED);
assertEqual(-128, DEVICE_CRC_ERROR);
assertEqual(0x00, DS18B20_CLEAR);
assertEqual(0x01, DS18B20_CRC);
}
unittest(test_constructor) unittest(test_constructor)