Skip to content

[Switch] Expose SoC and PCB temperature to scripts - #26

Open
ferrolho wants to merge 1 commit into
Homebrodot:main/3.5from
ferrolho:feat/switch-thermals
Open

[Switch] Expose SoC and PCB temperature to scripts#26
ferrolho wants to merge 1 commit into
Homebrodot:main/3.5from
ferrolho:feat/switch-thermals

Conversation

@ferrolho

@ferrolho ferrolho commented Aug 25, 2026

Copy link
Copy Markdown

The problem

There is no way to read the console's thermal sensors from a project, so a suspected overheat cannot be diagnosed after the fact. OS has no thermal API, so there is nothing to call from GDScript.

The change

NintendoSwitch.get_soc_temperature()   # Celsius, -1.0 if unavailable
NintendoSwitch.get_pcb_temperature()
NintendoSwitch.get_temperature(NintendoSwitch.TEMPERATURE_SOC)

This follows the pattern already used for the virtual keyboard: methods on the NintendoSwitch singleton, bound through ClassDB. tsInitialize() sits next to psmInitialize() in OS_Switch::initialize(), and tsExit() next to psmExit() in cleanup().

Firmware coverage

tsGetTemperatureMilliC() looks like the obvious choice for precision, but it is documented [1.0.0-13.2.1] and is missing on current firmware, so it is not used here.

Instead this prefers the session API (tsOpenSession and tsSessionGetTemperature, [10.0.0+], returns a float) and falls back to whole-degree tsGetTemperature() on older firmware. Sessions are opened once. If one fails to open, the ones already opened are closed rather than leaked.

Note that TsLocation_Internal is the PCB and TsLocation_External is the SoC, which reads backwards at a glance. The enum here is named TEMPERATURE_PCB and TEMPERATURE_SOC so callers do not have to remember that.

Testing

Tested on a v1 Switch with Atmosphère, docked in an enclosed TV unit, over a 98 minute session sampling at 1 Hz (390 samples):

start end peak
SoC 50.9C 61.2C 61.4C
PCB 47.9C 57.4C 57.4C

Values track load and rise slowly over a long session, which is what an enclosed shelf would suggest. Returns -1.0 cleanly when the sensors are unavailable.

There was no way to read the console's thermal sensors from a project, which makes diagnosing a suspected overheat impossible after the fact.

Adds NintendoSwitch.get_soc_temperature() and get_pcb_temperature(), returning degrees Celsius, or -1.0 when the sensors are unavailable.

Prefers the [10.0.0+] session API (tsOpenSession / tsSessionGetTemperature), which returns a float, and falls back to the whole-degree tsGetTemperature() on older firmware. Note tsGetTemperatureMilliC, the obvious choice for precision, is documented [1.0.0-13.2.1] and is absent on current firmware, so it is not used. Sessions are closed and tsExit() called from cleanup().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant