Reading temperature and humidity

User avatar
drwill
Posts: 14
Joined: Mon Oct 28, 2019 10:01 pm

Reading temperature and humidity

Postby drwill » Fri Nov 08, 2019 12:55 am

I'm using an ESP32 Azure IoT Kit. I want to send temperature and humidity along as telemetry to my IoT hub.

I cannot find almost any information on how to do this. I came across one post here where someone refers to using uint8_t temprature_sens_read() (note that the word temperature is misspelled) and much to my surprise that worked. I've searched the code base in esp-idf and can't find a single file that defines that function. There is no include file, you just "extern" it in your .c file.

I still need to get humidity. I haven't found any documentation or samples about that.

Am I reading temperature the right way? How do I get humidity?

Thanks,
David

P.S. I'm surprised the temperature reading is in F. I'd think C would be a better worldwide standard, and I'm curious about the decision to report in F.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Reading temperature and humidity

Postby WiFive » Fri Nov 08, 2019 2:00 am


User avatar
drwill
Posts: 14
Joined: Mon Oct 28, 2019 10:01 pm

Re: Reading temperature and humidity

Postby drwill » Fri Nov 08, 2019 2:33 am

I found this sample, which uses a very different approach than the function I found for temperature earlier.

Is this what is recommended?

https://github.com/espressif/esp-iot-so ... ain/main.c

Thanks,
David

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Reading temperature and humidity

Postby WiFive » Fri Nov 08, 2019 3:34 am

temprature_sens_read is not what you want. It is for reading esp32 internal temperature.

User avatar
drwill
Posts: 14
Joined: Mon Oct 28, 2019 10:01 pm

Re: Reading temperature and humidity

Postby drwill » Sat Nov 09, 2019 12:11 am

WiFive wrote:
Fri Nov 08, 2019 3:34 am
temprature_sens_read is not what you want. It is for reading esp32 internal temperature.
Gotcha.

In the samples, why are temp and humidity divided by 10?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Reading temperature and humidity

Postby WiFive » Sat Nov 09, 2019 1:07 am

To convert to decimal

User avatar
drwill
Posts: 14
Joined: Mon Oct 28, 2019 10:01 pm

Re: Reading temperature and humidity

Postby drwill » Sat Nov 09, 2019 1:30 am

WiFive wrote:
Sat Nov 09, 2019 1:07 am
To convert to decimal
I guess a better way to ask my question is, if my temperature reading is 30.4 C, why is it stored as 304?

I assumed the values are stored with accuracy of 0.1, but as an integer because maybe they store better than floats.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Reading temperature and humidity

Postby tommeyers » Sat Nov 09, 2019 1:42 pm

Are you using the HTS221 temp/humid sensor ?

if so: https://github.com/espressif/esp-iot-so ... /README.md
IT Professional, Maker
Santiago, Dominican Republic

User avatar
drwill
Posts: 14
Joined: Mon Oct 28, 2019 10:01 pm

Re: Reading temperature and humidity

Postby drwill » Sat Nov 09, 2019 9:28 pm

tommeyers wrote:
Sat Nov 09, 2019 1:42 pm
Are you using the HTS221 temp/humid sensor ?

if so: https://github.com/espressif/esp-iot-so ... /README.md
I didn't realize I am, but I am. I took a second look at the spec sheet to confirm. I'm new to MCUs and honestly don't know many things, but I'm learning.

I got a solution working yesterday, but the instructions didn't work. I resorted to copying the relevant components to my project component directory, and it finally built.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: Reading temperature and humidity

Postby tommeyers » Sat Nov 09, 2019 10:25 pm

Post what you need.

Post what you have tried.

we'll help where we can.

Tom
IT Professional, Maker
Santiago, Dominican Republic

Who is online

Users browsing this forum: No registered users and 175 guests