当前位置:网站首页>Realize a family security and environmental monitoring system (I)
Realize a family security and environmental monitoring system (I)
2022-07-25 14:05:00 【Sunqk5665】
Catalog
- One 、 System requirements analysis and overall design
- Two 、 The hardware design of the system
- 3、 ... and 、 Software design of the system
One 、 System requirements analysis and overall design
1.1 System functional requirements analysis
(1) Use ESP8266 Connect the temperature and humidity sensor 、 Smoke sensor 、 Flame sensor 、 Infrared sensor of human body 、 Ultrasonic distance sensor , Real time collection of family environment , Relevant data is displayed on the screen .
(2)ESP8266 Be able to establish a connection with the cloud , Data can be uploaded to the cloud in real time .
(3) It can make local audible and visual alarm in time for the abnormal information of the monitored family environment , Warn people around , And it can remotely receive real-time alarm information at home from a special window on mobile wechat .
(4) Users can view the real-time environmental conditions in the home and the real-time picture of video monitoring outside the door through wechat applet without being at home .
1.2 Overall design of system structure
The overall architecture of the system :

System function block diagram :
The overall goal of the system is to adopt ESP8266-NodeMCU The control core collects the required environmental data through sensors , The network will MCU The collected data is uploaded to the cloud server , Family members can monitor the internal environment of the family and the real-time video surveillance image outside the door in real time through wechat applet .MCU Be able to perceive the security warning information inside the family in time , It also gives audible and visual alarm and can receive sudden warning messages in time in the security message receiving window of the user's wechat . Form a good real-time 、 Simple deployment 、 Low cost home security and environmental monitoring system .
Two 、 The hardware design of the system
2.1 Overall design of system hardware
The hardware part of this system mainly includes two parts , First, data acquisition , Second, family security . Among them, data acquisition is a very important part of this system , Its main function is to collect environmental parameters in the environment ; Family security , The main function of this part is to alarm some dangerous situations of the family and to view the video monitoring outside the home remotely .
The data acquisition module is mainly used to collect environmental data in the family , The collected data mainly includes temperature and humidity 、 Combustible gas smoke concentration 、 The distance between the door and the ultrasonic distance sensor 、 flame 、 Human body infrared , It can monitor the safety of the home environment in real time . The control core of the whole hardware is ESP8266 controller , because ESP8266 It has both data processing and WiFi Wireless capabilities , therefore ESP8266 Connect WiFi After that, the collected sensor data can be uploaded to the cloud in real time .
Through buzzer and LED Light these two hardware to carry out local audible and visual alarm , It also pushes alarm messages in real time through wechat notification ; The hardware to realize remote video surveillance is ESP32-CAM modular , This module includes a OV2640 camera , There is no connection with ESP8266 The development board has a direct connection to the hardware , only ESP32-CAM The development board and a camera module constitute the hardware part of the remote monitoring .
The hardware design also includes a OLED display , The display screen is mainly used to display the collected environmental data and some alarm information . The hardware structure block diagram of home security and environmental monitoring is shown in Figure 3 Shown .
2.2 Selection and introduction of main control chip
The control core of this system is ESP8266 chip , For development convenience , Use ESP8266-NodeMCU The development board is the control board of the system , The system also uses ESP32-CAM The module is used as a camera module for remote monitoring ,ESP32-CAM The core of the module is ESP32 chip . among ESP8266-NodeMCU Responsible for the collection and upload of family environment data 、 Audible and visual alarm and OLED Screen display ,ESP32-CAM The development board is mainly responsible for the realization of remote monitoring function .
2.2.1 ESP8266-NodeMCU Development board
ESP8266-NodeMCU The main control chip of the development board is ESP8266. It is 32 Bit miniature MCU, with 16 Bit reduction mode , Main frequency support 80 MHz and 160MHz, Integrated WiFi function .
ESP8266 Processor plus WiFi Antenna and so on ESP12-F WiFi modular ,ESP8266-NodeMCU The development board is in ESP12-F WiFi Extended on the basis of modules .ESP8266 It can be done by GPIO Port connected sensors and other application specific devices , This depends on its powerful storage capacity and on-chip processing capacity , Greatly reduce the cost of early development .ESP-12F WiFi The schematic diagram of the module is shown in the figure 4 Shown :
ESP8266-NodeMCU It's an open source IoT Internet of things development board , Because it supports WIFI Function and with Arduino The use of development boards is very similar , You can use it directly Arduino IDE Software development , Greatly simplifies the development process . The design of this project is a project of Internet of things , Use ESP8266-NodeMCU The cost of development board is not high , Than raspberry pie and Arduino The family's IoT Platforms have more advantages .
ESP8266-NodeMCU Pin figure :
2.2.2 ESP32-CAM modular
Because the data flow of the camera exceeds ESP8266 The computing power of microcontroller , Therefore, the video monitoring function of this system adopts ESP32-CAM Module to complete . This module is a small camera module launched by anxinco .
ESP32-CAM The main features :
- use 32 Bit low power dual core CPU
- The main frequency can reach 240MHz, The highest computing power can reach 600 DMIPS
- External 8MB PSRAM, Built in 520KB SRAM
- The supported interface types are SPI/UART/PWM/ADC/I2C/DAC
- The supported camera types are OV2640 and OV7670
- Support TF card
- Support STA/AP/STA+AP Working mode
- Support Smart Config/AirKiss One key distribution network , wait …
2.3 Sensor selection and control introduction
2.3.1 Temperature and humidity sensor
Scheme 1 :
choice DS18B20 Temperature sensor , It's smaller , It is widely used in equipment with small space . Microprocessor and DS18B20 The temperature sensor can realize two-way communication, and the sensor and MCU Only one is needed when connecting IO Line , The measurement results are as follows 9-12 Serial transmission for digital quantity . But because it can only detect temperature , Single function , Therefore, this scheme is not adopted .
Option two :
choice DHT11 sensor , The sensor is a calibrated digital signal output sensor , Only one IO mouth , Easy to program , The important thing is to save MCU Of IO resources .DHT11 There are resistive humidity sensing elements and NTC Temperature measuring element , Combined with temperature and humidity sensing technology and special digital module acquisition technology , Its reliability and stability are greatly improved , It has completely calibrated the measured data , Direct digital output . Self 4 One pin can realize power supply and data transmission without additional component connection , And low power consumption 、 Cost effective features .
In many ways , choose DHT11 It is suitable as a sensor for measuring ambient temperature and humidity .
DHT11 The relevant parameters of temperature and humidity sensor are shown in the table below 3.1 Shown :
| type | Parameters |
|---|---|
| Working voltage | 3.3V-5V |
| Temperature measurement range | -20℃~+60℃ |
| Temperature measurement error | ±2℃ |
| Humidity measurement range | 20% ~ 95%(0~50℃) |
| Humidity measurement error | ±5% |
DHT11 The physical drawing of temperature and humidity sensor module is shown in the figure 7 Shown , The internal circuit schematic diagram is shown in the figure 8 Shown :


