Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read2( ) which uses float temperature and humidity only return integer values. #54

Open
DaleSchultz opened this issue Jan 19, 2023 · 0 comments

Comments

@DaleSchultz
Copy link

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant