SoC Voltage Sensor
Overview
This sample reads one or more of the various voltage sensors an SoC might have and displays the results.
On STM32 targets with an okay st,stm32-vref node and
CONFIG_ADC_STM32_VREFINT_CALIBRATE=y, the voltage reported here should
agree with adc_ref_internal() on any STM32 ADC (the measured rail is
cached SoC-wide). Prefer the ADC API for adc_raw_to_millivolts_dt(); use
this sensor sample for explicit voltage channels (VREF+/VBAT).
Building and Running
In order to run this sample, enable the sensor node that supports
SENSOR_CHAN_VOLTAGE and create an alias named volt-sensor0 to link to the node.
The tail 0 is the sensor number. This sample support up to 16 sensors.
west build -b nucleo_g071rb samples/sensor/soc_voltage
Sample Output
Sensor voltage: 2.99 V