1. Introduction
With the development of Internet of Things technology, smart home has gradually become a new trend in people's lives. In this field, humidifiers are not only the key equipment to solve the problem of indoor dryness, but also a very good scene to demonstrate the application of Internet of Things technology. Therefore, I decided to make an intelligent humidifier based on ESP32, integrating hardware modules and developing software to achieve a more intelligent, accurate and convenient indoor air humidity adjustment solution. Before designing, I will comprehensively analyze the humidifier products on the market, study popular Internet of Things platforms, and investigate the best hardware equipment to determine the design plan. This humidifier not only realizes the intelligent adjustment of indoor humidity, but also pays attention to user experience and data display. Therefore, the design includes the full-link implementation from hardware to software, such as water level sensor, temperature and humidity sensor, circuit board design, motor drive circuit, water tank temperature management, lighting platform, APP, etc. I hope that this project can not only provide convenience for solving practical problems in people's daily life, but also provide reference and inspiration for more Internet of Things developers, and explore the infinite possibilities of the development of Internet of Things technology together.

Humidifier effect

Using ESP32 as the core of the Internet of Things, an intelligent Internet of Things humidifier that can be adjusted according to external temperature and humidity.
It comes with a water level detector, which will prompt when the water level is insufficient.
It comes with an OLED screen that can display temperature, humidity and water level information.
It comes with a motor drive circuit to fan out the water vapor better.
The principle block diagram is as follows:
2. Circuit principle
2.1 Ultrasonic humidification
Humidifiers generally use ultrasonic waves to atomize water, and blow the atomized water vapor out of the shell through a fan to achieve the effect of humidifying the air.
The ultrasonic humidifier uses ultrasonic high-frequency oscillation at a frequency of 1.7MHZ to atomize water into ultra-fine particles of 1 to 5 microns, and then diffuses the water mist into the air through a pneumatic device, making the air moist and accompanied by rich negative oxygen ions, which can refresh the air, promote health, and create a comfortable environment.
The core circuit diagram is as follows:
5V is passed through the U8 triangle inductor, one of the pins is connected to the MOS tube, IO2 is connected to ESP32, and high-frequency PWM is issued through ESP32, so that the voltage output is about 60V (similar to inversion), thereby driving the ultrasonic module to work. The ultrasonic module wiring is located in U2

2.2 Charging and power path management
Charging uses a single-cell lithium battery charging chip TP5100, which is a switching power management chip.
The power path management is as follows:

When the battery is not plugged in, the 3.7V lithium battery directly powers the system.

When charging with 5V, in addition to charging the battery for the charging chip, it also powers the system.

Since the system needs to accept 3.7V lithium batteries and use 5V power supply, a unified voltage is required, so a boost circuit needs to be added to raise the battery voltage to 5V. There are

also some devices in the system that need to use 3.3V power supply, so there is also a 5V-3.3V DCDC step-down

2.3 The motor drive circuit
uses a MOS tube to drive the motor to fan out the water vapor. The fan interface is in U6, with positive on top and negative on the bottom. The speed can be controlled using IO16's PWM.
3. Sensor
3.1 DHT11 temperature and humidity sensor

DHT11 can detect the humidity and temperature of the surrounding environment. It is inserted into U7 in the form of a module.
3.2 Water level sensor
The water level sensor measures the amount of water droplets through a series of exposed parallel wire traces to determine the water level. Easily complete the conversion of water volume to analog signal, and the output is

directly connected to the ADC pin of ESP32 in the analog signal circuit.

The water level sensor can be directly inserted under the board, and pay attention to the positive and negative

4. BLINKER Internet of Things Platform
The Internet of Things platform uses BLINKER, and the platform uses Arduino (C++)
Lighting Technology:
https://diandeng.tech/home
Arduino (C++) SDK:
https://github.com/blinker-iot/blinker-library
SDK Guide:
https://diandeng.tech/doc/arduino-support
APP Download:
https://github.com/blinker-iot/blinker-app
4.1 Basic introduction of blinker solution

1. blinker is a set of IoT device development and deployment solutions. The core is to establish communication and interaction standards between devices and between devices and clients 2. The blinker server is only responsible for necessary functions such as user management, device management, and data storage 3. For devices connected to WiFi, remote communication is forwarded via a transmission intermediary, and data is not stored on the server; local LAN communication is carried out through webSocket 4. Ble access devices communicate by directly connecting to mobile phones 5. blinker itself does not limit hardware, hardware peripherals, cloud platforms, and development methods. Developers can freely expand any function (provided that hardware resources are sufficient)
4.2 esp32 uses WiFi access
This project is developed using ESP32 and uses WIFI to access the Internet
esp32 Arduino SDK document:
https://docs.espressif.com/projects/arduino-esp32/en/latest/index.html
5. Core code
5.1 The humidifier PWM
core code is in the humiupdate() function.
As mentioned earlier, the principle of the humidifier is: ultrasonic high-frequency oscillation at a frequency of 1.7MHz, atomizing water into ultra-fine particles of 1 to 5 microns.
In fact, it does not require such a high frequency. Generally, it will oscillate at a frequency of 108kHz. Therefore, we need ESP32 to send a frequency of 108kHz to the ultrasonic circuit.
The core code is as follows:
First judge: the humidity setting is higher than the actual humidity and the humidifier switch is turned on and there is water.
The PWM of IO2 will be turned on, PWM is set to 108kHz, and then various parameters are

