Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions DHT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void DHT::begin(uint8_t usec) {
*/
float DHT::readTemperature(bool S, bool force) {
float f = NAN;
short s = 0;

if (read(force)) {
switch (_type) {
Expand All @@ -108,6 +109,12 @@ float DHT::readTemperature(bool S, bool force) {
}
break;
case DHT22:
s = ((short) data[2]) << 8 | data[3];
f = s * 0.1;
if (S) {
f = convertCtoF(f);
}
break;
case DHT21:
f = ((word)(data[2] & 0x7F)) << 8 | data[3];
f *= 0.1;
Expand Down