Skip navigation

I created this blog post from the information I originally posted in this thread: If I Had a Hammer  made by jack.chaney56 .


1) Using Excel (or other spreadsheets) to compute/visualize the data.

I will consider the STMicroelectronics  HTS221HTS221 as an example. The sensor outputs temperature and humidity in 16-bit registers in 2nd complement format I will now focus only on relative humidity measurement (the temperature is the same. The datasheet states that the output should be linear (related to the humidity) and two reference values are provided (stored in the sensor by STM) - two output registers values at obviously two relative humidity values at which the registers values have been recorded.

In order to make sense of the values, you need to open another application note.


The following pictures are taken from the application note:

So I have read the calibration values over I2C and entered them into an Excel spreadsheet:

Here comes the first surprise, but let's visualize it. I selected the data and notes (B6:D7) and inserted a scatter plot:

Then I made a few minor changes to correspond the plot with possible output values. Double clicking on the X and Y axis show a dialogue where it's possible to set axis bounds (among other thing). Minimum for a 16-bit signed number is −32 768 and maximum is 32 767. I also adjusted the X axis to see -20 to + 120 % values.

You might say we should only adjust the X axis for 0 to 100 value, but this gives us a bit better idea of what values could appear in the output register. Later I found out that one of the sensor outputs about 117 % rH, which is nonsense; while another sensor, SHT21 said it's just about 91 % rH.

Then I added a trend line (right click on one of the values - the blue dot in my case - and selecting Add Trendline...).

Additional dialog is shown with various options. Since we know that out sensor output has linear characteristic, let's stick with linear. We know our values at 32 % and 73 % rH and we would like to see the values through the whole possible spectrum (plus the 20 % surroundings). I edited the forecast values, forward to 47 ( 73 % + 47 % = 120 %) and backward to 52 (32 % - 52 % = -20 %). I also checked Display Equation on chart and display R-squared value on chart.


The result is shown immediately:

As you can see, the output value has different slope than in the datasheet and the application note. However, the math remains the same.


More interesting is the equation and the R-sqared value:

This is another way to compute the sensor output value than using the computation from the application note. (Try it yourself with an calculator.) This makes no sense in this case, of course, since the equation suggested by STM satisfies with integer values. The power of computing and showing the trend line and the R-squared value is in all unknown characteristics. (For example if more values are measured and you are not sure, whether the sensor provides a linear / logarithmic output.) The R-squared value here is 1, which would normally mean a perfect match of the suggested function to the values provided, but we got that because we provided only 2 values. The more values, the better idea of the relation you get.


More about trend lines can be found in this Microsoft Office support article:…

More about R-squared value can be found here:


2) Using Excel (or other spreadsheets) to find the missing data.

Now let's say you can read the humidity register values and compute the relative humidity. What if you wanted to answer the opposite question, what register value will be valid for a specific relative humidity (for example to set some threshold or interrupt directly in the sensor) ?


I created one more column to the table and typed the equation for relative humidity computation:

If I enter my output registers value, I get the relative humidity value.


To do the opposite, we will use a Goal Seek function (Data > What-If Analysis > Goal Seek...)

