read2( ) which uses float temperature and humidity only return integer values.
DaleSchultz opened this issue · 0 comments
DaleSchultz commented
I noticed that there are read2( ) functions that take float arguments.
I tried them but I only get integer results even though the DHT11 has a resolution of 0.1°C
This shows the issue:
#include <SimpleDHT.h>
void setup() {
Serial.begin(115200);
Serial.println();
}
void loop() {
float temperature = 0;
float humidity = 0;
SimpleDHT11 dht11(-1);
int err;
if (dht11.read2(14, &temperature, &humidity, NULL) != SimpleDHTErrSuccess) {
Serial.print("Read DHT11 failed, err="); Serial.print(SimpleDHTErrCode(err));
//Serial.print(","); Serial.println(SimpleDHTErrDuration(err));
}
Serial.print(temperature); Serial.print("°C ");Serial.print(humidity);Serial.println("%");
delay (1500);
}