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.
§Configuration
Config selects the measurement range and clock source. Available clock
sources depend on the chip; see ClockSource.
§Examples
This example measures the chip temperature every second.
let config = Config::default().with_range(MeasurementRange::Minus10To80C);
let mut temperature_sensor = TemperatureSensor::new(peripherals.TSENS, config)?;
let delay = Delay::new();
loop {
let sample = temperature_sensor.get_temperature();
if let Some(celsius) = sample.to_celsius() {
println!("Temperature: {:.2} °C", celsius);
} else {
println!(
"Uncalibrated temperature: {:.2} °C",
sample.to_uncalibrated_celsius()
);
}
delay.delay_millis(1_000);
}§Implementation State
- Interrupts are not supported
Structs§
- Config
- Temperature sensor configuration
- Temperature
- A temperature measurement from one sensor sample.
- Temperature
Sensor - Temperature sensor driver
Enums§
- Clock
Source - Clock source for the temperature sensor.
The list of clock signals that the
TSENS_SCLKmultiplexer can output. - Config
Error - Temperature sensor configuration error.
- Measurement
Range - Measurement range of the temperature sensor.