Fix checksum for DHT11 upon request.

This commit is contained in:
RobTillaart 2017-09-20 14:49:16 +02:00
parent ec741c97f0
commit e14b8c22c7
4 changed files with 10 additions and 8 deletions

View File

@ -6,6 +6,7 @@
// URL: https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTstable
//
// HISTORY:
// 0.2.1 2017-09-20 fix https://github.com/RobTillaart/Arduino/issues/80
// 0.2.0 2017-07-24 fix https://github.com/RobTillaart/Arduino/issues/31 + 33
// 0.1.13 fix negative temperature
// 0.1.12 support DHT33 and DHT44 initial version
@ -54,10 +55,11 @@ int dht::read11(uint8_t pin)
temperature = bits[2]; // bits[3] == 0;
// TEST CHECKSUM
// bits[1] && bits[3] both 0
uint8_t sum = bits[0] + bits[2];
if (bits[4] != sum) return DHTLIB_ERROR_CHECKSUM;
uint8_t sum = bits[0] + bits[1] + bits[2] + bits[3];
if (bits[4] != sum)
{
return DHTLIB_ERROR_CHECKSUM;
}
return DHTLIB_OK;
}

View File

@ -1,7 +1,7 @@
//
// FILE: dht.h
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// VERSION: 0.2.1
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTstable
//
@ -18,7 +18,7 @@
#include <Arduino.h>
#endif
#define DHT_LIB_VERSION "0.2.0 - dhtstable"
#define DHT_LIB_VERSION "0.2.1 - dhtstable"
#define DHTLIB_OK 0
#define DHTLIB_ERROR_CHECKSUM -1

View File

@ -1,5 +1,5 @@
name=DHTStable
version=0.2.0
version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Stable version of library for DHT Temperature & Humidity Sensor

View File

@ -1,5 +1,5 @@
This is the 0.2.0 version of the DHTlib.
This is the 0.2.1 version of the DHTlib.
This version is stable for both ARM and AVR.
You can use most examples from https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib/examples