(In previous Office editions, there was an extension called a Solver (it might not be present in some editions or you might need to enable it. More information on solver can be found in this support article: .)



For example, I would like to know what value will be present in the registers if the humidity is 62,5 %.


So I will enter the following values to the dialog:

We want to set the cell with the humidity value to 62,5 by changing cell with the output register.


After clicking OK, the computation takes a while and shows us the result.

And we have a solution! Well, sort of The output register value is not round, which means we can adjust it to -8206 and/or -8207 and see whether this humidity value difference is OK for our application. (In this case is the sensor noise bigger than the difference between these two values, so I would say it fits.)


Final thoughts

I hope this helps someone


There are also more tools for advanced analysis etc. but I don't feel the confidence in talking about them.


Please note that I am aware that real-life applications are not always that simple as in the examples, but spreadsheets are a huge help for almost everything I do.


TIP: I used Microsoft Office 2016 Professional Plus edition (the full-featured edition, not available for resale). Microsoft has a Home Use Program (HUP) that entitles employees to buy software for which your company has a subscription contract with Microsoft (typically Microsoft Office, Project, Visio), for about 25 $.



Recently, I've been playing with various sensors. I've been interested in measuring air temperature, humidity and pressure. (Didn't get a CO2 and dust sensor yet.)


I thought I could post just a simple idea how to test a range of a humidity sensor. For measuring humidity, I tried SHT21, SHT31 and HTS221 sensors.


The pictures below contain a reference design with SHT21.


  • Very low relative humidity

What is needed: a small plastic bag with working sealing, silica gel (often supplied with shoes).




(It is possible to get even smaller relative humidity, but I didn't want to wait longer than a few minutes.) I also tried to let the bag opened and the silica gel has almost no effect. This means packaging anything with silica gel inside is useful only if the whole package is airtight.


  • Very high relative humidity

What is needed: a bathroom (the smaller and less ventilated, the better results) and someone having a shower / a bath.




(I didn't want to let the water condensate on the sensor, so I stopped at this value.)


SHT21 and SHT31 typically output +/- 2 % RH difference when placed next to each other, they can get as close as +/- 0,5 % RH in home environment after a while (nothing is moving around and there is almost none air movement), From an engineering point of view, humidity accuracy is typically +/-2 % RH for this sensor, which means the 2 decimal digits are only for reference. (Typical temperature accuracy is +/- 0,3 centigrade, so the same applies here.) However, seeing the data interpreted to the LSB gives a nice overview about the stability of output values and the noise present.




Note 2: I also tried 2 pieces of HTS221 sensor and was surprised by the results. One gave the output of 72 % RH , while SHT21/31 showed 59 % (which is about 22 % error). At higher humidity, the difference was even bigger: HTS221 gave output of 117 % RH, while SHT21/31 showed 91 % (which is about 28 % error). The other sensor gave output of 66 % RH while SHT21/31 showed 60 % (which is about 10 % error). Both sensors should have been calibrated and places on ST's reference designs, so I asked a question on ST community hoping to get an explanation of this difference by an ST engineer. I will post some update if I get any response. (I don't want to start a duplicate discussion here.)


I noticed there is a new event combining Microchip's  PICs and click boards from MikroElektronika.…

50 project in 50 days, reminds me of 100 projects in 100 days with PSoc devices (almost 4 years ago).


There is a chance to win some prizes, good luck


In case you've never heard of it, there are still a few days to pick a Humble Book Bundle, stuffed with Arduino and Raspberry Pi books and magazines by Make.


It is a "pay what you want" model (with certain price levels to get all the books) and you decide where the money goes - the publisher, a charity of your choice and/or the Humble Bundle team.


Note 1 : only 5 days remaining.

Note 2: this is not the first (and probably even last) books electronics-related bundle they made.

While browsing for construction ideas, I stumbled upon a construction by guys from MikroElectronika:

So I put out an old metal construction kit I inherited from my father and built a "car" chassis. You can see the result under the original project, in Replications section.


What I like about this construction (I mean the DIY variant, not buying the original kit):

  • easy to build (ca 1 - 2 hours including build the chassis)
  • cheap electronics - ca $10 for the parts, not including power source - my power bank was a giveaway (previously I used 4x NiMH AA battery and a battery holder)
  • cheap chassis - could be made from metal, wood, plastic, maybe even hard paper
  • cheap remote control - I assume almost everyone has a cell phone / tablet with WiFi and HTML5 capable browser
  • easy to expand - remote control software, micro-controller firmware, the hardware - more wheels, sensors, etc.
  • doesn't rely on 3rd party cloud services, registrations, ...


(More images are on the original project page.)


What do you think?