Reading temperature and humidity

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

Re: Reading temperature and humidity

Postby drwill » Sun Nov 10, 2019 12:03 am

tommeyers wrote:
Sat Nov 09, 2019 10:25 pm
Post what you need.

Post what you have tried.

we'll help where we can.

Tom
Much appreciated, Tom. I think I'm good now.

The issue was that I followed the instructions at https://github.com/espressif/esp-iot-so ... rationmake for my Windows v3.3 tool chain. I kept getting build errors, on both options listed. In some cases it couldn't find my other include to wifi_provisioning/manager.h. The other way, there were build errors for components I didn't need to use.

So I just copied the i2c and hts221 components to my project components dir and it worked perfectly.

What I don't know is if the esp-iot-solution is just for samples (to be borrowed from in one's own project), or if it becomes your new esp-idf. The latter didn't work for me, but as I'm still pretty new to this perhaps it was something I have set up wrong.

I've read through the sample code and provided components well enough to understand (at least for the most part) how it works, so I was successful in bringing it into my own project.

lbernstone
Posts: 829
Joined: Mon Jul 22, 2019 3:20 pm

Re: Reading temperature and humidity

Postby lbernstone » Sun Nov 10, 2019 4:37 pm

The temperature/humidity sensors have very limited memory, so they save space wherever possible. On a device that measures temperature from 0-100, you can get away with a 10-bit integer register (2^10=1024) to store it, with one decimal place of precision. A float value is 32 bits, and more complicated to process. The assumption is that whatever the sensor hands off to is far more capable of doing the division than the $0.02 chip.

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

Re: Reading temperature and humidity

Postby drwill » Mon Nov 11, 2019 12:15 am

lbernstone wrote:
Sun Nov 10, 2019 4:37 pm
The temperature/humidity sensors have very limited memory, so they save space wherever possible. On a device that measures temperature from 0-100, you can get away with a 10-bit integer register (2^10=1024) to store it, with one decimal place of precision. A float value is 32 bits, and more complicated to process. The assumption is that whatever the sensor hands off to is far more capable of doing the division than the $0.02 chip.
That makes sense. Still, why not convert it in the API so the caller doesn't have to know about your internal optimization?

lbernstone
Posts: 829
Joined: Mon Jul 22, 2019 3:20 pm

Re: Reading temperature and humidity

Postby lbernstone » Mon Nov 11, 2019 2:47 pm

If you are storing the data for processing, it will be more efficient all the way down the line to work with integers rather than decimals. Efficiency = lower cost. APIs are really for computers to interact (efficiently when possible). The presentation to your eyeballs is the only place where it is useful to see decimal places in a fahrenheit value. This is open source, so if you don't like it, write your own library.

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

Re: Reading temperature and humidity

Postby tommeyers » Mon Nov 11, 2019 10:55 pm

Well, my veiw is that "it is what it is"

Regarding cost.

The factors of cost are:
Producibility - How fast can you develop it
Reliability/Resiliency - Does it work correctly and is it prepared for bad inputs
Supportability - If it fails will you be able to diagnose
Readability - Looking at it can you understand how it works
Installability - Easy or hard
Applies to HW and SW

The cost is "Total Cost of Ownership" and it should be minimied.

Efficiency or how fast or how big can be ignored unless they affect the cost factors.(cost for efficiency must exceed delta TCO)

For play stuff this does not apply but for professional work product it is TCO.

If it was me I would add a note to my code to explain the coding of the value; that supports my TCO best.

Tom Meyers Minimising TCO for software fo 50 years
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 » Tue Nov 12, 2019 12:27 am

lbernstone wrote:
Mon Nov 11, 2019 2:47 pm
If you are storing the data for processing, it will be more efficient all the way down the line to work with integers rather than decimals. Efficiency = lower cost. APIs are really for computers to interact (efficiently when possible). The presentation to your eyeballs is the only place where it is useful to see decimal places in a fahrenheit value. This is open source, so if you don't like it, write your own library.
That makes sense, and having come from non-MCU development I'm not used to being so frugal about memory. My question was purely out of curiosity and desire to learn.

Who is online

Users browsing this forum: No registered users and 167 guests