PDA

View Full Version : Temperature Sensor




johnnyham
Aug 19, 2010, 12:40 PM
Just curious, but is it possible to access the data from the temperature sensor in an iDevice? Clearly the OS itself can as it gives you an overheating warning, but I couldn't find any info on here or Google about whether or not it could actually be accessed from a user standpoint. I'm assuming that this isn't something Apple has released to the development community at large, but I just thought I'd ask. It'd be nice to develop an app that could actually detect the ambient temperature without relying on Internet data, which does nothing for you if you're indoors or out of service.



robbieduncan
Aug 19, 2010, 01:32 PM
1) The sensor does not detect ambient temperature: it detects CPU die temperature so it's useless for what you want

2) To the best of my knowledge that data is not available anyway

johnnyham
Aug 19, 2010, 08:15 PM
Thanks, I wasn't sure if the temp sensor was a CPU sensor like the ones in Macbooks or if it was a sensor actually in the body of the iPhone. I'd seen it referenced as both in various places. Even then, you'd think that some fun math could possibly calculate an ambient temperature. Not my fort anyways ;) I didn't think it was possible to begin with, but I suppose it's always something I can add to my "do this before getting my AARP card" list.

robbieduncan
Aug 20, 2010, 03:55 AM
Even then, you'd think that some fun math could possibly calculate an ambient temperature.

I don't see how: the temperature reported is a function of how hard the device is working (and whether the battery is being charged). It does not seem likely you could extrapolate an ambient temperature from that.

johnnyham
Aug 20, 2010, 10:28 AM
I don't see how: the temperature reported is a function of how hard the device is working (and whether the battery is being charged). It does not seem likely you could extrapolate an ambient temperature from that.

I was just thinking something more along the lines of getting the average temp of the CPU over a set amount of time, then figuring out some kind of average offset to output an ambient temperature. Wouldn't be terrifically accurate, but interesting nonetheless.

With some deeper Google scouring though, I haven't found anything about APIs for it, although I'm sure it's a private API that has yet to be discovered. Even if you can't get an ambient temperature, it would be nice for curiosity's sake to know what temperature the CPU is running at. One person over at StackOverflow (http://stackoverflow.com/questions/1077324/iphone-temperature-sensor) mentions that there is a CTGetTemperature function in the CoreTelephony API, but I couldn't find any info on it.

I also found an app in the AppStore that gets a temperature reading from a DIY external sensor that plugs in to the headphone jack. Interesting, but not what I was looking for exactly. Maybe we'll see this API unveiled in the distant future...

cnd
Jan 27, 2012, 06:09 AM
I don't see how: the temperature reported is a function of how hard the device is working (and whether the battery is being charged). It does not seem likely you could extrapolate an ambient temperature from that.

I disagree.

If my iPod always lives plugged in, beside my bed, every night - it's clearly going to correctly indicate a hotter morning if the temperature reads is higher today than it was yesterday...

Under OS/X, temps come from a thing called the "SMC" (system management controller). There's apparently a bunch of different ones. Like - dozens even; ( TB0T: +33.0C TB1T: +31.0C TB2T: +33.0C TC0D: +55.8C TC0P: +51.0C TCFP: +50.0C TH0P: +40.8C TN0D: +53.5C TN0P: +47.5C TN1D: +58.0C TN1d: +0.0C Th1H: +48.0C ThFH: +48.2C Ts0P: +30.2C Ts0S: +38.8C )

It's read like this:-

#define SMC_KEY_CPU_TEMP "TC0D"
SMCOpen();
temp = SMCGetTemperature(SMC_KEY_CPU_TEMP);

Since iOS grew out of OS/X, I would imagine the procedure on that is similar...