当前位置:网站首页>Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
2022-07-29 03:11:00 【Salted fish brother】
Catalog
【 Function is introduced 】
This system uses single chip microcomputer as the control core , In order to realize the basic control function of portable temperature, humidity and formaldehyde detector . The main functions of the system include : Data processing 、 Start measurement 、 Over standard alarm 、 Keyboard detection . The design of this system adopts the design idea of function modularization , The system is mainly divided into overall scheme design 、 Three parts of hardware and software design .
This design mainly realizes the design of formaldehyde detector , Features include : smoke 、 Temperature and humidity 、 Formaldehyde detection 、 Over standard alarm 、 Keyboard detection 、 Data display, etc .
【 Schematic diagram 】

【PCB】

【 A physical picture 】

【 List of components 】
| specifications | name | label | Number |
| KEY1 | Key | K1, K2, K3 | 3 |
| S8050 | triode | Q2 | 1 |
| 10K | resistance | R3 | 1 |
| 1K | resistance | R4 | 1 |
| 10K | Potentiometer | RT1, RT3 | 2 |
| LCD1602 | liquid crystal | U1 | 1 |
| POW | Power Supply | U2 | 1 |
| SWITCH | switch | U3 | 1 |
| DHT11 | Temperature and humidity sensor | U4 | 1 |
| STM32 nucleus | Single chip microcomputer | U5 | 1 |
| MQ-2 | smoke | U6 | 1 |
| bee | Buzzer | U9 | 1 |
| CON4 | formaldehyde | U34 | 1 |
【 Source program 】
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "adc.h"
#include "timer.h"
#include "usart1.h"
#include "usart3.h"
#include "LCD1602.h"
#include "string.h"
#include "stdio.h"
#include "dht11.h"
#include "stmflash.h"
#define WriteFlashAddress ((u32)0x08010000)// Read and write start address
u16 CH20_MAX_val = 100;// Formaldehyde alarm value
u16 CH2O_mgvalue = 0;// formaldehyde
void Change_data_handle(void);
void SHOW_AND_BAOJING_Handle(void);
u8 KEY_SCAN(void); // Key function
u8 SHOW_BUF[16],SEND_BUF[16];
u8 key,PPM,Temperature,HUM;
u16 PPM_MAX=60,Temperature_MAX=40,HUM_MAX=70;// Initial value of upper limit of smoke temperature and humidity
u16 write_buf[5];
/// Serial port correlation
extern char RxCounter,Usart1RecBuf[64];// A serial port 1 Receive data cache
extern char bUsart1RecFlag; // A serial port 1 Received data flag bit
void save_data()// Store the data
{
write_buf[0]=1111;
write_buf[1]=PPM_MAX;
write_buf[2]=Temperature_MAX;
write_buf[3]=HUM_MAX;
write_buf[4]=CH20_MAX_val;
STMFLASH_Write(WriteFlashAddress,write_buf,5);
}
void read_data()// Reading data
{
static u16 chcek = 0;
STMFLASH_Read(WriteFlashAddress,write_buf,5);
chcek = write_buf[0];
if(chcek != 1111)// When the SCM is first used ,chcek It's not equal to 1111, The following is to save the data , Read again
{
save_data();
delay_ms(100);
STMFLASH_Read(WriteFlashAddress,write_buf,5);
}
PPM_MAX = write_buf[1];// Upper limit of smoke
Temperature_MAX = write_buf[2];// Upper temperature limit
HUM_MAX = write_buf[3];// Upper limit of humidity
CH20_MAX_val = write_buf[4];//PM Upper limit value
if(PPM_MAX > 99 || PPM_MAX<0)PPM_MAX=60;
if(Temperature_MAX > 99 || Temperature_MAX<0)Temperature_MAX=40;
if(HUM_MAX > 99 || HUM_MAX<0)HUM_MAX=70;
if(CH20_MAX_val > 999 || CH20_MAX_val<0)CH20_MAX_val=100;
}
void Get_CH2O(void)// Get formaldehyde
{
char i = 0;
if(Usart1RecBuf[i+5] == Usart1RecBuf[i]+Usart1RecBuf[i+1]+Usart1RecBuf[i+2]+Usart1RecBuf[i+3]+Usart1RecBuf[i+4])// check
{
CH2O_mgvalue = Usart1RecBuf[1]*256 + Usart1RecBuf[2];// Calculate formaldehyde
bUsart1RecFlag = 0;
}
RxCounter = 0;
}
int main(void)
{
u16 test,test_adc;
delay_init(); // Delay function initialization
NVIC_Configuration(); // Set up NVIC Interrupt grouping 2:2 Bit preemption priority ,2 Bit response priority
KEY_IO_Init();
Usart1_Init(9600);// A serial port 3 initialization , Baud rate 9600
TIM2_Int_Init(1000,72-1); // Timer initialization , timing 1MS
read_data();// Start up and read the stored value once
delay_ms(300);
DHT11_Init(); //DHT11 initialization
BEEP_DISENABLE(); // Buzzer initialization
LCD_Init(); // 1602 initialization
Adc_Init(); //ADC initialization
while(1)
{
test_adc = Get_Adc_Average(ADC_Channel_9,20);// Read channel 9 Of AD value ,20ms Read once
PPM = test_adc*99/4096;//12 position AD, hold AD Values are converted to percentages 0~99
PPM = PPM >= 99? 99: PPM;// The maximum value cannot exceed 99
DHT11_Read_Data(&Temperature,&HUM);// Read the temperature and humidity values
Get_CH2O();// Get formaldehyde value
SHOW_AND_BAOJING_Handle();
Change_data_handle();// Press the key to adjust
delay_ms(100);
}
}
extern u8 FLICKER;
void SHOW_AND_BAOJING_Handle(void)
{
unsigned char show_buf[16];// Show cache
if(Temperature >= Temperature_MAX)// Temperature out of limit
{
if(FLICKER)// The over limit display flashes
{
LCD_Write_String(0,0," ");
}
else
{
sprintf(show_buf,"TEMP:%02dC",(u16)Temperature);// Convert the display format to TEMP:00C
LCD_Write_String(0,0,show_buf);// Show
}
}
else
{
sprintf(show_buf,"TEMP:%02dC",(u16)Temperature);// Convert the display format to TEMP:00C
LCD_Write_String(0,0,show_buf);// Show
}
if(HUM >= HUM_MAX)// Humidity exceeds the limit
{
if(FLICKER)// The over limit display flashes
{
LCD_Write_String(9,0," ");
}
else
{
sprintf(show_buf,"HUM:%02d%%",(u16)HUM);// Convert the display format to HUM:00%
LCD_Write_String(9,0,show_buf);// Show
}
}
else
{
sprintf(show_buf,"HUM:%02d%%",(u16)HUM);// Convert the display format to HUM:00%
LCD_Write_String(9,0,show_buf);
}
if(PPM >= PPM_MAX)// Smoke out of limit
{
if(FLICKER)// The over limit display flashes
{
LCD_Write_String(0,1," ");
}
else
{
sprintf(show_buf,"YW:%02d%%",PPM);// Convert the display format to SMOKE:00%
LCD_Write_String(0,1,show_buf);
}
}
else
{
sprintf(show_buf,"YW:%02d%%",PPM);// Convert the display format to SMOKE:00%
LCD_Write_String(0,1,show_buf);
}
if(CH2O_mgvalue >= CH20_MAX_val && FLICKER)// Formaldehyde exceeds the limit
{
LCD_Write_String(7,1," ");
}
else
{
LCD_Write_Char(7,1,CH2O_mgvalue/100+'0');
LCD_Write_Char(8,1,'.');
LCD_Write_Char(9,1,CH2O_mgvalue%100/10+'0');
LCD_Write_Char(10,1,CH2O_mgvalue%10+'0');
LCD_Write_Char(11,1,'m');
LCD_Write_Char(12,1,'g');
LCD_Write_Char(13,1,'/');
LCD_Write_Char(14,1,'m');
LCD_Write_Char(15,1,'3');
}
if(Temperature >= Temperature_MAX || HUM >= HUM_MAX || PPM >= PPM_MAX || CH2O_mgvalue >= CH20_MAX_val)// Temperature, humidity, smoke and formaldehyde exceed the limit
{
BEEP_ENABLE(); // Buzzer alarm
}
else
{
BEEP_DISENABLE();
}
}
u8 KEY_SCAN(void)
{
u8 res = 0;
if(!KEY1)
{
delay_ms(10);
if(!KEY1)
{
while(!KEY1);// stuck
res = 1;
}
}
if(!KEY2)
{
delay_ms(10);
if(!KEY2)
{
while(!KEY2);// stuck
res = 2;
}
}
if(!KEY3)
{
delay_ms(10);
if(!KEY3)
{
while(!KEY3);// stuck
res = 3;
}
}
return res;
}
This paper introduces the key points in the design process , For your reference , If you have errors or don't understand, you can directly write to the author , Or add wechat biyezhan007.
Other information

【 Principle introduction 】
Working principle of smoke sensor :
Smoke sensor is used to detect the smoke concentration in the current place to achieve fire prevention , Ionic smoke sensor is used inside the smoke alarm , It is widely used in various fire alarm systems , Ion smoke sensor is a kind of stable and reliable , Technologically advanced sensors , The performance of fire alarm is better than that of gas sensitive resistor .
Smoke sensors are currently divided into 2 Categories: , They are ionic smoke sensors 、 Photoelectric smoke sensor and gas sensitive smoke sensor . Photoelectric smoke sensors are divided into light reducing and light scattering photoelectric smoke detectors . This design adopts the common gas sensitive smoke sensor , Its working principle is to use tin oxide with low conductivity in clean air , When there is combustible gas in the environment where the sensor is located , The conductivity of the sensor is linearly proportional to the gas concentration , Through the SCM itself AD Digital to analog conversion module , The semaphore can be converted into a digital quantity , Output to MCU , The final display is LCD1602 On the LCD
Smoke sensor is MQ-2 It is a kind of gas sensor . It can be used in gas detection in homes or factories . By reading the relevant chip information, we know that many kinds of gases can be detected . such as : liquid gas 、 alcohol 、 hydrogen 、 Smoke and other gases . Its own advantages are fast response 、 Long service life 、 Good stability 、 Simple circuit design and other characteristics . Smoke sensor is a semiconductor material of tin oxide . When the temperature is 200 To 300 When the degree of , Tin dioxide will absorb oxygen in the air , Increase the resistance . When smoke is detected, it will cause the conductivity of the surface to change , In this way, the value of smoke can be detected . If the output resistance value is lower , It means that the value of the output analog signal is larger .
【 reference 】
[1] Li weiti , Guo Qiang .《 LCD application technology 》 Beijing : Electronic industry press ,2000 year .
[2] Beijing Jingdian PENGYUAN Display Technology Co., Ltd . Inside KS0108B/HD61202 Controller graphic LCD module user manual .
[3] Zhao Maotai .《 Principle and application of intelligent instrument 》 Beijing : Electronic industry press ,2001.
[4] Zhao Xinmin .《 Principle and design of intelligent instrument 》 Harbin Institute of Technology Press ,1995.
[5] Xu Aijun , Peng Aihua .《 SCM high level language CSTM32 Application design 》〔M〕. Beijing Industry Press ,1999.
[6] YanWeiMin Wei-min wu .《 data structure 》 tsinghua university press ,1996
[7] Ma Zhongmei et al .《 Single chip microcomputer C Language application design 》 Beijing : Beijing University of Aeronautics and Astronautics Press ,1997
[8] Li Gang Lin Ling Wang Yan Huang, New concept SCM tutorial . Tianjin University Press ,2004 year
[9] Hua Chengying . Tong Shibai . 《 Fundamentals of Analog Electronic Technology Third Edition 》 Beijing : Higher Education Press , 2004.4.
[10] Ding Yuanjie . 《 Principle and application of single chip microcomputer 》. Beijing : Mechanical industry press ,1993
Without the permission of the author , No plagiarism or reprint , If you have any questions about reprint, please contact the author of private letter or wechat .

边栏推荐
- mycat读写分离配置
- Algorithm --- paint the house (kotlin)
- Li Shuo, vice president of Baidu: it's a good thing that China's labor costs rise with the support of digital technology
- Apache文件管理自学笔记——映射文件夹和基于单ip多域名配置apache虚拟机
- Multi table (Association) query of SQL query data
- C陷阱与缺陷 第3章 语义“陷阱” 3.9 整数溢出
- 力扣刷题之分数加减运算(每日一题7/27)
- C traps and defects Chapter 3 semantic "traps" 3.2 pointers to non arrays
- Unable to start after idea installation
- Unity game special effects
猜你喜欢

The Federal Reserve raised interest rates again, Powell "let go of doves" at 75 basis points, and US stocks reveled

【C】 Array

R language error: compilation failed for package '****‘

Shell编程规范与变量

IDEA安装后无法启动

C语言基础知识点汇总
![[open the door to the new world] see how the old bird of testing plays API testing between applause](/img/79/1bc836cefef24d23e09d9865ff1fba.png)
[open the door to the new world] see how the old bird of testing plays API testing between applause

爆肝整理JVM十大模块知识点总结,不信你还不懂

STC MCU drive 1.8 'TFT SPI screen demonstration example (including data package)

MySQL忘记密码怎么办
随机推荐
IDEA安装后无法启动
Watermelon book learning Chapter 6 -- SVM
服务器运行管理制度
Interpreting AI robots' pet raising and leading fashion trends
增量实时灾备笔记
照片比例校正工具:DxO ViewPoint 3 直装版
Algorithm --- paint the house (kotlin)
年内首个“三连跌” 95号汽油回归“8元时代“
mysql大表联合查询优化,大事务优化,规避事务超时,锁等待超时与锁表
MySql的安装配置超详细教程与简单的建库建表方法
01-sdram: Code of initialization module
Introduction and advanced MySQL (XIV)
Feedback function of conference OA
Self study notes on Apache file management -- mapping folders and configuring Apache virtual machines based on single IP and multi domain names
C语言小项目 -- 通讯录(静态版+动态版+文件版)
生产部署zabbix5.0笔记
MySQL large table joint query optimization, large transaction optimization, avoiding transaction timeout, lock wait timeout and lock table
接口自动化测试实践指导(上):接口自动化需要做哪些准备工作
【打开新世界大门】看测试老鸟如何把API 测试玩弄在鼓掌之间
Verilog:阻塞赋值和非阻塞赋值