---
title: "Temperature"
description: "New in v0.17.0. Two handle-less reads in signed integer milli-degrees Celsius: the SoM's on-module ambient sensor, and the SoC's own die (junction) temperature."
source: https://docs.alplab.ai/sdk/api/temperature
---

# `<alp/temperature.h>` — On-module and Die Temperature

New in v0.17.0. Two handle-less reads in signed integer milli-degrees Celsius: the SoM's on-module **ambient** sensor, and the SoC's own **die** (junction) temperature.

## Header

```c
#include <alp/temperature.h>
```

## Quick example

```c
int32_t milli_c;

if (alp_temperature_read_milli_c(&milli_c) == ALP_OK) {
    printf("SoM ambient: %d mC\n", (int)milli_c);
}

if (alp_temperature_read_die_milli_c(&milli_c) == ALP_OK) {
    printf("SoC die:     %d mC\n", (int)milli_c);
}
```

There is nothing to open, hold or select: the on-module manifest carries at most one temperature sensor per SoM, so the API takes no handle and no index.

## Functions

| Call | Reads |
|------|-------|
| `alp_temperature_read_milli_c(int32_t *milli_c)` | The on-module ambient-temperature sensor (e.g. the TI TMP112 on E1M-AEN). |
| `alp_temperature_read_die_milli_c(int32_t *milli_c)` | The SoC die (junction) temperature. When the SoC has several die sensors, the **hottest** is reported — the figure a throttling or protection decision cares about. |

Both write `*milli_c` only on `ALP_OK` and leave it untouched on any error.

The contract is **units and sign only**. The fitted part's resolution (TMP112: 62.5 m°C/LSB) is informational, so a future SoM with a different part changes nothing a caller can observe except the reading's granularity.

### Two different quantities, kept apart on purpose

The die temperature reads far above ambient under load. The two are never folded together, so a SoM can have either, both or neither. The ambient sensor is also kept out of [`<alp/hw_info.h>`](https://docs.alplab.ai/sdk/api/hw-info): `hw_info` is boot-time identity, this is polled telemetry.

Presence of the ambient sensor is a **SoM** fact — it comes from the SoM preset's on-module device population — not a SoC fact, so it is not exposed through [`ALP_HAS()`](https://docs.alplab.ai/sdk/api/capabilities), which is generated per SoC and would wrongly claim the sensor for every SoM sharing that die.

## Return codes

| Code | `alp_temperature_read_milli_c` | `alp_temperature_read_die_milli_c` |
|------|-------------------------------|------------------------------------|
| `ALP_OK` | Valid read. | Valid read. |
| `ALP_ERR_INVAL` | `milli_c` is `NULL`. | `milli_c` is `NULL`. |
| `ALP_ERR_NOSUPPORT` | The build reads no on-module sensor (every non-AEN target today — V2N / V2M modules carry an on-module TMP112 at `BRD_I2C` `0x40`, but the SDK does not read it through this call yet), or a sensor is declared but no driver bound it. | No thermal source: baremetal, a Zephyr tree with no `die-temp0` node (or no driver bound to it), or a Linux kernel with no matching thermal zone. |
| `ALP_ERR_NOT_READY` | A driver bound the sensor but it did not come up (e.g. it NACKs at boot). | The Zephyr device bound but did not come up. |
| `ALP_ERR_IO` | Transfer fault while reading. | Transfer fault (Zephyr), or matching Linux zones exist but none could be read. |

Treat `ALP_ERR_NOSUPPORT` as "this build has no such sensor" and degrade quietly; it is the expected answer on many targets today.

## Coverage in v0.17.0

| Target | Ambient (`read_milli_c`) | Die (`read_die_milli_c`) |
|--------|--------------------------|--------------------------|
| E1M-AEN, Zephyr | Yes — binds the metadata-emitted `alp-temp0` devicetree alias through the upstream Zephyr sensor API (needs `CONFIG_SENSOR`). | Through the upstream `die-temp0` devicetree alias (`SENSOR_CHAN_DIE_TEMP`). The SDK's SoM board trees do not declare it, so it answers only when a SoC or board tree provides one; otherwise `ALP_ERR_NOSUPPORT`. |
| E1M-X V2N / V2M, Linux | `ALP_ERR_NOSUPPORT` | Yes — the hottest `/sys/class/thermal/thermal_zone*/temp` whose `type` begins with `cpu-thermal` (zones are matched by type, never by index). The kernel owns the sensor hardware. |
| Baremetal | `ALP_ERR_NOSUPPORT` | `ALP_ERR_NOSUPPORT` |

On AEN the ambient read goes through the Zephyr sensor driver, never by opening the on-module I2C bus directly: an independent open at a different bitrate would race your own handle on that bus.

## ABI status

`[ABI-EXPERIMENTAL]` — new in v0.17.0.

## See also

- [`<alp/power.h>`](https://docs.alplab.ai/sdk/api/power#som-power-domains) — the temperature sensor is one of the SoM power domains quiesced around STOP
- [`<alp/hw_info.h>`](https://docs.alplab.ai/sdk/api/hw-info) — boot-time module identity
- [Chip catalogue: tmp112](https://docs.alplab.ai/sdk/chips)
