红水杯

Temperature and humidity alarm based on ESP12-S and Blinker

 
Overview

This work is a design assignment for one of my courses, so I share it here for your reference~

> Modified from my own: Minimum access control system board based on ESP12S

https://oshwhub.com/Aknice/esp12-zui-xiao-ji-tong-ban

Notice! The plate thickness is recommended to be below 1.0

1 Introduction


Taking ESP12-S IoT MCU as the control core, it uses DHT11 temperature and humidity sensor, OLED LCD display, and Blinker mobile client to realize real-time collection, display and over-limit alarm functions of temperature and humidity parameters.The advantage of the system is single-bus serial communication, which simplifies the system structure and saves microcontroller resources. The modular design facilitates system function expansion.

Features:

  1. The PCB is only the size of a 18650 battery, very compact
  2. Installing a 18650 battery (1800 mAh) can last for 18 hours without power supply
  3. Modular design, OLED and DHT11 modules are removable
  4. OLED displays the currently set upper and lower limits, current temperature and humidity status, remaining battery power, battery charging status, and WIFI connection status
  5. Integrated CH340 download circuit
  6. Through the Dian Deng APP, you can remotely view the current temperature and humidity status online, set the upper and lower limits of temperature and humidity, and view the historical curve of temperature and humidity.
  7. Reset and download buttons

2. Research background and significance


With the continuous development of computer technology and the widespread use of computer systems, the computer room environment must meet the technical requirements for computer equipment such as temperature and humidity. The temperature and humidity of the computer room are necessary conditions for the normal operation of computer equipment. We must install temperature and humidity sensors at reasonable locations in the computer room to achieve 24-hour real-time monitoring of temperature and humidity. The system stores medicines, organs, blood bags, vaccines, etc. at specific temperatures and plays an important role in the patient environment and the quality of patient care in the hospital. Regulators have issued temperature and humidity monitoring policies for some perishable items stored in hospitals. Temperature and humidity monitoring solutions improve the patient environment by monitoring current and historical temperatures with complete visibility.At present, various industries are paying more and more attention to product production, item management and warehouse storage. Many warehouses store very important materials, such as tobacco leaves, spinning, medicinal materials, food, etc. In order to maintain the integrity of the quality of warehoused goods and create an environment suitable for commodity storage, when the temperature and humidity inside the warehouse are suitable for commodity storage, we must try to prevent the adverse impact of the climate outside the warehouse on the inside of the warehouse; when it is monitored that the temperature and humidity inside the warehouse are not suitable for commodities During storage, effective measures must be taken in time to adjust the temperature and humidity in the warehouse. Therefore, it has become an industry norm to establish a real-time temperature and humidity monitoring system and save complete historical temperature data. This article will introduce an airThe temperature and humidity detection and alarm system uses a DHT11 temperature and humidity sensor to collect temperature and humidity signals. The data obtained from the collected digital signals are directly sent to the esp12-s microcontroller. The microcontroller then processes the digital signals. The signal processed by the microcontroller will display the temperature and humidity values ​​through the OLED liquid crystal display again. If the data collected by the temperature and humidity sensor is too high, an alarm will be issued through the alarm circuit to remind people that the temperature and humidity in the air are not good for the human body.

It’s all nonsense (laughs)

3.Principle


3.1 Reset circuit and pull-down design

The configuration is configured according to the boot mode in the ESP12-S

2.png

According to the above table, we need to default to the running mode, so we pull up EN, RST, GPIO0, GPIO2, and pull down GPIO15.

As shown in the following schematic diagram: 3.png

3.2 CH340 download circuit

This design uses the CH340C download circuit. Because the chip has its own crystal oscillator, there is no need to connect an external crystal oscillator to pins 7 and 8. If you use CH340G, you need to connect an external 12MHz crystal oscillator, occupying the PCB layout.

In addition, the download mode configuration and reset circuit are designed. That is, when downloading the code, GPIO0 will be pulled low to enter the download mode (see the reset circuit and the startup mode description in the pull-up and pull-down design ). After the download is completed, it will automatically reset and run. 1.png

It can be seen that the completion signal and the start signal are actually connected to two transistors to EN and GPIO0. The download mode and the running mode can be switched through logic transformation. One end of the chip is connected to the USB socket, and the other end is connected to the serial port of ESP12-S.

In addition, an indicator light circuit is designed. When there is a signal (low level), the indicator light will light up.

2.png

3.3 TP4056 lithium battery charging and SX1306 boost module

3.png

U4-TP4056X is a single-cell lithium battery 5V linear charging chip. It is designed based on the typical application diagram in the chip data sheet. It can support a maximum charging current of 1A. It can adjust the charging through the current limiting resistor of R16. For current, I use a 0 ohm resistor here, which means it can be charged at full load at 1A. R17 is connected to the constant current charging current setting and charging current detection terminal of the chip. According to the formula provided in the data sheet, we only need to connect a 1.2k resistor here to ground.

Pin 7 of the chip is the charging status indicator. When charging, pin 7 is low, and pin 6 is the full charge indicator. Therefore, LED4 is a red LED and LED5 is a green LED.

