Le Zhiwei, Fei Chen, He Chengqian, Smart Windows[Copy link]
Production of Multifunctional Intelligent Window Based on 51 Single Chip Microcomputer
Hubei University of Technology
Electronic Technology Association
Le Zhiwei
Fei Chen
He Chengqian
[img]https://bbs.e Smart home is a hot topic in recent years. A novice who has just come into contact with microcontrollers wants to use some simple sensors to make corresponding alarms or display environmental parameters in real time after being processed by a 51 microcontroller. It is expected to meet the following functions: 1) When rain is detected, the window can be closed (motor rotates) 2) When smoke and toxic gases are detected and exceed a certain standard, the window will be forced to open, and the exhaust fan on the other side (a small motor can be used instead) will work. At the same time, the buzzer will alarm and the light will flash. 3) When someone is stationed outside the window, the infrared heat source will be detected by the pyroelectric probe, and the window will automatically close and alarm.
4) When the temperature or humidity exceeds or falls below a certain standard, the windows can be opened or closed in time. Of course, this action is based on the premise that there is no rain or theft outside.
5) The windows can be opened and closed by pressing buttons in a humanized way.
I have just come into contact with circuit knowledge, so I borrowed some circuits on the Internet. Here I will introduce the various functional circuit modules
System Hardware Selection and Design
Relay Module
The function of the relay module is to control the operation of the motor, and the microcontroller transmits signals to the relay module. The power interface on the relay is located on the right side, connected to the power supply with a DuPont line, and can be connected to a voltage of 12V--20V. The four 2P terminals are its switches, and each switch is an independent module. Each interface is set to NO, A/B, NC. When disconnected, it is connected to NO, and when closed, A/B is connected to NC.
The core of this module is the MQ-2 smoke sensor. Its working principle is to use tin dioxide (SnO2) with low conductivity in clean air as a gas-sensitive material. Its conductivity is proportional to the concentration of combustible gas or smoke in the air. When the measured concentration is greater than the designed concentration, the output is low level. At this time, the light is on and the buzzer sounds to serve as an alarm. After measurement, it is found that the effect of using smoke as a trigger alarm medium is better than that of using combustible gases such as liquefiers. In order to convert the collected analog signal into a digital signal, the ADC0832 chip is used. This chip has a resolution of 8 and has two channels. Only one is needed here. The chip analog voltage input is between 0V-5V, the chip conversion time is extremely short, and the stability is strong. ADC0832 and single-chip microcomputer interface circuit smoke sensor module (physical)
Raindrop sensor module
The raindrop sensor module is designed to prevent rain from entering the room and damaging indoor items when no one is at home due to rain and the windows are not closed. The comparator output of this raindrop sensor has a clean signal, good waveform, strong driving force, over 15MA, and an operating voltage of 3.3V-5V. The sensor is directly connected to the serial port of the minimum system board. When there are no water drops on the sensing board, DO output is high level and the alarm light goes out; when there are water drops on the sensing board, DO output is low level and the alarm light turns on. The microcontroller transmits a signal to the relay module, the switch is closed and powered on, the motor rotates, and the window is closed. Here we use the existing module directly, and we only need to judge whether it is raining, so we can directly connect the digital signal to the microcontroller to judge the high and low levels. :
Housebreaking and robbery have always been a lingering nightmare in people's minds. The human body sensing module designed in this paper can effectively sense people staying in front of the window, which will then trigger an alarm and have an anti-theft effect. The HC-SR501 human infrared sensor module has an output level between 0V and 3.3V, a maximum delay time of 18 seconds, a large sensing range, and a sensing temperature between -15 degrees and 70 degrees. When someone enters the sensing range, a high level is input, the alarm light turns on, and the buzzer sounds. When the person leaves, a low level is input. Moreover, during the delay time of the HC-SR501 human infrared sensor module, if someone continues to move within its detection range, a high level will continue to be input until the detection target leaves.
DHT11The temperature and humidity sensor uses digital signal transmission, the power supply range is between 3.3V-5.5V, the humidity measurement range is 5%-95%, and the temperature measurement range is -20 degrees-60 degrees. After the relative humidity and temperature are measured, the data is transmitted and directly displayed on the LCD display. We place the LCD display on the smallest system board to facilitate viewing of the displayed values.
Schematic diagram of temperature and humidity sensor circuit
3.6Buzzer and indicator light (alarm)
Put the buzzer and indicator light on a module, where you can directly observe the reactions of each main module. The modules corresponding to different indicator lights are as follows:
Because it is convenient to debug a single module, but in the end it has to be connected with Dupont wires, which can easily lead to instability.
[img]https://en.eeworld.com/bbs/static/image/hrline/line7.Let's take a look at the program again.
Put the following function files in a separate folder. Each functional module and the interrupt functions used by the microcontroller system must correspond to a c file and h header file.
The MAIN folder contains the control and main function files
TIMER contains a timer interrupt and delay function
FUNCTION contains a partial function C file and H header file
First, the adc0832 file is used to transmit the data collected by the chip to the microcontroller. Since the chip has two channels to choose from for input, two corresponding functions are used in the C file, but only the smoke module needs to collect data, so when referencing the data receiving function, the transmission function corresponding to the port connected to the actual hardware should be selected. Then comes the dht11 temperature and humidity module file. Since it is just a sensor, a temperature and humidity reading subroutine is required. Finally, there is a check to determine whether the sensor responds. If it responds, it starts to transmit data.
Then there is the eeprom file. This design can set the upper and lower limits of the temperature and remember whether it is in the armed state. The eeprom function can store this information in the microcontroller. The data will not be lost when it is powered on next time, thus avoiding the trouble caused by power outages in real life.
There is also a key file. The key function written is to identify the 6 key operations in this system to achieve different effects. For example, there are 3 keys, namely set, add, and subtract. The number of times you press the set value can determine the upper and lower limits of the set temperature or humidity, and then press the plus and minus keys to add or subtract the temperature preset value according to the actual situation.
The last one is the lcd file, which realizes the display of temperature, humidity and smoke concentration.
MAIN contains the control function and the main function, which includes the entire function function and then runs it. It seems relatively concise and clear.
Here I will show the main function. My programming skills are not good, so the main function is still relatively complicated
#include#include#include#include #include "control.h" #include "timer.h" #include "adc0832.h"[/ size] #include "dht11.h" #include "eeprom.h" #include "key.h" #include "lcd1602.h" int main(void) { [ size=2] unsigned int testnum; EA = 0; Timer0_Init(); //Timer 0 initialization EA = 1; RW=0; L1602_init(); write_1602com(0x85); write_1602dat(0xdf); [ size=2] write_1602com(0x80); write_1602dat('T'); display(); init_eeprom() ; read_eeprom(); write_1602com(0x80); write_string("Te: C Hu: % ");[ /size] write_1602com(0xc0); if(bufang==1) write_string("Sg: mg/m3 B"); else write_string("Sg: mg/m3 ");[/size ] while(mode1) { // K=1; [size =2] while(mo == 0) { mode1=0; mode2=1; } if (FlagStartRH == 1) //Temperature and humidity conversion flag check {[/ size] TR0 = 0; testnum = RH(); FlagStartRH = 0; TR0 = 1; humidity = U8RH_data_H; //Read the temperature and humidity, only take the integer part temperature = U8T_data_H; if(temperature>=TH)//Open the window when it exceeds 30° [size=2 ] {//LED2=0; while(key3!=0) //Open window { n1=1 ; n2=0; while(key3!=0); n1=1; [size =2] n2=1; } } else {LED2=1;BJ_LED2=1;} if(temperature<=TL ) {LED2=0;BJ_LED2=0;} else {LED2=1;BJ_LED2=1;}[ /size] if(humidity>=HH) {//LED4=0; ; } else {//LED4=1; ; }[/size ] if(humidity<=HL) {//LED5=0; ; } else [size=2 ] { ; } } convdata(adc0832(0)); smog=(dis[1]*100+dis[2]*10+dis[3]+1) *10/250; if(flag==0) display(); KEY(); [/size ] if(smog>=SM) // The smoke exceeds the standard,Open windows, exhaust, alarm { LED1=0;BJ_LED1=0; [size= 2] n1=1; n2=0; alarm=0; FS=0; [ size=2] while(key3!=0); n1=1; n2=1; [size= 2] alarm=1; FS=1; } else {LED1=1;BJ_LED1=1;} if(K4==0&&bufang==1) //Someone is staying, close the window, alarm { LED3=0; n1=1;[/size ] n2=0; alarm=0; while(key4!=0); n1 =1; n2=1; alarm=1; } else [size=2 ] if(count==0||count==2000) {LED3=1;} if(BJ_LED1==0||BJ_LED2==0||BJ_LED3==0||(BJ_LED1==0&&bufang==1)) Onealarm(); [size= 2] else alarm=1; n1=1; n2=1; FS=1; while((key3!=0)&&(key1==0)) //key1 manually opens key3 as the limit switch [size =2] { n1=1; n2=0; } while((key4!=0)&&(key2==0)) //key2 manually closes key4 as the limit switch { n1=0; n2=1; } } while(mode2) {[/ size] while (mo == 0) { mode1=1; mode2=0; } if (FlagStartRH == 1) //Temperature and humidity conversion flag check { [size=2 ] TR0 = 0; testnum = RH(); FlagStartRH = 0; TR0 = 1; humidity = U8RH_data_H; //Read temperature and humidity, Only take the integer part temperature = U8T_data_H; if(temperature>=TH)//Open the window when it exceeds 30° {LED2=0;BJ_LED2=0; while((key3!=0)&&(yushui!=0)) //Open the window when there is no rain { n1=1; n2=0;[/size ] if(key3==0) { n1=1; n2=1;[ /size] } } } else { LED2=1;BJ_LED2 =1; n1=1; n2=1; } if(temperature<=TL) {LED2=0;BJ_LED2=0;} else {LED2=1;BJ_LED2=1;} if( humidity>=HH) { ; } else [ size=2] { ; } if(humidity<=HL) {[/size ] ; } else { ;[/size ] } } convdata(adc0832(0)); smog=(dis [1]*100+dis[2]*10+dis[3]+1)*10/250; if(flag==0) display(); KEY(); if((smog>=SM)&&(K1!=0)) // Smoke Exceeding the standard, open the window while the fan turns on and alarms {LED1=0;BJ_LED1=0; n1=1; n2=0; alarm=0; FS=0; while(key4!=0); n1=1; n2= 1; alarm=1; FS=1; } else[/ size] {LED1=1;BJ_LED1=1;} if(K4==0&&bufang==1) //Someone is staying, close the window and alarm {[ /size] n1=0; n2=1; alarm=0; while(key4 !=0); n1=1; n2=1; alarm=1; } else [size=2 ] if(count==0||count==2000) { ; } [size =2] if(BJ_LED1==0||BJ_LED2==0||BJ_LED3==0||(BJ_LED1==0&&bufang==1)) Onealarm(); [size= 2] else alarm=1; n1=1;n2=1;FS=1; while((key4!=0)&&(yushui==0)) //Close the window when it rains { n1=0; [ size=2] n2=1; } while((key3!=0)&&(key1==0)) //Manually open { n1=1; [size= 2] n2=0; } while((key4!=0)&&(key2==0)) //Manually turn off { n1=0; n2=1 ; } } return 0
We only display the temperature, humidity, and smoke concentration (smoke requires methane and other gases). When these indicators are not within the set standard range, the alarm light will turn on. In addition, the rain sensor infrared pyrolysis anti-theft module can also transmit signals normally, but the motor drive module has some faults. In fact, we can directly replace the L298N motor module. From the beginning, we used the relay drive circuit borrowed from others. Although we failed to get it right, we have figured out some circuits. Knowledge.
Experience
[align =left]This work mainly realizes its functions through the combination of TELESKY raindrop sensor; human infrared thermal sensor; MQ2 smoke sensor; DHT11 temperature and humidity sensor. When each sensor changes, the microcontroller executes the corresponding command according to the corresponding change, gives prompts through the buzzer or indicator light, and controls the opening and closing of the window. The cost of completing the work is relatively low, and it is programmed in the most common C language and controlled by a 51 single-chip microcomputer, which is extremely convenient. The possibility of achieving a finished product is relatively high. However, this window control system is not perfect to a certain extent. Some systems only have a simple window opening and closing function, and no voice alarm function. Only buzzer alarm can be used, which makes the user unable to understand what is happening. No matter what the situation is, it is impossible to solve the problem immediately. When the situation occurs, just open or close the window. I have considered using PLC to control, but I have no foundation in this area, and the cost of PLC is high, so it cannot be used at a very low cost. Fast speed into practical use. At the same time, due to the limited time and ability, many planned design ideas were not added to the work, such as using Bluetooth control, The situation is reported to the owner who is out; no exhaust system is installed at the smoke sensor. If the flammable gas or smoke exceeds the standard, the flammable gas or smoke in the room cannot be exhausted at the fastest speed. And the work cannot be debugged due to debugging reasons. Finally, the entire physical design was completed, which was the biggest regret and shortcoming of this design. The attempt at the interlocking relay module mentioned above failed, but the smoke collection module composed of the smoke sensor + AD chip that we tried to manually weld worked. This module can also use ready-made modules directly like the motor driver. For the purpose of learning knowledge, we still do the welding by ourselves. In the future, we will be more confident and skilled when collecting data. Although the whole design is not an excellent work, the complete design process has benefited every member of our team a lot, and we have made great progress in the design of single-chip microcomputer system and language. I have made great progress in programming, electronic circuit design and manual operation. This has laid a solid foundation for more perfect and successful designs in the future.
gif[/img]
Experience
This work mainly realizes its function through the combination ofTELESKY raindrop sensor; human infrared thermal sensor; MQ2 smoke sensor; DHT11 temperature and humidity sensor. When each sensor changes, the microcontroller executes the corresponding command according to the corresponding change, and gives prompts through the buzzer or indicator light to control the opening and closing of the window.
The cost of completing the work is relatively small. It uses the most common C language programming and 51 microcontroller control, which is extremely convenient. It is very likely to achieve a finished product.
However, this window control system is not perfect to a certain extent. Some of the systems only have simple window opening and closing functions, and no voice alarm function. Only buzzer alarm can be used, which makes the user unable to understand what is happening and cannot immediately resolve the situation. When a situation occurs, just open or close the window. I have considered using PLC to control, but there is no foundation in this regard, and the cost of PLC is high, so it cannot be put into practical use at a fast speed.
At the same time, due to limited time and ability, many planned design ideas have not been added to the work, such as using Bluetooth control to reflect the actual situation to the owner who is out; no exhaust system is added to the smoke sensor. If the flammable gas or smoke exceeds the standard, the flammable gas or smoke in the room cannot be discharged at the fastest speed. And because of debugging reasons, the work failed to complete all the physical designs, which is the biggest regret and shortcoming in this design. The attempt to interlock the relay module mentioned above failed, but the smoke collection module composed of the smoke sensor + AD chip that we tried to manually weld worked. This module can also use ready-made modules directly like the motor driver. For the purpose of learning knowledge, we still welded it by ourselves, and we will be more confident and skilled when collecting data in the future.
Although it is not an excellent work, a complete design process has benefited every member of our team. We have made great gains and progress in single-chip computer systems, language programming, electronic circuit design and manual operation. It has laid a solid foundation for more perfect and successful designs in the future.
gif[/img]
Experience
This work mainly realizes its function through the combination ofTELESKY raindrop sensor; human infrared thermal sensor; MQ2 smoke sensor; DHT11 temperature and humidity sensor. When each sensor changes, the microcontroller executes the corresponding command according to the corresponding change, and gives prompts through the buzzer or indicator light to control the opening and closing of the window.
The cost of completing the work is relatively small. It uses the most common C language programming and 51 microcontroller control, which is extremely convenient. It is very likely to achieve a finished product.
However, this window control system is not perfect to a certain extent. Some of the systems only have simple window opening and closing functions, and no voice alarm function. Only buzzer alarm can be used, which makes the user unable to understand what is happening and cannot immediately resolve the situation. When a situation occurs, just open or close the window. I have considered using PLC to control, but there is no foundation in this regard, and the cost of PLC is high, so it cannot be put into practical use at a fast speed.
At the same time, due to limited time and ability, many planned design ideas have not been added to the work, such as using Bluetooth control to reflect the actual situation to the owner who is out; no exhaust system is added to the smoke sensor. If the flammable gas or smoke exceeds the standard, the flammable gas or smoke in the room cannot be discharged at the fastest speed. And because of debugging reasons, the work failed to complete all the physical designs, which is the biggest regret and shortcoming in this design. The attempt to interlock the relay module mentioned above failed, but the smoke collection module composed of the smoke sensor + AD chip that we tried to manually weld worked. This module can also use ready-made modules directly like the motor driver. For the purpose of learning knowledge, we still welded it by ourselves. In the future, we will be more confident and skilled when collecting data.
Although it is not an excellent work, a complete design process has benefited every member of our team. We have made great gains and progress in single-chip computer systems, language programming, electronic circuit design and manual operation. It has laid a solid foundation for more perfect and successful designs in the future.
Awesome, awesome, it really exceeded my expectations Keep it up, I can post a few more posts when I have time, 1: It helps me understand the knowledge 2: Improve my ability to summarize and express
Details
Published on 2018-9-1 19:24
Awesome, awesome, it really exceeded my expectations Keep it up, I can post a few more posts when I have time, 1: It helps me understand the knowledge 2: Improve my ability to summarize and express