HVUCfxFY

STC Thermohygrometer

 
Overview
I bought a 3D printer and took this opportunity to make a thermometer and hygrometer. During the actual production process, I encountered many difficulties. I printed the board several times before finally completing it. It's usable, but still too rudimentary and needs continuous optimization. 
For hardware, I used an STC32G12K128. Because it has limited functionality and for compactness, I temporarily decided to change it to a 32-pin design. 
The temperature and humidity sensor used is a domestic AHT30 sensor, which is slightly too large. It supports I2C reading (address 0x38).
The display uses a 0.42-inch 16-pin SSD1306 OLED screen, also using I2C operation (address 0x3C).
Power is supplied by Type-C or a 1220 button battery. A lithium battery can also be used. A charging function was added.
The firmware flashing didn't use a serial port chip; instead, it directly used the STC chip's built-in USB CDC function for uninterrupted flashing, 
and supports message communication such as viewing serial logs to a host computer or serial port assistant.
This makes the board design more streamlined. The previously specially brought-out RXD and TXD pin headers were removed. 
Below is a picture of the actual device.
On the software side: 
a debug command was added. Sending the serial port string "TEMP" will receive the current temperature and humidity printed in the serial port log 
. Of course, STC's simulation debugging can also use the chip's built-in simulation function (the official claim of including simulation), allowing you to directly create a simulated chip in the STC-ISP tool. Then, you can simulate it by clicking "Debug" in Keil. 
This thermometer and hygrometer mainly reads the temperature and humidity of the AHT30 via I2C. For the OLED display, the official STC example using the U8G2 library is used. Related example code can be downloaded from the menu in the STC-ISP tool. (You can also go to the official forum for more learning materials, and the forum has a promotion where you can get a free experimental kit for completing 15 video lessons).
For ease of learning, low-power wake-up and other functions were not added. Therefore, this thermometer and hygrometer is inherently power-intensive and not suitable for battery-only use. It is for learning purposes only. However, it can be used if constantly plugged into USB.
If I learn more about related knowledge later... This thermometer and hygrometer will be further optimized. 
The attached file contains the code corresponding to the thermometer and hygrometer shown in the actual product image. 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-28 11:44:48

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号