[Arduino basics tutorials] use MQ135 air quality detecting module

in #utopian-io8 years ago (edited)

Before reading:

I write it on my PC typora ,but the passage may go wrong when I copythe passage to Utopian post editor.So I upload to the Github. If thearticle layout make you dazzled please read on the below url.Thanks.

The more readable version


What Will I Learn?

Two ways to use MQ135 air quality detecting module

MQ135 is mainly used to detect the concentration of carbon dioxide, alcohol, benzene, NOx, ammonia and other gases in the air.

  • Do not use library files
  • Using a library document

Requirements

  • Arduino Uno *1

  • MQ135 air quality detecting module *1

    图片.png

  • wire *3

  • Bakery board *1


Difficulty

  • Basic

Tutorial Contents

1.Do not use library files

  • Connection

    图片.png

    MQ135Arduino
    VCC->5V
    AOUT->A0
    GND->GND
  • Sample program

const int gasSensor =0;
void setup(){
  Serial.begin(9600);      // sets the serial port to 9600
}
void loop(){
  float voltage;
  voltage = getVoltage(gasSensor);
  
  Serial.println(voltage);
  delay(1000);
}
 
float getVoltage(int pin){
  return (analogRead(pin) * 0.004882814);
  // This equation converts the 0 to 1023 value that analogRead()
  // returns, into a 0.0 to 5.0 value that is the true voltage
  // being read at that pin.
}

2. use the <MQ135.h> Library

The required materials and wiring are the same as the way which does not use of the library files. The only difference is that you need to download the MQ135 library.

  • Load library files

    Download the MQ135 file .

    Open the Arduino IDE, click the project - > Load Library - > add a.Zip library, then select the MQ135 file .

  • Initialization settings

    Before you start using it, you need to energized it and preheat it for 12-24 hours. After that, perform the following procedures in the environment of 20 degree C/35% air temperature, and read the value of RZERO.

    #include "MQ135.h"
    const int ANALOGPIN=0;
    MQ135 gasSensor = MQ135(ANALOGPIN);
    void setup(){
      Serial.begin(9600);      // sets the serial port to 9600
    }
    void loop(){
      float rzero = gasSensor.getRZero();
      Serial.println(rzero);
      delay(1000);
    }
    

    Write the read value in the MQ135.h file in the library file.

    Where to find the MQ135.h file

    You can select the file > preferences in Arduino IDE, in the pop-up window, you can see the project folder location

    eg: d:\Users\weiwe\Documents\Arduino, and then you find the folder inside the libraries->MQ135-master->MQ135.h file can be opened, the value of RZERO is to be filled in.

    #define RZERO 76.63
    

  • Start detecting air quality

#include "MQ135.h"
const int ANALOGPIN=0;
MQ135 gasSensor = MQ135(ANALOGPIN);
void setup(){
  Serial.begin(9600);      // sets the serial port to 9600
}
void loop(){
  float ppm = gasSensor.getPPM();
  Serial.println(ppm);
  delay(1000);
}

Tips

  • Experiments show that MQ-135 can detect the above mentioned gases, but it does not distinguish them. If you want to test the content of a specific gas in the air, you may need to find other better sensors.

  • MQ-135 uses a heating module to preheat the sensor, so it is suggested that a power supply with a larger capacity will not run out of electricity quickly.

  • Indoor air quality control table

    图片.png


Curriculum


Thanks for reading patiently!



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

哈喽!请接受cn区点赞机器人 @cnbuddy 对你作为cn区一员的感谢。 @cnbuddy 的梦想是能够对cn区快速发展作出自己的贡献。我的主页会定期总结cn区活动动态,欢迎围观。如果不想再收到我的留言,请回复“取消”。

Out of curiosity did you write this in another language and use google translate? (rhetorical)

An instance that makes this apparent is "bakery board" instead of bread board.

yeah!That is the project I wrote in Chinese before.I arrange the project files which i wrote in chinese while the project was going on.But i don`t know how to translate some technical terms so i use the Google to help me .

forgiving my poor english
Thank you for instructing me the bread board

No worries, I do forgive and completely understand. Tomorrow when my VP regenerates I will give you an upvote at 100%

I always enjoyed playing with this module when I first got it!

you are quite nice.I am also interested in the Arduino which can make my idea come true .I have made many ideas realized including the Arduino bluetooth&wifi car ,UAV and something more about the IOT .I am glad you like it ,too ,and i can communicate with you as well as learning from you .

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • A tutorial must be informative and explanatory, this tutorial lacks both and no more than simply "copy-paste this code" tutorial.

You can contact us on Discord.
[utopian-moderator]

Hey .I do not think so .this is not the simple copy .that is what i translate from Chinese.

As we talked in Discord, I wanted to state we ended in a conclusion which both of us agrees. Thanks for contacting.

but i still think it should not be disapproved at least

Coin Marketplace

STEEM 0.13
TRX 0.34
JST 0.036
BTC 108739.50
ETH 4358.49
USDT 1.00
SBD 0.83