mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.13 DS18B20_RT
This commit is contained in:
parent
e5bd3dad2e
commit
e8438b99b2
@ -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:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
- leonardo
|
||||
- due
|
||||
- zero
|
||||
- leonardo
|
||||
# - m4
|
||||
# - esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
# Declaring Dependent Arduino Libraries (to be installed via the Arduino Library Manager)
|
||||
libraries:
|
||||
- "OneWire"
|
||||
@ -13,6 +33,7 @@ unittest:
|
||||
# These dependent libraries will be installed
|
||||
libraries:
|
||||
- "OneWire"
|
||||
- "util/crc16"
|
||||
# fix the #include "util/crc16" problem here?
|
||||
|
||||
|
||||
|
60
libraries/DS18B20_RT/CHANGELOG.md
Normal file
60
libraries/DS18B20_RT/CHANGELOG.md
Normal 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
|
||||
|
@ -1,37 +1,24 @@
|
||||
//
|
||||
// FILE: DS18B20.cpp
|
||||
// AUTHOR: Rob.Tillaart@gmail.com
|
||||
// VERSION: 0.1.12
|
||||
// VERSION: 0.1.13
|
||||
// DATE: 2017-07-25
|
||||
// PUPROSE: library for DS18B20 temperature sensor with minimal footprint
|
||||
// URL: https://github.com/RobTillaart/DS18B20_RT
|
||||
//
|
||||
// HISTORY:
|
||||
// 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
|
||||
// HISTORY: see changelog.md
|
||||
|
||||
|
||||
#include "DS18B20.h"
|
||||
|
||||
|
||||
// OneWire commands
|
||||
// OneWire commands
|
||||
#define STARTCONVO 0x44
|
||||
#define READSCRATCH 0xBE
|
||||
#define WRITESCRATCH 0x4E
|
||||
|
||||
|
||||
// Scratchpad locations
|
||||
// Scratchpad locations
|
||||
#define TEMP_LSB 0
|
||||
#define TEMP_MSB 1
|
||||
#define HIGH_ALARM_TEMP 2
|
||||
@ -43,11 +30,11 @@
|
||||
#define SCRATCHPAD_CRC 8
|
||||
|
||||
|
||||
// Device resolution
|
||||
#define TEMP_9_BIT 0x1F // 9 bit
|
||||
#define TEMP_10_BIT 0x3F // 10 bit
|
||||
#define TEMP_11_BIT 0x5F // 11 bit
|
||||
#define TEMP_12_BIT 0x7F // 12 bit
|
||||
// Device resolution
|
||||
#define TEMP_9_BIT 0x1F // 9 bit
|
||||
#define TEMP_10_BIT 0x3F // 10 bit
|
||||
#define TEMP_11_BIT 0x5F // 11 bit
|
||||
#define TEMP_12_BIT 0x7F // 12 bit
|
||||
|
||||
|
||||
DS18B20::DS18B20(OneWire* ow)
|
||||
@ -135,7 +122,7 @@ void DS18B20::setResolution(uint8_t resolution)
|
||||
_oneWire->reset();
|
||||
_oneWire->select(_deviceAddress);
|
||||
_oneWire->write(WRITESCRATCH);
|
||||
// two dummy values for LOW & HIGH ALARM
|
||||
// two dummy values for LOW & HIGH ALARM
|
||||
_oneWire->write(0);
|
||||
_oneWire->write(100);
|
||||
switch (resolution)
|
||||
|
@ -2,32 +2,32 @@
|
||||
//
|
||||
// FILE: DS18B20.h
|
||||
// AUTHOR: Rob.Tillaart@gmail.com
|
||||
// VERSION: 0.1.12
|
||||
// VERSION: 0.1.13
|
||||
// DATE: 2017-07-25
|
||||
// PUPROSE: library for DS18B20 temperature sensor with minimal footprint
|
||||
// URL: https://github.com/RobTillaart/DS18B20_RT
|
||||
|
||||
//
|
||||
// BOTTOM VIEW
|
||||
// BOTTOM VIEW
|
||||
//
|
||||
// PIN MEANING
|
||||
// /---+
|
||||
// / o | 1 GND
|
||||
// | o | 2 DATA
|
||||
// \ o | 3 VCC
|
||||
// \---+
|
||||
// PIN MEANING
|
||||
// /---+
|
||||
// / o | 1 GND
|
||||
// | o | 2 DATA
|
||||
// \ o | 3 VCC
|
||||
// \---+
|
||||
//
|
||||
|
||||
|
||||
#define DS18B20_LIB_VERSION (F("0.1.12"))
|
||||
#define DS18B20_LIB_VERSION (F("0.1.13"))
|
||||
|
||||
#include <OneWire.h>
|
||||
|
||||
// Error Code
|
||||
// Error Code
|
||||
#define DEVICE_DISCONNECTED -127
|
||||
#define DEVICE_CRC_ERROR -128
|
||||
|
||||
// config codes
|
||||
// config codes
|
||||
#define DS18B20_CLEAR 0x00
|
||||
#define DS18B20_CRC 0x01
|
||||
|
||||
|
@ -89,7 +89,7 @@ Note: thicker wires require smaller resistors (typically 1 step in E12 series)
|
||||
| 100cm (3'4") | 3K3 | 2K2 |
|
||||
| 200cm (6'8") | 2K2 | 1K0 |
|
||||
| 500cm (16'8") | 1K0 | \* |
|
||||
| longer | * | \* |
|
||||
| longer | \* | \* |
|
||||
|
||||
\* = no info, smaller
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
"version": "^2.3.5"
|
||||
}
|
||||
],
|
||||
"version": "0.1.12",
|
||||
"version": "0.1.13",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=DS18B20_RT
|
||||
version=0.1.12
|
||||
version=0.1.13
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for the DS18B20 temperature sensor.
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user