It can be seen from the schematic diagram DHT11 Sensors and MCU Connection method of :1 Pin and VCC Pick up ,2 Pin connection DATA,3 Pin for NC Pin , In the air ,4 Pin connection GND, In the power supply and DATA Add a pull-up resistor between pins to improve stability . In this design DHT11 Sensor module DATA Pin connection ESP8266-NodeMCU Of D0(GPIO16) Pin for data transmission .
3.3.2 Flame sensor


The physical drawing of the selected flame sensor is shown in the figure above 9 Shown . The schematic diagram is shown in the figure 10 Shown
The main parameters of the sensor are as follows :
- The wavelength range of flame that can be detected is 760 nanometer ~1100 nanometer
- Detection angle 60 Degrees or so
- The sensitivity can be adjusted
- The working voltage is 3.3~5V
- Digital switching value (0 or 1) Output
In this design, the flame sensor module D0 Pin connection ESP8266-NodeMCU Of D3(GPIO0) Pin for data transmission , adopt D0 The level of pin output determines whether flame is detected .
2.3.3 Smoke sensor
In modern home life , Combustible gases such as natural gas greatly facilitate people's life , In case of leakage, it may cause serious harm . If these leaked gases encounter open flames again , There will be terrible consequences such as fire and explosion . In order to detect whether the combustible gas in the home leaks , choice MQ-2 Smoke sensors detect the concentration of natural gas smoke in the home environment , It is of great significance to ensure the indoor safety of families .
MQ-2 Type a gas sensor uses tin oxide (SnO2) As a combustible gas sensing material , Tin dioxide has less conductivity in clean air , In contact with flammable gases , Its conductivity is positively correlated with the concentration of combustible gases in the air , With the increase of flue gas concentration and conductivity , Its output value will also increase .MQ-2 Type a gas sensor for liquefied gas 、 alkane 、 Hydrogen and other combustible gases are highly sensitive , It can effectively detect the combustible gas in the surrounding air , It has good anti-interference . The sensor has the ability to measure various flammable gases , It is a low-cost sensor , Suitable for many occasions .
MQ-2 Sensor parameters :
| type | Parameters |
|---|---|
| Detect gas | Combustible gas 、 smoke |
| Working voltage | 2.5V-5V |
| Heating power | ≤900mW |
| Detection range | 3000-10000ppm |
In a safe situation , The smoke concentration in the home is maintained in a normal range , therefore , You can set an upper limit on the smoke concentration in your home , When MQ-2 The smoke concentration detected by the smoke sensor exceeds this upper limit , It will trigger the operation of the alarm system , Convey the corresponding alarm information to people .
MQ-2 The schematic diagram of the module is shown in the figure below 12:
In this system ,MQ-2 The gas sensor uses only three pins ,VCC Connect the positive pole of the power supply ,GND Grounding , Analog interface AOUT Pick up ESP8266 Of A0 Interface .ESP8266-NodeMCU By reading the MQ-2 Simulate the value of the port to judge whether the natural gas in the home leaks .
2.3.4 Infrared sensor of human body

To prevent burglary , Pyroelectric infrared sensor is used for monitoring , Pyroelectric infrared sensor has high cost performance , Sensitive and anti-interference , It can effectively prompt people to detect someone nearby , It can play the role of family theft prevention .
Combined with ESP8266-NodeMCU The output voltage is 3.3V, Pyroelectric infrared sensor that can work normally under this voltage is selected ,HC-SR312 The human body sensor module meets this requirement , chart 3.11 It is the physical picture . This module can realize automatic induction , When someone enters the sensing area HC-SR312 The output pin of outputs high level , Output low level when leaving the sensing area or no one enters the sensing area .
HC-SR312 Parameter list of human body induction module :
| type | Parameters |
|---|---|
| Working voltage | 2.7-12V |
| Delay Time | 2 second |
| Blockade time | 2 second |
| Trigger mode | repeatable |
| Sensing range | ≤ 100 Degree cone angle ,3-5 rice |
| working temperature | -20℃~+60℃ |
| Dimensions | 10mm×8mm |
Functional characteristics :
(1) It has good anti-interference performance . Its interior is processed by digital signals , Can be high 、 The low level is directly output from the outside ;
(2) Repeatable trigger mode . After sensing human activity output high level , Within a certain delay period , If there is activity within its perceptual range , Then its output will always be maintained at high level , Until the person leaves the sensing range and the delay ends , Will become low level .
In this design HC-SR312 Human body induction module OUT Pin connection ESP8266-NodeMCU Of D5(GPIO14) Pin for data transmission . The method of flame detection is the same as that of the previous flame sensor , By judgment OUT The level of the pin determines whether someone is active in the current sensing area .
2.3.5 Ultrasonic ranging sensor module
The model of ultrasonic distance sensor selected in this system design is HC-SR04, The physical picture is shown in the picture 14 Shown .


working principle :
(1) use 10us High level signal triggers ranging ;
(2) The module sends out ultrasonic waves , And can automatically detect whether there is echo ;
(3) Ultrasonic signal detected bouncing , Will pass immediately I/O Pin output high level , The time from the emission to the return of ultrasonic wave is the duration of high level . The test distance =( High level time * The speed of sound (340M/S))/2.
Working parameters :
- Working voltage :3.3V-5V
- Quiescent current : Less than 2mA
- Detection angle : No more than 15°
- Detection distance :2cm-450cm
- Highest accuracy : Can be up to 0.3cm
- working temperature :-20℃~80℃
2.4 Introduction to selection and control of display module
In the field of electronic design , The display screen is often used to display data and important messages . Common screen displays are LED The nixie tube shows ,OLED Display and TFT-LCD The screen shows , Here is a brief analysis :
(1)LED The nixie tube shows
LED The nixie tube can only display numbers or characters , And occupy I/O Too many resources , Can't display the Chinese characters or pictures we want .
(2)TFT-LCD screen
TFT-LCD It is the mainstream display screen in the market , This kind of screen can support higher digit color depth , It can also support RGB Color mode , Some can also support touch , The function is all ready . All design requirements are TFT-LCD The requirements of the subject can be realized on the screen , But considering power consumption, size, appearance and other factors , It's not as light and compact as the one with lower power consumption OLED The screen is more suitable for this design .
(3)OLED The screen shows 
More mainstream in the market OLED The screen is 0.96 " OLED display ( Pictured 16) and 1.3 " OLED display , This kind of display adopts the organic diode light-emitting principle , Less materials are needed , It can withstand low temperature , Low power consumption , These two paragraphs OLED The screen can meet the requirements of displaying pictures 、 Chinese characters 、 English and other characters , The resolution can also meet the requirements , The screen interface style is simple , Small and light , It is very suitable as the display module of this topic .
Its schematic diagram is shown in the figure below 17 Shown :
OLED Of SCL and SDA The pins are connected separately ESP8266-NodeMCU Of D1(GPIO5) and D2(GPIO4) Pin , Conduct IIC signal communication .
2.5 Sound and light alarm hardware design
(1) Buzzer is a common sounding element in electronic design , Widely used in electronic equipment . In the system design of this subject , Buzzer is mainly used to give audible alarm for relevant abnormalities . There are two main types of buzzers , One is an active buzzer , The other is a passive buzzer .
The active buzzer has a vibration source inside , You can make it sound just by applying direct current ; There is no vibration source inside the passive buzzer , DC cannot make it sound , need PWM Drive sound .


