Introduction to hardware design
Main control selection and minimum system design:
Since we need to design an Internet of Things system, the two most commonly used in our daily life are WIFI and Bluetooth. Since Bluetooth is only suitable for short-distance communication, we chose WIFI as our communication method. As for the main control, we chose the ESP32 main control chip, which is a chip dedicated to the Internet of Things. Compared with stm32, stm32 also needs an external Internet of Things chip, which is very uneconomical from the perspective of hardware cost. Therefore, we think ESP32 is very suitable for this project.
The board is equipped with a USB to serial port chip CP2102 for the convenience of board debugging, and an automatic download circuit is designed. When burning the program, there is no need to perform BOOT and RST operations, which greatly improves the efficiency of board debugging.
Peripheral selection and design:
Since we plan to make a system that connects access control, lights, fans, and air conditioners, we chose the AS608 fingerprint module for access control. AS608 uses serial port communication, and its function is to manage the access control system through fingerprint recognition. The light and fan are simulated by the simplest LED light and small motor. The motor drive circuit is designed with a MOS. Because the maximum drive current of GPIO is 40mA, it cannot drive the motor. Therefore, a MOS is added to enhance the drive capability, and a freewheeling diode is added at both ends of the motor to protect the circuit. As for the air conditioner, we designed a drive circuit for an infrared emitting tube on the board. In
addition to these external control systems, a screen drive circuit is also designed to drive the TFT screen to display necessary information, such as the time and weather obtained from the network, data obtained by the sensor, etc. The screen driver chip is ST7789, with a size of 1.3 inches and a resolution of 240x240, which is just enough for this project.
Functional circuit design:
The board is equipped with two types of environmental sensors, light sensors and temperature and humidity sensors. The light sensor uses a photoresistor model GL5516. The light resistance of the light resistor is 5kΩ~10kΩ per 10Lux. Therefore, in order to use the resistor voltage division, after testing, the voltage division effect with 10kΩ is the best, and the effective range under indoor light intensity is wider and the accuracy is higher. After voltage division, the ADC of the main control can be used to sense the light, and the temperature and humidity sensor uses SHT30, an I2C communication temperature and humidity sensor with an address of 0x44, which is relatively convenient to use. In the production of the circuit board, in order to prevent SHT30 from being affected by the temperature of the circuit board, I specially set up a prohibited copper plating area, which can effectively reduce the impact of the board temperature on the temperature sensor.
Design of the power supply circuit:
The power supply circuit uses a circuit composed of ME6217C33M5G, which is an LDO chip with a maximum power supply circuit of 800mA. I think this is a design failure. We should choose a DCDC, because the circuit power consumption of the device in WIFI is really large, which makes the power chip hot, which is something I didn’t consider.
The following is the software involved process:
Works
