Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Posting DHT22 in Fahrenheit
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Posting DHT22 in Fahrenheit

by jupiter457 on Mon Jan 25, 2016 6:35 pm

I apologize in advance for this question, I'm very new to all of this. I am following the Sensor Module example from the Home Automation in the Cloud tutorial from Adafruit Learn. I seem to have everything up and running but I would like to post my temperatures in Fahrenheit and not Celsius. Could you tell me how I would need to modify the sample code to do that?
Thank you very much
Attachments
Huzzah.txt
(4.51 KiB) Downloaded 175 times

jupiter457
 
Posts: 3
Joined: Thu May 24, 2012 4:34 pm

Re: Posting DHT22 in Fahrenheit

by jupiter457 on Mon Jan 25, 2016 7:57 pm

I should have been more clear. I understand how to mathematically do the conversion, I don't understand how to get the sketch to do this and then post it. Do I need to create a new variable called Fahrenheit and tell the Huzzah to post that to Adafruit.io instead of readTemperature?
I see that the code has:

// Grab the current state of the sensor
int humidity_data = (int)dht.readHumidity();
int temperature_data = (int)dht.readTemperature();

// Publish data
if (! temperature.publish(temperature_data))
Serial.println(F("Failed to publish temperature"));
else
Serial.println(F("Temperature published!"));

jupiter457
 
Posts: 3
Joined: Thu May 24, 2012 4:34 pm

Re: Posting DHT22 in Fahrenheit

by jupiter457 on Tue Jan 26, 2016 11:02 am

Ahh, that's exactly what I needed. Thank you very much.

jupiter457
 
Posts: 3
Joined: Thu May 24, 2012 4:34 pm

Re: Posting DHT22 in Fahrenheit

by Luminaric on Wed Jan 27, 2016 5:10 pm

Jupiter,
In the DHT library I use this code:
Code: Select all | TOGGLE FULL SIZE
float tempF = dht.readTemperature(true);


Hope that's what you were looking for. BTW, it is also in the example sketch.

Luminaric
 
Posts: 3
Joined: Mon Aug 18, 2014 12:23 pm

Please be positive and constructive with your questions and comments.