Measuring temperature - strange results

I used the humidy and pressure sensors to measure the temperature and these were the results:

$ node test_pressure.js
Sending pings every 5 seconds{ pressure: 102208.5, altitude: -73.375, temperature: 32.5 }

$ node test_humidity.js
Sending pings every 5 seconds{ humidity: 74.43267822265625, temperature: 35.39208984375 }

So while the room temperature in my workplace is about 20 degrees, the pressure sensors measures 32.5 and the humidity sensor measures 35.39! It seems that both sensors measure the temperature of the Matrix board and are placed too close to heat sources on the board.

Or am I wrong?

I don’t yet have my Matrix units, but here are some things to consider:

  1. What are the units of the values being reported? Pascals, cm and degrees C? Some unit conversion may be needed.

  2. To reduce the effect of nearby components, use a fan to blow air over the sensors for a few minutes before taking readings, then see if the values look better. If they do, then consider adding a small fan to your Matrix. Of course, this assumes you actually want to measure the ambient environment, and not the Matrix itself.

  3. Many sensors need some form of correction/calibration, both a generic static corrections and one that adapts with time. Most modern sensors have these built-in, but they may need to be enabled and/or configured. Such features will typically be accessed via a lower-level API.

However, it may be best to look at this as an opportunity for you to do some Real Science ™, to perform experiments to “characterize” your sensors. Characterization involves getting answers to questions like:

  • Are your sensors always off by a fixed amount? This is what’s called a “systematic error”, and can be fixed by adding or subtracting that fixed value from each reading. This ensures your sensor will be accurate at at least one value.

  • After removing any systematic error, and assuming the reading still isn’t right across the entire measurement range, is the sensor value at least proportional to the correct value? This is what’s called “proportional” or “geometric” or “multiplicative” error, and can be fixed by multiplying or dividing the reading by a fixed value.

For the math nerds: The above two steps combined will obtain a “Linear Fit”, which can be directly calculated in several ways, including LSBF (Least-Squares Best-Fit).

  • If the reading still doesn’t closely match the correct value after correcting for systematic and proportional errors, then the remaining error, no matter the cause or kind of correction needed, is called “non-linear” error.

Most often, the remedy is to throw our hands in the air and use a simple lookup table with linear interpolation. This can work extremely well, and I’ve often used it in scientific-grade sensors and aircraft instruments.

If you are ambitious, the non-linear errors can be decomposed by two main approaches within the general category of “curve-fitting methods”: Polynomial best-fit and Fourier Analysis.

All calibration/correction methods require the sensor to have one vital feature: Repeatability. We tend to take this for granted, but it is important to measure the amount of randomness or chaos in the readings, and (if possible) identify their sources. The presence of randomness in sensor readings is often due to issues in the circuit board, such as not enough power supply filtering or device decoupling. No matter the source, some randomness can be removed by averaging, but in the end there may always be some left in the processed reading. It is simply not possible for any calibration to do better than the residual randomness in the readings.

But what steps are needed to figure all this out? The first thing is to take as much data as you can easily get, many readings taken under many conditions, over the full useful range.

Ideally, you want to include reference values, readings that reflect fundamental physical constants in nature. For temperature, two convenient values are the melting and boiling point of water (or other fluids in the home, such as alcohol) at standard atmospheric pressure. For humidity, near 0% may be obtained by blowing air over silica gel, and 100% should exist near a pot of boiling water.

Unfortunately, electronics often don’t like getting wet, so we can use another approach: Comparison to a known-accurate (“reference”) instrument. Even cheap home weather stations have remarkably good calibration, so putting your Matrix next to a weather station and recording the data from both may give you all the data needed to calibrate your Matrix.

Finally (or first, if you’ve read this far), it should be very informative to download the datasheets for the Matrix sensor chips, and learn how they are supposed to work. Then read the source code that accesses the sensor, and ensure it is behaving per the datasheet.

More than once I’ve had to take tons of data, read a bunch of data sheets, examine a pile of code, verify the schematics and probe the circuit itself before finding what was making sensor readings misbehave.

But my bet is a fan, with some unit conversion, will do the trick.

1 Like

I would like some answer from the Matrix people.
Is no one measuring temperature?
Has no one noticed the issue?

Hi Harm,

As you said and @BobC explained the errors in the temperature values are mostly due to the heat that comes from the Raspberry Pi processor. This is a common problem for sensors placed on circuits board.
We are doing a lot of measurements and testing different methods to address this with a nice compensation algorithm. You can try some simple methods like using thermal paste and a small heat sink in the sensors or use software based workarounds like making a simple calibration by subtracting the error.
We have some data from a test we did in case you want to use it to improve your measurements.

We will keep you updated in this topic.
Post you result here in the community !


Sorry, my friend, but I am afraid you have a design flaw on your board.
What you are saying has been tried before and nobody got it working reliably and accurately.
Google for it, it’s useless.

I think you should have provided off board sensors for humidity and air pressure that attach to the board with a piece of flatcable and a socket.

I seem to have a similar problem, the temp on my Matrix says about 10 degrees or more above the actual room temperature, but I am not sure its the only problem. My sensors also do not seem to update. At first they all only had zeros on all readings, but after some updating, rebooting and power cycling I got some readings, but they are static. The humidity is also off.

Seems Harm might be right, that its a bit of a design problem to have all of these sensors so close to the Pi? But in my case it might also be more than that, since the readings remain static and only change after a reboot or a power cycle.