A digital thermometer using STM32F103C8T6 (Blue Pill) that reads temperature from an LM35 sensor and displays it on a 4-digit 7-segment display using two daisy-chained 74HC595 shift registers. The project features register-level ADC reading and SPI communication for optimal performance, providing real-time temperature measurement.
For a more advanced version of this project with multiple sensors, DMA, data logging capabilities, and additional features, check out: STM32_Thermometer_DataLogger
- MCU: STM32F103C8T6 (Blue Pill)
- Temperature Sensor: LM35 (10mV/°C)
- Display: 4-digit Common Cathode 7-Segment Display
- Shift Registers: 2x 74HC595 (daisy-chained)
- Communication: SPI1 for data transfer and GPIO for latch control
- System Clock: 64 MHz (HSI PLL)
- SPI1:
- Data Size: 16-bit mode
- Baud Rate: 16 MBits/s
- Mode: Master, Full-Duplex
- Clock Polarity: Low, Phase: 1 Edge
- First Bit: MSB
- ADC1:
- ADC Clock: 10.667 MHz
- Resolution: 12-bit
- Sampling Time: 28.5 cycles
- Channel: PA0 (ADC1_IN0)
- Firmware developed in
Keil MDK-ARM 5 - Circuit simulation and validation in
Proteus 8
Complete_Proteus_Demo.mp4
Demonstration of the digital thermometer:
- Starts at 1.0°C showing basic temperature display functionality
- Both positive and negative temperature readings
- Voltage divider circuit for negative temperature measurement
- Measurement accuracy within ±0.1°C tolerance
*Schematic designed using EasyEDA*
The schematic shows the complete STM32F103C8T6 implementation including:
- Core Blue Pill circuits: Power supply, 8MHz and RTC clock, reset circuit, decoupling and BOOT circuit
- Display driver: Two daisy-chained 74HC595 shift registers controlling the 4-digit seven segment display
- Temperature sensing: LM35 sensor with voltage divider for negative temperature measurement
| STM32 Pin | Function | Connected To | Purpose |
|---|---|---|---|
PA5 |
SPI1_SCK |
Both 74HC595 SH_CP (Pin 11) | Shift Clock - data synchronization |
PA7 |
SPI1_MOSI |
First 74HC595 DS (Pin 14) | Serial Data - segment/digit data |
PA4 |
GPIO Output |
Both 74HC595 ST_CP (Pin 12) | Latch Control - update outputs |
PA0 |
ADC1_IN0 |
LM35 Output | Temperature sensor reading |
| 74HC595 Pin | Connection | Purpose |
|---|---|---|
Q0 |
Segment A | Display segment A |
Q1 |
Segment B | Display segment B |
Q2 |
Segment C | Display segment C |
Q3 |
Segment D | Display segment D |
Q4 |
Segment E | Display segment E |
Q5 |
Segment F | Display segment F |
Q6 |
Segment G | Display segment G |
Q7 |
Decimal Point | Display decimal point |
Q7'/QH' |
Second 74HC595 DS (Pin 14) | Daisy-chain connection |
| 74HC595 Pin | Connection | Purpose |
|---|---|---|
Q0 |
Digit 1 Cathode | Activate Digit 1 |
Q1 |
Digit 2 Cathode | Activate Digit 2 |
Q2 |
Digit 3 Cathode | Activate Digit 3 |
Q3 |
Digit 4 Cathode | Activate Digit 4 |
Q4-Q7 |
Not Connected | Unused outputs |
| Component | Connection Points | Purpose |
|---|---|---|
R1 (10kΩ) |
3.3V → R1 → R2 | Creates voltage divider for 1.65V reference |
R2 (10kΩ) |
R1 → R2 → GND | Sets midpoint voltage at 1.65V |
LM35 GND |
R1-R2 junction → LM35 GND | Shifts LM35 ground to 1.65V for negative readings |
- STM32F103C8T6 (Blue Pill) Microcontroller
- STM32CubeF1 Firmware Package (includes HAL drivers)
- Keil MDK-ARM 5 with STM32 support
- STM32CubeMX for initial project setup
- Proteus 8 to run the simulation file
- ST-Link Programmer/Debugger
- Clone this repository
git clone https://github.com/rubin-khadka/STM32_Digital_Thermometer.git-
Open CubeMX file
STM32_Digital_Thermometer.iocin STM32CubeMX -
Generate codein CubeMX - this will open the project in Keil 5 -
Build the project and test it with:
- Actual hardware, OR
- Proteus 8 simulation
Proteus_Simulation.pdsprj
If you don't have Keil MDK:
- In CubeMX file
STM32_Digital_Thermometer.ioc, configure the project for STM32Cube IDE - Copy files from
Core/SrcandCore/Incfolders - Copy code from
main.cfile - Build in STM32Cube IDE and test
The project should work with either development environment.
Status: Complete
Version: v1.0
Last Updated: December 5, 2025
Rubin Khadka Chhetri
- Email: rubin.robotic@gmail.com
- GitHub: @rubin-khadka