Temperature Sensors in Mobile Apps
A practical look at on-device temperature sensors — what you can read, what is locked down, and how to ship a temperature feature anyway.
There is no general-purpose ambient temperature sensor on most smartphones, even though the OS has plenty of internal thermometers. This guide shows you what you can actually read — battery temperature, thermal state, the rare `TYPE_AMBIENT_TEMPERATURE` sensor — and how to fall back to the weather API for "what's the temperature outside" features.
Key Takeaways
- iOS does not expose ambient temperature. You can read battery temperature indirectly and the system thermal state via `ProcessInfo.thermalState`.
- Android exposes battery temperature via the BatteryManager and, on a tiny minority of devices, ambient temperature via `Sensor.TYPE_AMBIENT_TEMPERATURE`.
- For "what's the temperature outside?", use a weather API with the user's location.
- Battery and CPU temperature are heavily filtered, intended for safety / throttling, not for showing the user.
Temperature Sensors at a Glance
What It Is & How It Works
What it is. Smartphones contain several temperature sensors — battery, SoC, modem, sometimes ambient — but most are restricted. The two values your app can usually read are battery temperature and the system's thermal state.
How it works. iOS gives you a coarse `ProcessInfo.thermalState` (`nominal`, `fair`, `serious`, `critical`) and lets you observe battery state. Android gives you a numeric battery temperature via the BatteryManager broadcast and, on devices that include one, ambient temperature via the sensor framework.
Units & signal. Android battery temperature is in tenths of a degree Celsius (so 287 = 28.7 °C). Ambient temperature, if present, is in degrees Celsius. iOS thermal state is an enum.
What You Can Build With It
Performance / throttling
Detect when the device is hot and reduce work — lower video quality, pause background tasks, dim a 3D scene.
Example: A live-streaming app that drops to 720p when the device hits the "serious" thermal state.
Battery health hints
Warn the user when battery temperature is high (e.g. while charging in a hot car).
Example: A power-user app that shows a battery health card.
Outdoor temperature display
Use a weather API to display "outside" temperature alongside in-app content.
Example: A jogging app that shows the current outdoor temperature on the run summary.
Ambient temperature on supported devices
On the rare phones with the sensor, show local room temperature in a smart-home dashboard.
Example: A home-automation companion app that uses the phone as a temperature probe in a pinch.
Permissions & Setup
No runtime permission required.
iOS · Info.plist
No special permission keys required.
Android · AndroidManifest.xml
No special permission keys required.
"Temperature outside" features need location permission to call a weather API.
Code Examples
Setup
- Expo: `npx expo install expo-battery` for cross-platform battery state
- iOS: read `ProcessInfo.processInfo.thermalState` and observe `ThermalStateDidChangeNotification`
- Android: register a BroadcastReceiver for `ACTION_BATTERY_CHANGED`, or query `Sensor.TYPE_AMBIENT_TEMPERATURE`
import * as Battery from 'expo-battery';
import { useEffect, useState } from 'react';
export function useBatteryInfo() {
const [info, setInfo] = useState({ level: 0, state: Battery.BatteryState.UNKNOWN });
useEffect(() => {
const a = Battery.addBatteryLevelListener(({ batteryLevel }) =>
setInfo(p => ({ ...p, level: batteryLevel }))
);
const b = Battery.addBatteryStateListener(({ batteryState }) =>
setInfo(p => ({ ...p, state: batteryState }))
);
return () => { a.remove(); b.remove(); };
}, []);
return info;
}Tip: With Newly, you describe the feature you want and the AI agent wires up the sensor, permissions, and UI for you. Try it free.
Best Practices
Use thermal state, not raw temperature, to throttle
iOS's `ThermalState` enum is the supported way to back off when the device is hot.
Don't display battery temperature as a feature
It is filtered, intermittently updated, and varies wildly with charging — usually misleading.
Fall back to weather APIs for "outside" temperature
OpenWeather, WeatherKit (iOS), and Google's weather APIs are accurate, low-bandwidth and require only location.
Always feature-detect ambient temperature
`getDefaultSensor(TYPE_AMBIENT_TEMPERATURE)` returns null on most devices.
Common Pitfalls
No iOS API for ambient temperature
Public iOS APIs do not give you outside temperature. There is no workaround that survives App Review.
Mitigation: Use WeatherKit / a weather provider with location.
Battery temperature ≠ ambient temperature
A charging phone in a 22 °C room can read 35 °C battery temperature.
Mitigation: Never present battery temperature as the room temperature.
Slow update rate
Battery broadcasts and thermal state change every few seconds — they are not real-time.
Mitigation: Design UI for slowly-changing values; debounce reactions.
When To Use It (And When Not To)
Good fit
- Adapting performance based on `ProcessInfo.thermalState`
- Power-user dashboards that surface battery temperature with context
- Smart-home features on the rare devices with ambient temp sensors
- Combining a weather API with local UI for an "outside" reading
Look elsewhere if…
- A "thermometer" app on iOS — it cannot read ambient temperature
- Sub-degree precision health features
- High-rate temperature streaming
- Inferring user location or activity from temperature values
Frequently Asked Questions
Can I read room temperature on iPhone?
No. Apple does not expose any ambient temperature reading. Apps that claim to do so are estimating from your location and weather data.
My Android phone has no `TYPE_AMBIENT_TEMPERATURE` sensor — what now?
That's the norm. Use the weather API approach. The on-device sensor only exists on a handful of older Galaxy and ASUS devices.
How do I detect overheating to throttle work?
On iOS observe `ThermalStateDidChange` and pause expensive work at `serious` or `critical`. On Android use `PowerManager.getCurrentThermalStatus()`.
Is battery temperature private?
No, but it's noisy and shouldn't be shown without context. Some users find it alarming when it normally reads 30+ °C.
Build with the Temperature Sensor on Newly
Ship a temperature sensor-powered feature this week
Newly turns a description like “use the temperature sensor to performance / throttling” into a real React Native app — permissions, native modules and UI included. Full source code is yours, and you can publish to the App Store and Google Play directly from the dashboard.
Want a deeper dive on the underlying APIs? See Expo Sensors, Apple Core Motion and Android sensor framework.
