split off the DHT11 conversion, corrected the algorithm for temperatures below 0 degrees celsius.

This commit is contained in:
Simon IJskes 2019-02-08 22:18:10 +01:00
parent d6488c1fbe
commit 57fe95c1be

View File

@ -39,6 +39,15 @@ float DHT::readTemperature(bool S, bool force) {
if (read(force)) {
switch (_type) {
case DHT11:
f = data[2];
if (data[3] & 0x80) {
f *= -1 -f ;
}
f += (data[3] & 0x0f) * 0.1;
if(S) {
f = convertCtoF(f);
}
break;
case DHT12:
f = data[2];
f += (data[3] & 0x0f) * 0.1;