Project Introduction:
The one I bring today is really cheap and compact. It is only 1.8*1.2CM in size, just the size of a thumb. Although it is compact, it integrates a temperature control circuit implemented by a 32-bit single-chip microcomputer. The overall cost is less than 2 yuan. Why is it so cheap? This is due to Hangshun's 32-bit MCU HK32F030MF4P6, which is only 0.94 yuan on Taobao. When I saw such a cheap MCU, I was moved and immediately placed an order to buy it.

It is because of it that it has achieved ultra-low prices and intelligent temperature control functions. It mainly realizes the following functions:
1. Automatically switch the fan according to the upper and lower limits of temperature;
2. Enter sleep mode after 10 seconds below the lower limit temperature;
3. Use LM321 to realize automatic temperature alarm wake-up function.
Circuit analysis:
1. The temperature sampling circuit

hopes to obtain lower static power consumption, and then according to the existing components in hand, a 50K NTC is selected. In order to facilitate ADC sampling and cooperate with the alarm circuit, a 12K resistor voltage divider is used here. Because the power supply voltage is 3.3V, it will not exceed the maximum value of ADC sampling, so the choice of R1 here is relatively loose, but it will affect the threshold selection of the alarm circuit later, which will be explained in the following circuit.
2. Temperature alarm circuit

The temperature alarm circuit is mainly used to wake up the MCU when it is dormant so that it can enter the working state. The working principle is to use the voltage comparison function of the operational amplifier.
Here we have to talk about it in conjunction with the temperature sampling circuit. First, let's take a look at the NTC graduation table:


Only a part of what we care about is intercepted here, because I hope that the air room can trigger an alarm when the temperature rises to 36 degrees, so that the fan can work. Looking up the table, we know that the center value of the resistance is 31.396K at 36 degrees, so we hope to achieve level flipping at this value to realize the alarm function.
Then we can calculate the voltage divider value of temperature sampling at this time based on this value:
Vadc=Vin*R3/(R1+R3)=3.3*1.396/(12+1.396)≈2.387V
, that is, the LM321 IN- voltage is 2.387V at this time. We can configure the IN+ voltage to be slightly lower or equal to this value. At this time, we can use inverse calculation to obtain the ratio of R2 R5 to screen the value of R2 R5. The calculation formula is as follows:
Vo=Vi*R5/(R2+R5) That is, 3.387=3.3*R5/(R2+R5) converted to R5/R2 = 2.614
With this value, we can screen the voltage divider resistor, but the resistor cannot be too small. If it is too small, the static current will be too large. If it is too large, it will be easily interfered. First assume that R2=4.7K, then R5=12.2K or so, so choose R2=4.7K R5=12K as the nearest choice. After the resistors are selected, calculate whether the actual values meet the requirements:
Vin+ = 3.3*12/(4.7+12)=2.371V.
It is found that the Vin+ value is very close to the Vadc value and slightly lower than the threshold. Let's see if the temperature continues to rise and the threshold can be lowered to trigger the voltage comparator to flip. Assuming that the temperature rises to 37 degrees, the table shows that the NTC center value is 30.126K at this time. Now calculate the temperature sampling value:
Vadc2=3.3*30.126/(12+30.126)≈2.359V.
It can be seen that Vadc2 is lower than the Vin+ value at this time, and the voltage comparator will flip, which can achieve the temperature alarm we need.
Finished product display:



Finally, please watch the video demonstration effect: