From 57fe95c1be265743ca02b93cf6b1cf193d5430ea Mon Sep 17 00:00:00 2001 From: Simon IJskes Date: Fri, 8 Feb 2019 22:18:10 +0100 Subject: [PATCH] split off the DHT11 conversion, corrected the algorithm for temperatures below 0 degrees celsius. --- DHT.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/DHT.cpp b/DHT.cpp index 463a61f..037c104 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -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;