Arduino Uno 实验15 您所在的位置:网站首页 arduino实验案例加代码 Arduino Uno 实验15

Arduino Uno 实验15

2023-08-11 02:07| 来源: 网络整理| 查看: 265

MQ-135 气体传感器模块简介(空气质量检测 有害气体检测)

  MQ135气体传感器所使用的气敏材料是在清洁空气中电导率较低的二氧化锡(SnO2)。当传感器所处环境中存在污染气体时,传感器的电导率随空气中污染气体浓度的增加而增大。MQ135气体传感器对氨气、硫化物、苯系蒸汽的灵敏度高,对烟雾和其它有害气体的监测也很理想。这种传感器可检测多种有害气体,是一款适合多种应用的低成本传感器。   主要用途:家庭和环境的有害气体检测装置   主要芯片:LM393、MQ-135气体传感器

在这里插入图片描述

不同气体的型号选择

在这里插入图片描述

使用步骤:

  ①将配套程序下载到相应的开发板中。   ②将串口线和模块接入开发板,给开发板上电。     若选择DOUT,TTL高低电平端,输出信号可以直接接单片机IO口或者接一个NPN型三极管去驱动继电器,电位器RP在这里用于调节输出电平跳变的阀值,当传感器检测到被测气体时,比较器LM393管脚2点的电压值,跟传感器检测到气体的浓度成正比,当浓度值超过电位器RP设定的阀值时,比较器2脚的点位高于3脚的点位,这个时候,比较器1脚输出低电平,LED灯亮,R3为LED灯限流电阻,C1为滤波电容。传感器输出低电平,反之,当没有信号的时候,传感器输出高电平,等于电源电压。     若选择AOUT,模拟量输出,那样就不用管电位器了,直接将AOUT脚接AD转换的输入端或者,带有AD功能的单片机,就可以了。根据我们的经验:在正常环境中,即:没有被测气体的环境,设定传感器输出电压值为参考电压,这时,AOUT端的电压在1V左右,当传感器检测到被测气体时,电压每升高0.1V,实际被测气体的浓度增加20ppm(简单的说:1ppm=1mg/kg=1mg/L=1×10-6 常用来表示气体浓度,或者溶液浓度。),根据这个参数就可以在单片机里面将测得的模拟量电压值转换为浓度值。注意:如果您是用来做精密仪器,请购买市场上标准的校准仪器,不然存在误差,因为,输出浓度和电压关系的比值并非线性,而是趋于线性。   ③让传感器先预热一分钟。   ④把传感器放入含有敏感气体的装置中,模块上的信号指示灯点亮。 把传感器从敏感气体装置中取出,模块上的信号指示灯熄灭。

MQ-135 气体传感器模块的使用 实验一:模拟值和数字值读取 项目要求:

  直接读取数字信号和模拟信号的数值。

电路搭建

在这里插入图片描述

参考程序 int mqPinDO = 2; int mqPinAO = A0; void setup(){ pinMode(mqPinDO,INPUT); pinMode(mqPinAO,INPUT); Serial.begin(9600); } void loop() { int mqDValue =digitalRead(mqPinDO); Serial.print("mqDValue ="); Serial.println(mqDValue); int mqAValue =analogRead(mqPinAO); Serial.print("mqAValue ="); Serial.println(mqAValue); delay(200); } 实验结果

在这里插入图片描述

实验二:未完成

在这里插入图片描述 在这里插入图片描述

说明: 根据上面手册说明,还与环境的温度和湿度有关,

/**************************************************************************/ /*! @file MQ135.cpp @author G.Krocker (Mad Frog Labs) @license GNU GPLv3 First version of an Arduino Library for the MQ135 gas sensor TODO: Review the correction factor calculation. This currently relies on the datasheet but the information there seems to be wrong. @section HISTORY v1.0 - First release */ /**************************************************************************/ #include "MQ135.h" /**************************************************************************/ /*! @brief Default constructor @param[in] pin The analog input pin for the readout of the sensor */ /**************************************************************************/ MQ135::MQ135(uint8_t pin) { _pin = pin; } /**************************************************************************/ /*! @brief Get the correction factor to correct for temperature and humidity @param[in] t The ambient air temperature @param[in] h The relative humidity @return The calculated correction factor */ /**************************************************************************/ float MQ135::getCorrectionFactor(float t, float h) { return CORA * t * t - CORB * t + CORC - (h-33.)*CORD; } /**************************************************************************/ /*! @brief Get the resistance of the sensor, ie. the measurement value @return The sensor resistance in kOhm */ /**************************************************************************/ float MQ135::getResistance() { int val = analogRead(_pin); return ((1023./(float)val) * 5. - 1.)*RLOAD; } /**************************************************************************/ /*! @brief Get the resistance of the sensor, ie. the measurement value corrected for temp/hum @param[in] t The ambient air temperature @param[in] h The relative humidity @return The corrected sensor resistance kOhm */ /**************************************************************************/ float MQ135::getCorrectedResistance(float t, float h) { return getResistance()/getCorrectionFactor(t, h); } /**************************************************************************/ /*! @brief Get the ppm of CO2 sensed (assuming only CO2 in the air) @return The ppm of CO2 in the air */ /**************************************************************************/ float MQ135::getPPM() { return PARA * pow((getResistance()/RZERO), -PARB); } /**************************************************************************/ /*! @brief Get the ppm of CO2 sensed (assuming only CO2 in the air), corrected for temp/hum @param[in] t The ambient air temperature @param[in] h The relative humidity @return The ppm of CO2 in the air */ /**************************************************************************/ float MQ135::getCorrectedPPM(float t, float h) { return PARA * pow((getCorrectedResistance(t, h)/RZERO), -PARB); } /**************************************************************************/ /*! @brief Get the resistance RZero of the sensor for calibration purposes @return The sensor resistance RZero in kOhm */ /**************************************************************************/ float MQ135::getRZero() { return getResistance() * pow((ATMOCO2/PARA), (1./PARB)); } /**************************************************************************/ /*! @brief Get the corrected resistance RZero of the sensor for calibration purposes @param[in] t The ambient air temperature @param[in] h The relative humidity @return The corrected sensor resistance RZero in kOhm */ /**************************************************************************/ float MQ135::getCorrectedRZero(float t, float h) { return getCorrectedResistance(t, h) * pow((ATMOCO2/PARA), (1./PARB)); } @file MQ135.h @author G.Krocker (Mad Frog Labs) @license GNU GPLv3 First version of an Arduino Library for the MQ135 gas sensor TODO: Review the correction factor calculation. This currently relies on the datasheet but the information there seems to be wrong. @section HISTORY v1.0 - First release */ /**************************************************************************/ #ifndef MQ135_H #define MQ135_H #if ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif /// The load resistance on the board #define RLOAD 10.0 /// Calibration resistance at atmospheric CO2 level #define RZERO 76.63 /// Parameters for calculating ppm of CO2 from sensor resistance #define PARA 116.6020682 #define PARB 2.769034857 /// Parameters to model temperature and humidity dependence #define CORA 0.00035 #define CORB 0.02718 #define CORC 1.39538 #define CORD 0.0018 /// Atmospheric CO2 level for calibration purposes #define ATMOCO2 397.13 class MQ135 { private: uint8_t _pin; public: MQ135(uint8_t pin); float getCorrectionFactor(float t, float h); float getResistance(); float getCorrectedResistance(float t, float h); float getPPM(); float getCorrectedPPM(float t, float h); float getRZero(); float getCorrectedRZero(float t, float h); }; #endif 原理图

在这里插入图片描述



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有