I have been unable to go out due to the epidemic during this period. Looking at the constantly changing data on the large screen of the air detection system opposite my house, I suddenly had an idea: could I make a PM2.5 testing system myself? I just had to do it when I thought about it.
As usual, without further ado, here are the pictures:
Physical picture 1
Physical picture 2
The actual measurement accuracy and precision are still acceptable.
The reference code of PM2.5 detection system is as follows:
host
#include #include "delay.h" #include "LCD12864.h" #include "PM2_5.h" #include "BMP180.h" #include "DHT11.h" #define uint unsigned int #define uchar unsigned char sbit waring=P1^3; void main() { lcd_init(); Init_BMP085(); Init_PM2_5(); while(1) { bmp085Convert(); RH(); lcd_pos(0,0); display_string("pm2.5:"); if(read_pm()>5) display_num(read_pm()); else display_num(5); display_string("ug/m3"); display_string(" "); lcd_pos(1,0); display_string("T:"); display_num(temperature/10); display_string("."); display_num(temperature%10); display_string("'C"); display_string(" "); display_string("H:"); display_num(RHdataH); display_string("%"); lcd_pos(2,0); display_string("pre:"); display_num(pressure/1000); display_string("."); display_num(pressure%1000); display_string("kpa"); lcd_pos(3,0); display_string("smo:"); if(read_pm()>200) { display_string("High"); waring=0; } else { display_string("low"); display_string(" "); warning=1; } display_string("Al:"); display_num(Altitude); display_string("m"); display_string(" "); delay_ms(200); } } PM2.5 #include #define uint unsigned int #define uchar unsigned char #define K_PM 820 void senddata(uchar dat); uint read_pm(); uchar cal[7]={0}; // cal[0]: starting bit 0xAA // cal[1]:Vout(H) // cal[2]:Vout(L) // cal[3]:Vref(H) // cal[4]:Vref(L) // cal[5]: check digit // cal[6]: end bit 0xFF uchar buf; uchar sum; int i=0; float Vo; void Init_PM2_5() { SCON=0x50; PCON=0x00; TMOD=0x20; EA=1; ES=1; TL1=0xF4; TH1=0xF4; TR1=1; } uint read_pm() { return (uint)(K_PM*Vo); } void serial() interrupt 4 { ES=0; RI=0; buf=SBUF; senddata(buf); ES=1; } void senddata(uchar dat) { if(dat0xAA) { i=0; cal[i]=dat; } else { i=i+1; cal[i]=dat; if(i6) { sum=cal[1]+cal[2]+cal[3]+cal[4]; if(sum==cal[5]&&cal[6]==0xFF) { // for(i=0;i<=6;i++) // { // SBUF=cal[i]; // while(!TI); //TI=0; // } Vo=(cal[1]256+cal[2])/1024.05; // SBUF=cal[1]; // while(!TI); //TI=0; // // // SBUF=cal[2]; // while(!TI); //TI=0; } } } } Due to limited space, I can only write this much.
Previous article:Semiconductor refrigeration refrigerator made of single chip microcomputer
Next article:Design of anti-theft system based on single chip microcomputer + human infrared sensor
Recommended ReadingLatest update time:2024-11-16 15:26
- Popular Resources
- Popular amplifiers
- Network Operating System (Edited by Li Zhixi)
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- MATLAB and FPGA implementation of wireless communication
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Kuyuan Electric Allegro video training
- What are the differences between precision op amps, instrument op amps, and general-purpose op amps?
- Detailed explanation of the principle of lora spread spectrum technology
- Questions about oscilloscope and USB flash drive
- EEWORLD University ---- Digital Circuit Design
- Disassembled a solar lamp
- Summary: About 2.4G NRF24L01 wireless module
- What is the difference between a chip's "data sheet" and "technical documentation"?
- Capacitive sensor measurement system module circuit design precision amplifier circuit
- TBS 1102 Oscilloscope Use