connected to the G pole of AO3400 .

The oscilloscope waveform is as follows

. It should be noted that the humidifier needs to be plugged in to turn on this 108k PWM, otherwise the AO3400 tube will be damaged.
5.2
The core code of the DHT11 sensor is in the dht11state() function.

Set the IO port and sensor to DHT11 type in the front and connect them to IO26.


5.3 OLED screen
Before using the screen, we need to use the modeling software to model the icons and Chinese. Due to time constraints, I have already made

the screen function and I put it in oled()

It's quite simple. What we need to do is to fix the unchanged things and change the changing things.
For example, when running, we need to play the fan animation to

indicate the on status, the real-time display of temperature and humidity, etc.

5.4 Blinker networking
This part is the key to networking. Cooperate with the mobile phone APP to
set the key and WIFI information here.

5.4.1 Mobile phone part
For the mobile phone part, just copy and paste the mobile phone code to the configuration interface. Attachment:
Configure the code.txt on the mobile phone.

After creating a new device, click Interface Configuration,

paste the code content in and update it. After

completion, the interface will be like this.

5.4.2 Component part
After seeing the APP configuration, you can think of the components we use.
1. Real-time temperature (Number1)
2. Real-time humidity (Number2)
3. Real-time water volume (Number4)
4. Real-time power (Number3)
5. Humidity setting upper limit (Number6)
6. Slider bar to set humidity (Slider3)
7. Fan switch (Button1)
8. Humidifier switch (Button2)
9. Fan indication (Button3)
10. Humidifier indication (Button4)

5.4.3 Component callback function and button status feedback The
callback function is what we need to execute after pressing or taking action on the APP side.
Take two callback functions as examples:

slider3_callback is the callback function of the slider. Our goal is to set the humidity upper limit to the corresponding value when the APP slides to a certain value.
The APP slider will return a value to us. We only need to assign the sliding value to the upper limit of hmax, and then Number6.print(hmax); return our set hmax to Number6-humidity setting upper limit. In this way, when sliding, it will also give real-time feedback to the humidity setting upper limit on the right side of the slider

. Isn’t it simple?
Let's look at the next button1_callback.
We are making the fan switch (Button1).
What we do is very simple. First, we set this button to be a switch. In the APP,

when the switch is turned on, the APP will return two states "on" and "off".
When we judge that it is turned on, fanstate is set to 1. Later, the system will set the fan state to on for us (it is just set to on, whether it is actually running or not depends on the situation).
Then it will feedback to Button1 as "on" to say that our system has been turned on, and the fan switch on the APP will change
from off

to on.

5.4.4 Data feedback part
is to reduce Low public server resource consumption, APP will limit the time interval for obtaining data and uploading data.
Due to APP restrictions, we only need to place real-time data in the heartbeat package, and the system will synchronize once every 9 seconds.
The function is placed in heartbeat().

We synchronize temperature and humidity, water volume, battery circuit, set humidity, and

the status of each button of the synchronization slider
. In addition, there is manual synchronization. Pressing this button will immediately synchronize the content of the heartbeat package, with no limit on the number of intervals.

5.4.5 Drawing of temperature and humidity historical data curves.
The temperature and humidity historical curves can be displayed in the APP, and the maximum curve that can be stored for one week is

relatively simple

. The data report is stored once every 1 minute.
5.5 System Scheduling
After all the core codes are written, they need to be combined, which requires system scheduling.
It is mainly written in stateupdate()
to update the status of various sensors .

Key scanning

is due to the characteristics of Arduino, and it is finally attributed to the loop.

6. The shell
is drawn using SolidWorks
7. Core device
Humidifier: https://item.taobao.com/item.htm?spm=a1z09.2.0.0.72802e8daQun1W&id=667972237137&_u=uqavhl87ea7
Battery: 14500 lithium battery is enough
Three-pin inductor: https://item.taobao.com/item.htm?spm=a1z09.2.0.0.72802e8daQun1W&id=562674731215&_u=uqavhl8ba6b Inductor parameters: 6*8-22uH/720uH
8. Summary
In this IoT smart humidifier project based on ESP32, the Blinker lighting IoT platform provides great convenience for our development and helps us quickly realize remote control and monitoring functions. At the same time, the application of OLED screen and the integration of water level, temperature and humidity sensors have comprehensively improved the performance of the humidifier. The design and application of the boost circuit, power path management module and motor drive circuit of the TPS61008 chip ensure that the equipment works stably and efficiently, and the use of the 5V to 60V PWM circuit provides an efficient and accurate drive signal for the motor. Finally, in terms of circuit board design, we used the EasyEDA professional version software for design. This software has a rich resource library and design tools, which makes our circuit board production more accurate, fast and professional. The success of the entire project is inseparable from the integration and synergy of various equipment and technologies, which makes this project have a more reliable, intelligent and efficient user experience. In the future field of the Internet of Things, we will continue to think and explore, develop more intelligent equipment, and create greater practical value for users.