Skip to content

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

@DaleSchultz

Description

@DaleSchultz

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions