Page 1 of 3

Astro Pi Temperature Sensor Reading

Posted: Mon May 25, 2015 1:17 pm
Hi All.

We are trying to use the astro pi temperature sensor to check readings.
However whenever we get the temperature (get_temperature) it is always around 28 degrees.
i.e. the operating temp of the raspberry pi rather than the air temp around it.

As my kids astro pi competition entry program is trying to measure differences in air temp this is proving tricky.

Questions:
Is there a way to get a true air temp from the astro pi.
Anyone else seeing this problem?
Are they doing something wrong . i.e. does it need calibrating?

Cheers

Phil

Re: Astro Pi Temperature Sensor Reading

Posted: Mon May 25, 2015 4:13 pm
Hello and welcome to the forum.

The temperature/humidity sensor is PCB-mounted so it will be measuring the temperature of the PCB more than the temperature of the air - the sensor is located in a place where heat from other components will have less impact but will still skew the reading upwards.

This is where data fusion comes into play. You do in fact have two temperature sensors onboard - the temperature sensing peripheral inside BCM2835 and the humidity/temperature sensor on the Sense HAT.

The vast majority of the heat that skews the sensor on the sense HAT will come from the Pi itself. BCM2835's temperature sensor is more-or-less ideally placed to measure the "hottest" temperature on the board.

As you have a measurement of the "hottest" point which will be significantly above ambient and a point further away which will be slightly above ambient, it should be possible to get a relatively accurate heuristic that takes the two temperature readings and comes up with a calculated ambient temperature.

Note that the heuristic needs to take into account the ambient conditions! If you're blowing a hair dryer across the board then of course the delta between the sensor and ambient will be different. Same if you were to put the Pi on its side rather than flat on the table (hint: there's a sensor that can detect that). You can train your heuristic estimates with a "true" reading of ambient temperature. If you have enough data points for your ambient/measured deltas then you can curve-fit and extrapolate :]

Re: Astro Pi Temperature Sensor Reading

Posted: Fri May 29, 2015 2:38 pm
Any chance of an example of how to achieve this?

Re: Astro Pi Temperature Sensor Reading

Posted: Wed Jun 03, 2015 2:22 pm
pashworth wrote:Is there a way to get a true air temp from the astro pi.
Anyone else seeing this problem?
Are they doing something wrong . i.e. does it need calibrating?
Hi there, I'll try to answer these below.
• Not without doing your own calibration. As jdb said some heat conducts through the copper top fill of the sense HAT PCB and is picked up by the temperature sensors. The problem is a little less noticeable on a Pi 1 but on a Pi 2 you can see it a lot. It's partly our fault. Ideally we should have pulled back the fill around those sensors to prevent heat conduction however with the close proximity to the main CPU even that might not have achieved much. There is a way you can measure the Pi CPU temperature though (might be useful if you want to compare them). Enter this command at the terminal:

Code: Select all

``vcgencmd measure_temp``
Try spraying an upside down air duster onto the sense HAT for a moment and you should see it picks up negative temperatures from the extreme cooling.
• Yep, everyone.
• You're not doing anything wrong, as I said above it's kind of a design flaw / feature

Re: Astro Pi Temperature Sensor Reading

Posted: Wed Jun 03, 2015 10:29 pm
Thanks for the replies everyone.
This is a little disappointing as it sort of kills my daughters project for which she came in the top 50 ideas awards and got a free astro pi kit.
I do see how it could be calibrated but this is a child's project not an MSc thesis. In addition I've seen the pics of the big metal pi case and it doesn't look like there will be much airflow through that to get a temperature differential. In fact a standard plastic pi case shows this as well.

Its a real shame since a couple of resistors, a capacitor and thermistor on a bread board costing a couple of quid works really well. As does the adafruit temp sensor or a scratch board temp sensor.
Instead we have looked up what the temp is usually set at on the space station and we are using that as a constant. But that sort of defeats the purpose.
We may also tell Tim what the temp of the board is as a cheeky aside.
Thanks for responding.
Phil

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Jun 04, 2015 7:23 pm
Unfortunately, we have to make do. It's the path of least resistance* to design a cuboid box to go into space than a device that's an octopus of wire-attached sensors. The path of least resistance is also the path of best chance of success, so we chose that route in our design for the overall unit, given the timescales that we have to operate under.

In my previous post, I was describing the implementation that would likely result in a calculated temperature that was closest to the actual value. It's complex because there's a large number of variables to consider. You can achieve a rougher approximation with fewer variables.

Experimental data is key. If you can measure and record the CPU temperature, the Sense HAT temperature and a reasonably accurate measure of ambient temperature, what's the relationship between each? If you orient the Pi differently (or put it outside), how do these three measured values change in each case? What changes when you put the Pi inside a case?

If it's any consolation, I have absolutely no idea what the temperature differential between the processor and ambient is going to be when it's on the station. I specified the case dimensions and did a rough calculation to make sure it wouldn't ever get hot enough to burn an Astronaut's fingers, but as to the actual value measured by the sensor on the HAT? Not a clue. The best we can do on Earth is to put Astro-Pi in a vacuum and make some measurements, then do some complex calculations to translate to the temperature of the case in a vaccuum to a case in an atmosphere in zero-gravity.

Data that doesn't meet your expectations is still data - it just requires more analysis to figure out what the factors are that affect it.

* In terms of qualification burden. Qualifying Astro-Pi for flight is a Byzantine maze of rules and regulations - simplifying requirements is the key to ensuring we meet our launch date.

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Jun 04, 2015 9:37 pm
I posted some code recently to log temperature, humidity and pressure. It yielded good results for me.

I left my Astro Pi outside overnight and saw a 15 ish degree swing in the temperature reading using ap.get_temperature()

How come some people are not seeing the delta?

Hang on, just had a thought. I have an RTC board between the HAT and the Pi. Does this create a suitable gap that heat is not transferred?

If so, flight Astro Pi will be OK, as it has the RTC board.

Users with temperature critical code could use longer stand-off's and a header extender?

Re: Astro Pi Temperature Sensor Reading

Posted: Sun Jun 14, 2015 6:22 pm
This doesn't take into account rotation and stuff. However, I've been working on a formula this evening. In my experience, AmbientTemp - ( (CPUtemp - AmbientTemp) / 2 ) is accurate to within a degree or two. Hope this helps someone!

Re: Astro Pi Temperature Sensor Reading

Posted: Tue Jun 16, 2015 12:51 pm
Rotation?

If it can be proven, through analysis perhaps, that the RTC board gives sufficient air gap then the OP's experiment will be valid.

My astro pi is one of the few with the RTC board in between the Pi and The HAT. It's the exact same configuration as the flight unit, and has shown that the sensor can read differing temperatures.

If the OP could raise the HAT off the Pi with headers or a ribbon, they could validate their code.

Think I might put my Astro Pi through a calibrated oven run, to see if there is a delta between ambient and the reading on the sensor.

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Jun 18, 2015 3:40 pm
I did a -10 to +40 run in our test lab yesterday. Astro Pi returned a nice linear response on both of the temperature sensors. Granted, there was a delta between the sensors themselves, and the thermocouple probe, but nothing major.

I will remove the RTC board and re-run it tomorrow, to see what effect it has on the sensors.

Re: Astro Pi Temperature Sensor Reading

Posted: Wed Jul 29, 2015 6:49 pm
It's not an option for the ISS use case but for home use you can connect the astropi via a 40-way ribbon cable and a male-male adaptor. I'll add a photo of my setup when I get to the office.
OK - picture -
IMG_0161.jpg (13.57 KiB) Viewed 29363 times
I'm actually using a 40pin stacker header that passes through the astropi sockets and the cable can just plug on the top. Very convenient.

Re: Astro Pi Temperature Sensor Reading

Posted: Tue Sep 01, 2015 12:32 pm
ThomasS wrote:This doesn't take into account rotation and stuff. However, I've been working on a formula this evening. In my experience, AmbientTemp - ( (CPUtemp - AmbientTemp) / 2 ) is accurate to within a degree or two. Hope this helps someone!
Here is the python code for those who have the same issue:

Code: Select all

``````#!/usr/bin/python
from sense_hat import SenseHat
import os

sense = SenseHat()
temp = sense.get_temperature()
t = os.popen('/opt/vc/bin/vcgencmd measure_temp')
cputemp = cputemp.replace('temp=','')
cputemp = cputemp.replace('\'C\n','')
cputemp = float(cputemp)
newtemp = temp - ((cputemp - temp) / 2)
print("%.1f C" % newtemp)``````
I use it for checking the temps of a house that already had a burst water pipe due to heating failure when no one was in in winter. Really expensive that one

Any improvements to this code are appreciated, its still off by 4 degrees currently (29.5 vs should be around 25.5) but it gets the job done

Re: Astro Pi Temperature Sensor Reading

Posted: Sun Sep 06, 2015 1:51 pm

Placing the "naked" Pi2+Sense HAT in the room, refrigerator and the freezer I got the following function for temperature:
Ta = 0.0071*Tm*Tm+0.86*Tm-10.0
Tm = measured with the temp+humidity sensor
Ta = ambient temperature

It was running Rasbian+a program reading temperature every 5 s+wifi connection. Loading the Pi or Sense HAT more will give different results I assume.

An other problem is that the humidity is measured at the Tm. That means that the ambient humidity is higher than the sensor reading. Approximating from Buck's formula I got:
Ha = Hm*(2.5-0.029*Tm) for temperatures above 0 C.

A program using these approximations:

Code: Select all

``````#Simple meteorology

from sense_hat import SenseHat
import time

sense = SenseHat()

while True :
pressure = sense.get_pressure()
temp = sense.get_temperature()
humidity = sense.get_humidity()
calctemp = 0.0071*temp*temp+0.86*temp-10.0
calchum=humidity*(2.5-0.029*temp)
print '%.0f %.1f %.0f' % (pressure, calctemp, calchum)
time.sleep(5)
``````
I also noted that it takes a long time, ~15 min, for the temperature to stabilize.

Re: Astro Pi Temperature Sensor Reading

Posted: Tue Nov 17, 2015 9:30 pm
So I have been trying to use a 40 pin cable from the Pi to the SenseHat and in one position the Pi won't boot. If I connect it in the orientation as if it was directly connected to the Pi I get Red and Green lights on the Pi and the SenseHat and still no boot. If I disconnect the SenseHat and direct connect to Pi it works.

I'll try and post a picture later but wanted to see if any one had any thoughts. It's a straight through 40 pin cable with a male adapter.

Re: Astro Pi Temperature Sensor Reading

Posted: Wed Nov 18, 2015 4:01 pm
Have you reversed the connections?

IDC cables usually have a differing coloured wire to mark pin#1. You can only attach the IDC connectors to one side of the cable to avoid reversing the polarity of everything.

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Nov 19, 2015 2:56 am
Attached are the components. I oriented exactly as it would be if directly plugged into the pi to avoid the polarity issue. I wonder if it's because the male "converter" I'm using is actually supposed to be surface mount and the pins aren't long enough.

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Nov 19, 2015 9:17 am
Here's my female to male cable showing the connection pins at each end which may help you?

A picture of its orientation on the board in this thread:

viewtopic.php?f=104&t=124571&sid=fa2aee ... 7916fe1ae8

sense-hat extension-cable.JPG (57.12 KiB) Viewed 28082 times

Re: Astro Pi Temperature Sensor Reading

Posted: Fri Nov 20, 2015 9:31 pm
AndersM wrote:Placing the "naked" Pi2+Sense HAT in the room, refrigerator and the freezer I got the following function for temperature:
Ta = 0.0071*Tm*Tm+0.86*Tm-10.0
Tm = measured with the temp+humidity sensor
Ta = ambient temperature

[...]

