DS18B20 is a digital temperature sensor with wide applicable voltage, simple interface with microprocessor, measuring temperature range of -55~+125℃, accuracy of ±0.5℃. It can directly read out the measured temperature, and can implement 9~l2-bit digital value reading mode according to actual requirements through simple programming. It works in the voltage range of 3—5.5 V, and adopts various packaging forms, which makes the system design flexible and convenient. The set resolution and user-set alarm temperature are stored in the EEPROM and remain unchanged after power off.
This guide explains how to add a DS18B20 one‑wire temperature sensor to the ALIENTEK MiniSTM32 development board and read temperature values. It includes an introduction to the DS18B20, hardware connection details, software implementation, and steps for downloading and testing the code.
The document provides the required circuit connections, source code files (ds18b20.c/h), and a sample main program that initializes the sensor, reads temperature every 200 ms, and displays the result on the LCD and LED indicators. This manual is written in Chinese.
| Temperature range | -55~+125 °C |
|---|---|
| Operating voltage | 3 V–5.5 V |
| Resolution | 9–12 bits |
| Microcontroller used | STM32F103RBT6 |
| Data line connection | PA0 via jumper |
Connect the DS18B20 data pin to the PA0 pin of the board using a jumper, power the sensor with 3‑5.5 V, and ensure the PA0 line is not left floating.
Call the function DS18B20_Get_Temp(), which returns the temperature in 0.1 °C units as a signed short.
The program displays "DS18B20 Check Failed!" on the LCD and flashes the LED, prompting you to check the sensor connection.
The sensor can measure temperatures from –55 °C up to +125 °C.