Page 1 of 1

ESP8266 + DHT... Temperature conversion

Posted: Fri Jun 28, 2019 3:13 pm
by jovosm
In a sketch for ESP8266 + DHT, how to change temperature from Celsius to Fahrenheit?

Re: ESP8266 + DHT... Temperature conversion

Posted: Fri Jun 28, 2019 11:11 pm
by AskGuru
Hi jovosm,

Thanks for trying AskSensors. Could you please specify the ESP8266+DHT sketch do you use?

Thanks

Re: ESP8266 + DHT... Temperature conversion

Posted: Tue Jul 02, 2019 3:07 pm
by jovosm
It's example sketch how to connect ESP8266 and DHT sensor and how to connect to asksensor.com and see temperature and humidity.
https://github.com/asksensors/AskSensors-ESP8266-DHT

Re: ESP8266 + DHT... Temperature conversion

Posted: Thu Jul 04, 2019 11:49 am
by Guru
jovosm,
You can convert the temperature from degrees Celsius to Fahrenheit just after reading it from the sensor and before sending it to the AskSensors cloud: by multiplying by 1.8 (or 9/5) and adding 32.

here is an example:

Code: Select all

 // Get temperature event and print its value.
  sensors_event_t event;  
  dht.temperature().getEvent(&event);
  if (isnan(event.temperature)) {
    Serial.println("Error reading temperature!");
  }
  else {
    // Update temperature and humidity
    myTemperature = (float)event.temperature;
    myTemperature = (float) (32 + myTemperature  * 9/5);
    Serial.print("Temperature: ");
    Serial.print(myTemperature);
    Serial.println(" C");
}


Re: ESP8266 + DHT... Temperature conversion

Posted: Fri Jul 05, 2019 3:14 pm
by jovosm
It works now.
Thank You!

Re: ESP8266 + DHT... Temperature conversion

Posted: Thu Jul 11, 2019 10:23 pm
by Guru
Great!