Welcome to STM32-BoardCar repository
6. Internal temperature sensor(ADC)
Internal temperature sensor
Internal temperature sensor1、Software-Hardware2、Brief principle2.1、Hardware schematic diagram2.2、Physical connection diagram2.3、Principle of control3、Engineering configuration3.1、Tips3.2、Pin configuration4、Main functionsHAL library function parsing5、Experimental phenomenon
This tutorial demonstrates: getting real-time temperature from internal temperature sensor via ADC (ADC1_IN16) and printing battery voltage information via serial port (UASRT1) .
1、Software-Hardware
STM32F103CubeIDE
STM32机 robot expansion board
ADC, USART, internal temperature sensor: chip internal peripherals
Type-C cable or ST-Link
Download or simulate the program of the development board
2、Brief principle
2.1、Hardware schematic diagram
由于ADC、USART、内部温度传感器都是芯片内部外设,这里只展示串口相关接口

2.2、Physical connection diagram

2.3、Principle of control
The converted value of internal temperature is obtained through a single-channel ADC, and the value is converted into the actual temperature information and printed out through the serial port.
Internal temperature sensor
The STM32 has an internal temperature sensor that can be used to measure the temperature of the CPU and surrounding devices.
ADC conversion
Adc-related knowledge can be referred to [3. Development Board Basic Tutorial: Voltage Detection]
The internal temperature sensor is internally connected to the ADC1_IN16 input channel, which converts the voltage output of the sensor into a digital value.
Actual temperature:
(Typical values are used here, and the calculated temperature is not exact, but it is possible to observe the temperature change)
3、Engineering configuration
Project Configuration: Prompt for configuration options during STM32CubeIDE project configuration
3.1、Tips
Omitted project configuration: New project, chip selection, project configuration, SYS for pin configuration, RCC configuration, clock configuration, and project configuration content
The project configuration part, which is not omitted, is the key point to configure in this tutorial.
xxxxxxxxxxPlease refer to [2, development environment construction and use: STM32CubeIDE installation - Use] to understand how to configure the omitted part of the project
3.2、Pin configuration
Configure the specified pin function
You can directly select the corresponding pin number in the pin view, and the corresponding option will appear when the mouse is left clicked

ADC

USART


Clock Configuration

Advanced Settings

Generating code

4、Main functions
This paper mainly introduces the functional code written by users. Detailed code can be opened by yourself in the project file we provide, and enter the Bsp folder to view the source code. .
HAL library function parsing
The HAL library functions that were covered in the previous tutorial will not be covered
xxxxxxxxxxFor information on how to parse the HAL and LL libraries that are covered throughout this tutorial, check out the documentation under the STM32 Manual: STM32F1_HAL and LL Library_ User Manual
function:HAL_ADCEx_Calibration_Start
| Function prototypes | HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc) |
|---|---|
| Functional Description | Start the calibration process of the ADC |
| Input parameters | hadc:ADC handle address |
| Return value | HAL status value:HAL_OK、HAL_ERROR、HAL_BUSY、HAL_TIMEOUT |
5、Experimental phenomenon
After downloading the program successfully, press the RESET button of the development board to open the serial debugging assistant to observe the phenomenon
xxxxxxxxxxProgram download can refer to [2, development environment construction and use: program download and simulation]
phenomenon:
The serial debugging assistant will print the following information:
The value converted by the current ADC;
The voltage converted according to the ADC value;
Real-time temperature information from internal temperature sensor.
