mirror of
https://github.com/adafruit/DHT-sensor-library.git
synced 2023-10-23 22:20:38 +03:00
Add support for DHT12.
Change DHT11 temperature resolution to 0.1 instead of 1.
This commit is contained in:
8
DHT.cpp
8
DHT.cpp
@ -38,7 +38,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);
|
||||
}
|
||||
@ -74,7 +79,8 @@ float DHT::readHumidity(bool force) {
|
||||
if (read()) {
|
||||
switch (_type) {
|
||||
case DHT11:
|
||||
f = data[0];
|
||||
case DHT12:
|
||||
f = data[0] + data[1] * 0.1;
|
||||
break;
|
||||
case DHT22:
|
||||
case DHT21:
|
||||
|
Reference in New Issue
Block a user