Merge pull request #95 from fanthos/master

Add support for DHT12.
This commit is contained in:
Paint Your Dragon
2019-01-11 16:22:00 -08:00
committed by GitHub
3 changed files with 24 additions and 1 deletions

View File

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