yig8z

#9th LCSC Electronics Contest# Temperature and Humidity Detector

 
Overview
* 1. Project Function Introduction

This project uses the STM32G0 series chip as the main control chip, paired with the Sensirion SHT40 temperature and humidity sensor module, to measure the ambient temperature and humidity.
For data display, two 3-digit LED displays are used to show the temperature and humidity values ​​respectively.
The software design utilizes the CubeMX graphical interface, allowing for simple configuration of microcontroller resources and automatic code generation.
The casing is designed using Fusion360 and printed using a Tuozhu 3D printer, resulting in a simple and compact finished product after assembly.
*2. Hardware

Overall Schematic Design:
2.1 The main control circuit
uses ferrite beads and capacitors for filtering to improve the power supply stability of the main control chip. A power-on reset circuit is included, but a manual reset circuit is not included.
2.2 The crystal oscillator circuit
uses an external 32.768kHz passive crystal oscillator, reserved for future expansion functions; this project uses an internal crystal oscillator.
2.3 Temperature and Humidity Sensor Circuit
This project uses the Sensirion SHT40 temperature and humidity sensor, which features high accuracy and low power consumption. The SHT40 itself is very small and difficult for beginners to solder. This training camp project provides an SHT40 module; simply solder a 4-pin socket onto the board, plug in the SHT40 module, and it's ready to use—very convenient.
2.4 The tri-state output 8-bit shift register circuit
uses three 595 shift registers to control two digital tubes displaying values. This allows multiple digital tubes to be controlled with only a few main control chip I/O ports. Here, LED1X controls the first digital tube display, LED2X controls the second, and LEDX_DIG controls the common-polarity side of the digital tube.
2.5 Button wake-up and LED test circuit :
The LED test circuit is a test circuit to verify whether the board can work properly after soldering. After the board is soldered, the LEDs can be turned on and off by controlling the level change of the FPIO_TEST pin through the LED lighting program. If the LEDs can be turned on and off normally, it means that your hardware circuit is basically fine (but not completely fine), and the software environment is also basically successfully set up.
The button wake-up circuit provides an interrupt signal to wake up the main control chip from sleep mode and start working.
2.6 Common Cathode 3-Digit LED Display Circuit:
Two 3-digit LED displays show temperature and humidity values ​​respectively. The two displays are directly controlled by three 595 shift registers, which in turn are controlled by an STM32G0 main control chip. The schematic
shows a common cathode LED display, but due to stock shortages at LCSC, a common anode LED display was used instead. The binary values ​​of 0-9 and dots displayed using a common anode LED display are different from those displayed using a common cathode display.
Here is a table showing the correspondence between common anode display values ​​and hexadecimal data:
Furthermore, the software design code differs when using a common anode LED display; refer to the software section for details.
2.7 Battery Powered Circuit
: The temperature and humidity detector uses two AA batteries, and the battery voltage can be detected by the main control chip.
A MOSFET is used for reverse connection protection.
2.8 SWD Download and Debug Interface:
Used for downloading and debugging programs.
*3. PCB Display
3.1 Overall PCB Layout and Routing
3.2 3D View
3.3 Completed Soldering Sample Image
* 4. Software Part

This project's software development uses CubeMX to configure pin functions and generate basic code.
Note:

When setting the TIM14 timer, you need to perform an additional operation in CubeMX called "NVIC Settings" to enable the TIM14 global interrupt for the timer to function correctly.

The code is developed using Keil5. Pay special attention to the displayed values ​​and hexadecimal decimal points on the common anode seven-segment display.
For program burning, ST-Link is used. Make sure to check if your ST-Link is working properly. I couldn't burn the program the first time I used a faulty ST-Link; I had to buy a new one before I could successfully burn the program.
Programming Logic:
1. The main control chip goes to sleep, waiting for an interrupt;
2. When a button is pressed, a falling edge interrupt is triggered, calling the interrupt service function to wake up the program;
3. The program works normally and enters a while loop;
4. The temperature and humidity sensor data is obtained through the I2C program;
5. The temperature and humidity data is sent to the 595 register via GPIO, and then sent to the digital tube. The digital tube displays the data and times the timer;
6. When the timer ends, the program re-enters sleep mode, waiting for the next wake-up.
*5.
3D Shell Fabrication and Printing: The Fusion360 3D shell design requires measuring the position of the digital tube and the position of the SWD download pin header, reserving slots, and printing for installation and testing. If the dimensions do not match, modifications and printing continue. A 3D printer is available for multiple modifications and verifications.
The bottom cover is directly pressed in using an interference fit.
Slots also need to be reserved for the external buttons. A small button is printed, inserted first, and then the temperature and humidity sensor is installed.
Finally, limit switches are set inside the shell to eliminate the need for alignment during installation, making it easier.
 
3D shell printing files
*6, BOM list

 
*7, competition logo verification:

JLCPCB EDA logo and Sensirion sensor text label printed on the physical object.
*8, Demo your project and record a video for upload.

 
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 16:36:25

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号