XuwMD

#9th LCSC Electronics Contest# Thermometer and Hygrometer

 
Overview
@TOC
LCSC Electronics Competition & Thermohygrometer
Introduction:
A comfortable environment is beneficial for improving the efficiency of PCB design, soldering, and programming. Traditional thermohygrometers have limited functionality, require frequent battery replacements, and cannot activate the air conditioner when the temperature and humidity are unsuitable.
Therefore, with the support of JLCSC, I DIYed a thermohygrometer
with the following functions and features
: Convenience: Powered by two dry batteries;
Low power consumption: Automatic sleep mode, which can be woken up by a button during use
; Automation: Activates the air conditioner's cooling mode when the temperature is too high; turns off the air conditioner when the temperature drops to a suitable level. Activates the air conditioner's dehumidification mode when the humidity is too high; turns off the dehumidification mode when the humidity drops to the set value.
Physical Demonstration
Hardware Design
Power Supply:
This project uses two dry batteries for power. To prevent reverse connection from burning out components, we use a WST3401 as protection and two 10K resistors to sample and determine if the battery is sufficient. It's worth noting that since this is resistor sampling rather than current limiting, accuracy is required. We need to use resistors with a 0.1% error.
This
project uses the STM32G030K6T6 as the main controller, which has a timer, ADC, and communication interface for easy reading of temperature and humidity sensor data. The voltage range is 2.0V to 3.6V, allowing for battery power, which is very convenient. It also has three low-power modes: sleep, stop, and standby. Battery power can be programmed to enter sleep mode to reduce power consumption.
On the PCB layout, the power supply must pass through a filter capacitor before entering the MCU.
The crystal oscillator should be as close to the MCU as possible and grounded, and placed in an area where copper pouring is prohibited. Avoid routing traces on all layers in the crystal oscillator area.
To
save costs and reduce power consumption, we use a digital tube to display temperature and humidity. Here, we use two three-digit numbers to display temperature and humidity. To conserve pin resources, we use the 74 series 595 chip for serial input and parallel output.
In PCB design, we must also pay attention to the following: power supply must pass through a filter capacitor before entering the 595 chip. Due to the dense pin arrangement, GND can be connected to the large copper area on the bottom layer using a wire and via.
Because the digital transistor has many traces, we must avoid frequent crossings and routing to prevent affecting the integrity of the copper area. The
sensor
used is Sensory's SHT40. For convenience, we use modules instead of direct sensor soldering. We use a 1.27mm 4-pin header to connect the modules. The sensor uses I²C communication. Note the use of pull-up resistors
in the PCB design. It's important to note that because this is a temperature and humidity sensor, it should be kept as far away as possible from heat-generating components, and sufficient height should be provided for the module.
Furthermore, according to feedback from group members, this module is very fragile; reverse connection will burn it
out . Pay attention to the orientation during connection.
With the widespread use of home appliances and audio-visual products, infrared remote controls are widely used in various types of home appliances. They are small, have strong anti-interference capabilities, and low power consumption. Generally, a common infrared remote control system consists of two main parts: a transmitter and a receiver. Here, we only have the control part, so we only design the transmitter.
The infrared part uses an 8550 transistor to drive the infrared transmitter. This part controls the air conditioner based on temperature changes. The oscilloscope captures the infrared transmitter signal from
the remote control.
The software design uses oscilloscope signal capture and analysis, along with data search, to roughly deduce that it uses the NEC infrared protocol: preamble + 8-bit user code + 8-bit user inverse code + 8-bit data code + 8-bit data inverse code + stop bit. Here, the infrared data is read using an STC test chamber, and the air conditioner activation data is written into the program. The STC test chamber connects to the computer. The remote control is pointed at this button , and the serial port reads the data . Different remote controls may have slightly different encodings; please operate the actual encoding. u8 SampleTime; IR_SampleCnt++; //Sample + 1 F0 = P_IR_RX_temp; //Save Last sample status P_IR_RX_temp = P_IR_RX; //Read current status if(F0 && !P_IR_RX_temp) //Pre-sample is high, and current sample is low, so is fall edge { SampleTime = IR_SampleCnt; //get the sample time IR_SampleCnt = 0; //Clear the sample counter if(SampleTime > D_IR_SYNC_MAX) B_IR_Sync = 0; //large the Maxim SYNC time, then error else if(SampleTime >= D_IR_SYNC_MIN) //SYNC { if(SampleTime >= D_IR_SYNC_DIVIDE) { B_IR_Sync = 1; //has received SYNC IR_BitCnt = D_IR_BIT_NUMBER; //Load bit number } } else if(B_IR_Sync) //has received SYNC { if(SampleTime > D_IR_DATA_MAX) B_IR_Sync=0; //data samlpe time too large






























else
{
IR_DataShit >>= 1; //data shift right 1 bit
if(SampleTime >= D_IR_DATA_DIVIDE) IR_DataShit |= 0x80; //devide data 0 or 1
if(--IR_BitCnt == 0) //bit number is over?
{
B_IR_Sync = 0; //Clear SYNC
if(~IR_DataShit == IR_data) //Judge data positive and negative codes
{
UserCode = ((u16)IR_UserH << 8) + IR_UserL;
IR_code = IR_data;
B_IR_Press = 1; //Data is valid
}
}
else if((IR_BitCnt & 7)== 0) //one byte receive
{
IR_UserL = IR_UserH; //Save the User code high byte
IR_UserH = IR_data; //Save the User code low byte
IR_data = IR_DataShit; //Save the IR data byte
}
}
}
}
Failure Log
This module records the problems I encountered and their solutions during the hardware and software design and production process of this project. If you encounter the same problems, I hope it will be helpful.

Programming Issues Many users have encountered problems where they cannot program or can only program once. After investigation, it was found that the chip is in sleep mode in low power mode and cannot be programmed. It needs to be woken up before it can be programmed again. Acknowledgements Thanks
to JLCPCB and Sensirion Technologies for providing the learning platform and material support.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-27 12:58:34

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号