On the premise that the program is not too complex and the sound alarm effect can be achieved , It is more appropriate to choose the active buzzer as the alarm in this design . Its I/O Pin connection ESP8266-NodeMCU Of D6(GPIO12) Pin , Write a low level to it to sound .
(2) The light part of audible and visual alarm is red LED As a light source . Just power on the alarm when it is needed .
2.6 PCB draw
2.6.1 Schematic drawing

2.6.2 PCB Make
Combine the schematic diagram in Lichuang EDA In software PCB Design , The circuit connection between various components is shown in the figure below 21 Shown .
Set teardrops and lay copper :

PCB After the design 3D Preview :
3、 ... and 、 Software design of the system
Link to : Click the jump 🤫
边栏推荐
- Amd epyc 9664 flagship specification exposure: 96 core 192 threads 480MB cache 3.8ghz frequency
- Lesson of C function without brackets
- Oka pass rights and interests analysis is the best choice to participate in okaleido ecological construction
- Alibaba mqtt IOT platform "cloud product circulation" practice - the two esp32 achieve remote interoperability through the IOT platform
- "Digital security" alert NFT's seven Scams
- Day1: 130 questions in three languages
- 【目录爆破工具】信息收集阶段:robots.txt、御剑、dirsearch、Dirb、Gobuster
- 飞沃科技IPO过会:年营收11.3亿 湖南文旅与沅澧投资是股东
- Common problems in the use of wireless vibrating wire acquisition instrument
- CDA level Ⅰ 2021 new version simulation question 1 (with answers)
猜你喜欢

实现一个家庭安防与环境监测系统(二)
![【Platform IO编译Hifive1-revB】*** [.pio\build\hifive1-revb\src\setupGPIO.o] Error 1的解决办法](/img/a1/de197464e2a735d7ef012cea780da5.png)
【Platform IO编译Hifive1-revB】*** [.pio\build\hifive1-revb\src\setupGPIO.o] Error 1的解决办法

Brush questions - Luogu -p1075 prime factor decomposition

伯克利博士『机器学习工程』大实话;AI副总裁『2022 ML就业市场』分析;半导体创业公司大列表;大规模视频人脸属性数据集;前沿论文 | ShowMeAI资讯日报

实现一个家庭安防与环境监测系统(一)

Internal error of LabVIEW
知名手写笔记软件 招 CTO·坐标深圳

Construction and practice of yolov7 in hands-on teaching

Arduino code of key state machine for realizing single, double click, long press and other functions with esp32 timed interrupt

Digital Twins - cognition
随机推荐
[configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB
百度搜索打击盗版网文站点,SEOer应该关注哪些问题?
Day1:三种语言暴刷牛客130题
Cologne new energy IPO was terminated: the advanced manufacturing and Zhanxin fund to be raised is the shareholder
Mongodb source code deployment and configuration
Tensorflow2 installation quick pit avoidance summary
Leetcode -- addition of four numbers II
Esp32 connects to Alibaba cloud mqtt IOT platform
Wangeditor rich text editor
Data analysis business core
实现一个家庭安防与环境监测系统(二)
What financial products can I invest with some money in my hand?
wangeditor 富文本编辑器
Oka pass rights and interests analysis is the best choice to participate in okaleido ecological construction
伯克利博士『机器学习工程』大实话;AI副总裁『2022 ML就业市场』分析;半导体创业公司大列表;大规模视频人脸属性数据集;前沿论文 | ShowMeAI资讯日报
【力扣】645.错误的集合
word设置粘贴仅保留文本
飞沃科技IPO过会:年营收11.3亿 湖南文旅与沅澧投资是股东
Internal error of LabVIEW
依迅总经理孙峰:公司已完成股改,准备IPO