mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.2.3 DS18B20_RT
This commit is contained in:
parent
bf2c838130
commit
8456e25fc3
@ -6,12 +6,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.2.3] - 2024-06-27
|
||||
- Fix #32, add connectCheck parameter to getTempC()
|
||||
- update examples
|
||||
- update readme.md
|
||||
- minor edits
|
||||
|
||||
## [0.2.2] - 2024-01-03
|
||||
- fix examples
|
||||
- extend **OneWireScanner.ino**
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.2.1] - 2023-10-19
|
||||
- update readme.md
|
||||
- add oneWireScanner.ino example
|
||||
|
@ -70,9 +70,10 @@ Returns true if a device is found.
|
||||
There will be a number of retries to connect, default 3.
|
||||
- **void requestTemperatures()** trigger temperature conversion.
|
||||
- **bool isConversionComplete()** check if conversion is complete.
|
||||
- **float getTempC()** returns temperature in Celsius.
|
||||
- -127 = DEVICE_DISCONNECTED
|
||||
- **float getTempC(bool checkConnect = true)** returns temperature in Celsius.
|
||||
- -127 = DEVICE_DISCONNECTED (only when checkConnect == true)
|
||||
- -128 = DEVICE_CRC_ERROR
|
||||
- can be faster by setting checkConnect to false. (experimental)
|
||||
- **bool setResolution(uint8_t resolution = 9)** resolution = 9..12 (9 is default).
|
||||
Returns false if no device is found.
|
||||
- **uint8_t getResolution()** return resolution set.
|
||||
@ -200,8 +201,9 @@ and all people who contributed to that lib.
|
||||
|
||||
- add examples
|
||||
- investigate performance gain of no CRC.
|
||||
- Extend oneWireSearch with devicetypes
|
||||
- Extend oneWireSearch with device types
|
||||
- see oneWireScanner.ino (2016 version)
|
||||
- should checkConnect be a **config** flag like CRC?
|
||||
|
||||
#### Could
|
||||
|
||||
|
@ -20,8 +20,9 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
if (sensor.begin() == false)
|
||||
{
|
||||
|
@ -19,8 +19,9 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
Serial.print("\ngetAddress: ");
|
||||
Serial.println(sensor.getAddress(da));
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "DS18B20.h"
|
||||
|
||||
|
||||
#define ONE_WIRE_BUS 2
|
||||
#define ONE_WIRE_BUS 7
|
||||
|
||||
OneWire oneWire(ONE_WIRE_BUS);
|
||||
DS18B20 sensor(&oneWire);
|
||||
@ -23,6 +23,9 @@ void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
sensor.begin();
|
||||
}
|
||||
|
@ -35,8 +35,9 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
sensor.begin();
|
||||
}
|
||||
|
@ -18,10 +18,12 @@ void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
sensor.begin();
|
||||
sensor.setResolution(10);
|
||||
}
|
||||
|
||||
|
||||
@ -41,5 +43,3 @@ void loop(void)
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
||||
|
@ -20,8 +20,10 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
delay(100);
|
||||
|
||||
sensor.begin();
|
||||
sensor.setResolution(12);
|
||||
@ -29,16 +31,23 @@ void setup()
|
||||
|
||||
start = millis();
|
||||
int n = 0;
|
||||
// wait until sensor ready, do some counting for fun.
|
||||
// wait until sensor ready, do some counting for fun.
|
||||
while (!sensor.isConversionComplete()) n++;
|
||||
stop = millis();
|
||||
|
||||
|
||||
delay(100);
|
||||
start = micros();
|
||||
float f = sensor.getTempC();
|
||||
stop = micros();
|
||||
|
||||
Serial.print(stop - start);
|
||||
Serial.print("\t");
|
||||
Serial.print(n);
|
||||
Serial.print("\t");
|
||||
Serial.println(sensor.getTempC(), 4); // 4 decimals is too much ...
|
||||
Serial.println(f, 4); // 4 decimals is too much ...
|
||||
Serial.println();
|
||||
delay(100);
|
||||
}
|
||||
|
||||
|
||||
@ -50,11 +59,12 @@ void loop()
|
||||
sensor.setResolution(r);
|
||||
|
||||
int n = 0;
|
||||
start = millis();
|
||||
sensor.requestTemperatures();
|
||||
while (!sensor.isConversionComplete()) n++;
|
||||
|
||||
start = micros();
|
||||
t = sensor.getTempC();
|
||||
stop = millis();
|
||||
stop = micros();
|
||||
|
||||
Serial.print(r);
|
||||
Serial.print("\t");
|
||||
@ -64,6 +74,7 @@ void loop()
|
||||
Serial.print("\t");
|
||||
// 1 decimal makes perfect sense
|
||||
Serial.println( t, 1);
|
||||
delay(100);
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
@ -72,4 +83,3 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -20,14 +20,15 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
// wait until address found
|
||||
// wait until address found
|
||||
if (sensor.begin() == false)
|
||||
{
|
||||
Serial.println("ERROR: No device found");
|
||||
while (!sensor.begin()); // wait until device comes available.
|
||||
while (!sensor.begin()); // wait until device comes available.
|
||||
}
|
||||
|
||||
Serial.println(sensor.getResolution());
|
||||
@ -43,11 +44,11 @@ void loop()
|
||||
start = millis();
|
||||
sensor.requestTemperatures();
|
||||
|
||||
// wait for data AND detect disconnect
|
||||
// wait for data AND detect disconnect
|
||||
uint32_t timeout = millis();
|
||||
while (!sensor.isConversionComplete())
|
||||
{
|
||||
if (millis() - timeout >= 800) // check for timeout
|
||||
if (millis() - timeout >= 800) // check for timeout
|
||||
{
|
||||
Serial.println("ERROR: timeout or disconnect");
|
||||
break;
|
||||
|
@ -23,8 +23,9 @@ void setup(void)
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("DS18B20 Library version: ");
|
||||
Serial.print("DS18B20_LIB_VERSION: ");
|
||||
Serial.println(DS18B20_LIB_VERSION);
|
||||
Serial.println();
|
||||
|
||||
inside.begin();
|
||||
outside.begin();
|
||||
|
@ -23,7 +23,7 @@
|
||||
"version": "^2.3.5"
|
||||
}
|
||||
],
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=DS18B20_RT
|
||||
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 the DS18B20 temperature sensor.
|
||||
|
@ -86,12 +86,15 @@ bool DS18B20::isConversionComplete(void)
|
||||
}
|
||||
|
||||
|
||||
float DS18B20::getTempC(void)
|
||||
float DS18B20::getTempC(bool checkConnect)
|
||||
{
|
||||
ScratchPad scratchPad;
|
||||
if (isConnected(3) == false)
|
||||
if (checkConnect)
|
||||
{
|
||||
return DEVICE_DISCONNECTED;
|
||||
if (isConnected(3) == false)
|
||||
{
|
||||
return DEVICE_DISCONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (_config & DS18B20_CRC)
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: DS18B20.h
|
||||
// AUTHOR: Rob.Tillaart
|
||||
// VERSION: 0.2.2
|
||||
// VERSION: 0.2.3
|
||||
// DATE: 2017-07-25
|
||||
// PURPOSE: library for DS18B20 temperature sensor with minimal footprint
|
||||
// URL: https://github.com/RobTillaart/DS18B20_RT
|
||||
@ -22,7 +22,7 @@
|
||||
#include "OneWire.h"
|
||||
|
||||
|
||||
#define DS18B20_LIB_VERSION (F("0.2.2"))
|
||||
#define DS18B20_LIB_VERSION (F("0.2.3"))
|
||||
|
||||
// Error Code
|
||||
#define DEVICE_DISCONNECTED -127
|
||||
@ -46,7 +46,8 @@ public:
|
||||
|
||||
void requestTemperatures(void);
|
||||
bool isConversionComplete(void);
|
||||
float getTempC(void);
|
||||
// backwards compatible
|
||||
float getTempC(bool checkConnect = true);
|
||||
|
||||
bool getAddress(uint8_t * buf);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user