An other problem is that the humidity is measured at the Tm. That means that the ambient humidity is higher than the sensor reading. Approximating from Buck's formula I got:
Ha = Hm*(2.5-0.029*Tm) for temperatures above 0 C.
Running your code, and comparing it to the T°C provided by my heat system, I'm 3°C below, and I'm quite doubtful about the 100% humidity I got (I'm in France).

On ground floor :
996 17.4 100
996 17.5 101
996 17.4 100
996 17.5 100
996 17.3 101
In my garage (fewmeters below) :
997 16.9 90
997 16.9 90
997 17.1 89
997 16.9 89
997 16.9 90
997 16.9 89
997 16.7 90
997 16.9 89
997 17.0 90
997 16.8 90
So my question is where do these coefficient comes from so that I can see which one I should adjust. I notice that as of today, Sense Hat Temperarture is 5°C higher than my heat system. Applying a basic -5°C is a bit too strict I think.

As of today, the T°C = Ambient temp - (CPU Temp - Ambient Temp)/2 is around +2°C > current temp.

Having a RTC board inbetween RPI2 and Sense HAt does not help much.

Nicolas

Re: Astro Pi Temperature Sensor Reading

Posted: Fri Nov 20, 2015 10:18 pm
Mixing both solution, ie making the average between the two formula may provide the closer/best average so far to ambient temp. I may go this way

Re: Astro Pi Temperature Sensor Reading

Posted: Fri Nov 20, 2015 10:29 pm
Has anyone every found this temperature sensor reading to be accurate at all?

Re: Astro Pi Temperature Sensor Reading

Posted: Tue Dec 01, 2015 11:57 am
I have been using an extension cable as well and was able to get some temperature values from the
• temperature sensor
pressure sensor
humditiy sensor
And if the sense hat board is "reasonable" far away from the Rpi board the values are good enough. The extension cable is about 10cm long.
The three sensors differ around each other with about 1°C at max, compared with two other (random I still had at home) temperature sensors they show same values still with max 1°C from highest to lowest..

What I did notice though is, that by using an extension cable, after about 20 hours (but can happen earlier as well), the temperature sensor and the humidity sensor only give 0 as reported value for temperature or humidity. The pressure sensor on the other hands shows spikes going up in temperature.
Having the sense hat directly connected to the Rpi board all sensors keep reporting "correct" board tempeature values (correct as directly related to the CPU temperature and not to the environment).

Mechanically the extension cable and the board look well connected and the LED matrix and the pressure sensor are still working, so i doubt a bad mechanically connection.

Anybody else experienced this as well?

I log all sensors every 5 mins 24/7 in my apartment and despite being able to use the pressure sensor to get the temperature I find it odd that the temperature sensor and the humidity sensor start reporting only 0s.

One reboot usually does not fixes the 0 value reporting, but the 2nd usually does.

Re: Astro Pi Temperature Sensor Reading

Posted: Tue Dec 22, 2015 10:03 am
I agree with pashworth that there is a relevant design issue in the sense hat.
The temperarute reading is clearly not accurate because of the raspberry cpu heating.
And it's not easy to connect the sense hat with a 40 pin cable in order to avoid heating.
For example while i was trying to transform the sense hat female header in a male header, i've just broken a copper contact.
It's not an "out-of-the-box" add-on for Raspberry

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Dec 24, 2015 7:04 pm
Merry Christmas everyone!

This is my first post, which I guess needs to be verified. So I'll post a simple question here while I wait for that and come up with the list of questions I wanted to ask.

Can the GPIO pins be de-soldered from the board and reattached with a flatter cable between the GPIO and the unit? Would be able to place the SENSE HAT further from the unit. This question goes for all the attachments to the board, or at least the USB's, LAN and GPIO pin setup. Maybe even some of the rest of the stuff like camera input and display input as well.

I purchased the Rasp Pi 2 B and the Sense HAT the 7" touchscreen and a few other things. I have lots of questions but this is a major one. I'm somewhat new to electronics and microelectronics. So if anyone can tell me where to post my big list of questions that would be helpful.

I'll be buying more of these little gadgets too! Also is it possible you guys at Pi could make a Rasp Pi Model 2 B version the Zero?

Re: Astro Pi Temperature Sensor Reading

Posted: Mon Jan 04, 2016 3:55 am
I was a little disappointed myself in the accuracy of the temperature reading.

However, using an amalgam of what I found on this thread I was able to get a fairly accurate approximation of the temperature. I've been tracking it against some hyperlocal weather stations in my area and it's pretty much been within 0.5-1 degree of those reported temperatures (only across a 24 hour period though).

Code: Select all

``````def getCPUtemperature():
res = os.popen('vcgencmd measure_temp').readline()
return(res.replace("temp=","").replace("'C\n",""))

cpuTemp=int(float(getCPUtemperature()))
ambient = sense.get_temperature_from_pressure()

calctemp = ambient - ((cpuTemp - ambient)/ 1.5)``````
I chose to get the temp from the pressure sensor as opposed to the humidity as it's generally about 1.5-2 degrees closer to the actual ambient temperature than the temp from the humidity sensor.

Re: Astro Pi Temperature Sensor Reading

Posted: Thu Jan 07, 2016 8:45 pm
Hello,

I was just wondering if all of your calculations lead to a similar difference between real temp and what the sense hat displays?...

In my case, it is around 4-6 degrees Celsius more than the actual temp, but I think this may vary a lot depending on the processes you are running on your CPU.

I read another post with a similar difference (5 degrees), is it safe to say the difference from the humidity sensor and the actual temp is of about 4 to 6 degrees celsius?

Thanks!