Merge pull request #125 from sijskes/master

fixed incorrect values on DHT11 below 0 degrees celcius
This commit is contained in:
Paint Your Dragon 2019-02-14 09:03:16 -08:00 committed by GitHub
commit 1e752b12ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,15 @@ float DHT::readTemperature(bool S, bool force) {
if (read(force)) { if (read(force)) {
switch (_type) { switch (_type) {
case DHT11: 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: case DHT12:
f = data[2]; f = data[2];
f += (data[3] & 0x0f) * 0.1; f += (data[3] & 0x0f) * 0.1;