0.3.3 DS18B20_INT

This commit is contained in:
Rob Tillaart 2024-06-28 10:25:17 +02:00
parent 8456e25fc3
commit 650a3c45f0
7 changed files with 30 additions and 12 deletions

View File

@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.3.3] - 2024-06-27
- add connectCheck parameter to getTempC()
- update readme.md
- minor edits
## [0.3.2] - 2024-01-03 ## [0.3.2] - 2024-01-03
- fix examples - fix examples
- minor edits - minor edits
## [0.3.1] - 2023-10-19 ## [0.3.1] - 2023-10-19
- update readme.md - update readme.md

View File

@ -57,8 +57,9 @@ There will be a number of retries to connect, default 3.
There will be a number of retries to connect, default 3. There will be a number of retries to connect, default 3.
- **void requestTemperatures()** trigger temperature conversion. - **void requestTemperatures()** trigger temperature conversion.
- **bool isConversionComplete()** check if conversion is complete. - **bool isConversionComplete()** check if conversion is complete.
- **int16_t getTempC()** returns temperature in whole degrees only. -55..125 - **int16_t getTempC(bool connectCheck = true)** returns temperature in whole degrees only.
or -127 = DEVICE_DISCONNECTED -55..125 or -127 = DEVICE_DISCONNECTED
Is faster when connectCheck is set to false. Default true = backwards compatible.
- **bool getAddress()** returns true if the sensor is configured (available). - **bool getAddress()** returns true if the sensor is configured (available).

View File

@ -97,6 +97,16 @@ void setup()
Serial.println(stop - start); Serial.println(stop - start);
delay(10); delay(10);
start = micros();
temp = sensor.getTempC(false);
stop = micros();
Serial.print("\ngetTempC(false): \t");
Serial.println(temp);
Serial.print("Time: \t");
Serial.println(stop - start);
delay(10);
} }

View File

@ -23,7 +23,7 @@
"version": "^2.3.5" "version": "^2.3.5"
} }
], ],
"version": "0.3.2", "version": "0.3.3",
"license": "MIT", "license": "MIT",
"frameworks": "*", "frameworks": "*",
"platforms": "*", "platforms": "*",

View File

@ -1,5 +1,5 @@
name=DS18B20_int name=DS18B20_int
version=0.3.2 version=0.3.3
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=Library for DS18B20 restricted to a single sensor per pin. sentence=Library for DS18B20 restricted to a single sensor per pin.

View File

@ -1,7 +1,7 @@
// //
// FILE: DS18B20_INT.cpp // FILE: DS18B20_INT.cpp
// AUTHOR: Rob.Tillaart // AUTHOR: Rob.Tillaart
// VERSION: 0.3.2 // VERSION: 0.3.3
// DATE: 2017-07-25 // DATE: 2017-07-25
// PURPOSE: library for DS18B20 temperature sensor - integer only. // PURPOSE: library for DS18B20 temperature sensor - integer only.
// URL: https://github.com/RobTillaart/DS18B20_INT // URL: https://github.com/RobTillaart/DS18B20_INT
@ -72,12 +72,15 @@ bool DS18B20_INT::isConversionComplete(void)
} }
int16_t DS18B20_INT::getTempC(void) int16_t DS18B20_INT::getTempC(bool connectCheck)
{
if (connectCheck)
{ {
if (isConnected(3) == false) if (isConnected(3) == false)
{ {
return DEVICE_DISCONNECTED; return DEVICE_DISCONNECTED;
} }
}
int16_t rawTemperature = _readRaw(); int16_t rawTemperature = _readRaw();
rawTemperature >>= 4; rawTemperature >>= 4;
if (rawTemperature < -55) if (rawTemperature < -55)

View File

@ -2,7 +2,7 @@
// //
// FILE: DS18B20_INT.h // FILE: DS18B20_INT.h
// AUTHOR: Rob.Tillaart // AUTHOR: Rob.Tillaart
// VERSION: 0.3.2 // VERSION: 0.3.3
// DATE: 2017-07-25 // DATE: 2017-07-25
// PURPOSE: Minimalistic library for DS18B20 temperature sensor // PURPOSE: Minimalistic library for DS18B20 temperature sensor
// uses only integer math (no float to minimize footprint) // uses only integer math (no float to minimize footprint)
@ -25,7 +25,7 @@
#include "OneWire.h" #include "OneWire.h"
#define DS18B20_INT_LIB_VERSION (F("0.3.2")) #define DS18B20_INT_LIB_VERSION (F("0.3.3"))
// Error Code // Error Code
#define DEVICE_DISCONNECTED -127 #define DEVICE_DISCONNECTED -127
@ -42,7 +42,7 @@ public:
bool isConnected(uint8_t retries = 3); bool isConnected(uint8_t retries = 3);
void requestTemperatures(void); void requestTemperatures(void);
int16_t getTempC(void); int16_t getTempC(bool connectCheck = true);
bool isConversionComplete(void); bool isConversionComplete(void);
bool getAddress(uint8_t* buf); bool getAddress(uint8_t* buf);