Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

johnnyham

macrumors regular
Original poster
Jun 18, 2010
116
0
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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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

macrumors regular
Original poster
Jun 18, 2010
116
0
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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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

macrumors regular
Original poster
Jun 18, 2010
116
0
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 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

macrumors newbie
Jan 27, 2012
2
0
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.0°C TB1T: +31.0°C TB2T: +33.0°C TC0D: +55.8°C TC0P: +51.0°C TCFP: +50.0°C TH0P: +40.8°C TN0D: +53.5°C TN0P: +47.5°C TN1D: +58.0°C TN1d: +0.0°C Th1H: +48.0°C ThFH: +48.2°C Ts0P: +30.2°C Ts0S: +38.8°C )

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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.