Pin 5 is connected to the battery, but we need to set the C5 22uf filter capacitor close to the chip.

Of course, we must also consider fool-proof design when selecting chips. We used the TP4056A chip before, but there is a problem with this chip. If the polarity of the battery is reversed, the chip will burn. Therefore, we chose the better TP4056X chip. Compared with the A chip, this chip has the same functions. There is no difference in performance, but it has an additional reverse-connection anti-burn design. Even if the battery is installed upside down, the chip will not be burned. Therefore, after discussion, we decided to use the better TP4056X chip.

U5-SX1306 (B628) is a dynamically adjustable boost chip. It is modified based on the boost boost circuit. The chip acts as the switch V in the boost circuit because we use a 18650 lithium battery. Drive, but the 18650 battery voltage is only 3.7V (typical), and some modules require 5V to drive, so this boost circuit needs to be designed.

Pin 1 is the switch pin

Pin 3 is the voltage feedback pin. It sets the voltage boost based on the two feedback resistors R20 and R21. The formula:

Vout=Vref *(1+R20/R21) , where Vref is the reference voltage =0.6V * , then Vout=5.1V (theoretical value ** )

practical testing:

4.jpg

It can be seen that the error of the boost chip is still within the acceptable range, the theory is 5.1V, and the actual value is 5.08V

We use Multisim for simulation. In fact, it is not a simulation, it is a verification.

5.jpg

Current battery voltage, about 4.1V

6.jpg

We use an oscilloscope to measure the 1-pin switch pin of B628. The picture is relatively small. I will write down some important parameters here:

Frequency: 1.064MHz

Positive duty cycle: 74.5%

So we can build a boost circuit

The signal generator and Q1 are equivalent to the B628

Parameter settings and waveforms are as follows

7.png

8.png

9.png

The circuit and results are above

You can see the boost result at 5.122V

The error is not big between the ideal 5.1V and the actual 5.08V. Because the frequency set here is 1MHz and 75% duty cycle, a little error is normal. Therefore, this simulation also verifies that boosting is feasible.

Then I designed a fuse FU1 at the boost output end to prevent accidents. The fuse parameter 6V/1A will activate.

The backend is an AMS1117 linear voltage regulator chip, which regulates the voltage from 5V to 3.3V to power the chip. The reason for using linear is to save cost and save PCB layout. If switching voltage stabilization is used, although the efficiency is high, the cost is also high. A switch Voltage stabilization costs more than 2 yuan, and it also requires additional peripheral components, while switching voltage stabilization costs only a few cents each and does not occupy the PCB layout. The disadvantage is that the efficiency is a little lower, but it doesn't matter.

3.4 ADC battery power measurement module

10.png

In fact, it is relatively simple. It is to use two resistors connected to the battery and change the distributed voltage through different resistor value ratios. This voltage is fed back to the ADC module of the MCU to measure the voltage, and the current battery charge is calculated through an algorithm.

Because the voltage of the 18650 battery is 4.2V when fully charged, typically 3.7V, and drops to 3.0V or even lower when out of power. Therefore, the pressure difference is used to measure electricity. Because the MCU's ADC input has a range, voltage division is required.

3.5  Battery charging status detection

11.png

What we use is not to directly connect the input voltage to the MCU, otherwise the MCU will burn. Therefore, we use PC817 optocoupler isolation as an intermediary. The charging voltage is given to the optocoupler, and the output signal is a 3.3V signal, so that It will not have a major impact on the GPIO of ESP12-S. In addition, a pull-down resistor must be designed at the signal input port, because we want it to be stable at a low level when not charging.

4.PCB display


We adopt a modular design. Both the sensor and the OLED screen can be disassembled and assembled. In addition, the OLED screen is an optional accessory. Because our operation alarm settings are set on the mobile client, the screen is dispensable, and the screen is used as an optional accessory. The most power-consuming and expensive accessory, it is therefore made into a detachable modular design.

The picture below shows the screen and DHT11 sensor

The OLED screen can display:

  1. WIFI connection status
  2. Battery level display
  3. Battery charging status display
  4. The currently set temperature and humidity alarm upper and lower limits
  5. Current temperature and humidity status

12.jpg


The picture below shows only DHT11 sensor 13.jpg

The picture below shows the bare board 14.jpg

In addition, according to the ESP12-S data manual, there should be no wiring on the transmitting antenna, otherwise it will affect the WIFI performance, so I designed the WIFI antenna to be prominent, as shown in the bare board status diagram above. 15.png

The instructions for placing the antenna are as shown in the picture above. We will place them according to #1.

5.Software design


The mobile client uses Blinker 16.jpg

The third-party library functions we use are: Adafruit_Sensor, which contains the DHT11 sensor U8g2lib, which contains the functions to drive our OLED

For the specific preparation method, please refer to the mobile phone (Blinker) configuration method.docx document.

The client has functions such as adjusting the upper and lower limits of temperature and humidity ( restart without memory! ), displaying current temperature and humidity, displaying historical temperature and humidity curves, and displaying power and charging status in the console.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-21 16:54:16

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号