Available on crate feature
unstable
only.Expand description
§Temperature Sensor (tsens)
§Overview
The Temperature Sensor peripheral is used to measure the internal temperature inside the chip. The voltage is internally converted via an ADC into a digital value, and has a measuring range of –40 °C to 125 °C. The temperature value depends on factors like microcontroller clock frequency or I/O load. Generally, the chip’s internal temperature is higher than the operating ambient temperature.
It is recommended to wait a few hundred microseconds after turning it on before measuring, in order to allow the sensor to stabilize.
§Configuration
The temperature sensor can be configured with different clock sources.
§Examples
The following example will measure the internal chip temperature every second, and print it
let temperature_sensor = TemperatureSensor::new(
peripherals.TSENS,
Config::default())?;
let delay = Delay::new();
delay.delay_micros(200);
loop {
let temp = temperature_sensor.get_temperature();
println!("Temperature: {:.2}°C", temp.to_celcius());
delay.delay_millis(1_000);
}
§Implementation State
- Temperature calibration range is not supported
- Interrupts are not supported
Structs§
- Config
- Temperature sensor configuration
- Temperature
- Temperature value
This struct stores the raw ADC value, and can be used to calculate the
temperature in Celsius using the formula:
(raw_value * 0.4386) - (offset * 27.88) - 20.52
- Temperature
Sensor - Temperature sensor driver
Enums§
- Clock
Source - Clock source for the temperature sensor
- Config
Error - Temperature sensor configuration error