Arduino MQ135 Gas Sensor

Source: Internet
Author: User

Arduino MQ135 Gas Sensor

first, the wiring

The MQ135 has 4 pins, VCC, GND, A0, D0, respectively, where VCC, GND, and A0 are required. The following diagram is a esp8266 wiring diagram. Due to the measurement of the gas value of PPM, it is related to the air temperature and humidity. So we've added a DHT22 here. DHT22 Portal

vcc->3v

Gnd->g

A0->a0

Second, MQ135 library

Download Address: https://github.com/zhao007z4/MQ135

After the download is complete, copy to the Arduino Library directory under Three, code

#define Dht_type DHT11
#define Dht_pin 2//pin d4

#define Analogpin A0

DHT DHT (Dht_pin, Dht_type);

MQ135 gassensor = MQ135 (Analogpin);

void Setup () {
Serial.begin (9600);
Dht.begin ();

}void Loop () {
Float h = dht.readhumidity ();
Read Temperature as Celsius (the default)
float T = dht.readtemperature ();
Check if any reads failed and exit early (to try again).
if (isNaN (h) | | | isNaN (t))
{
Serial.println ("Failed to read from DHT sensor!");
Delay (1000);
Return
}
Serial.print ("hum=");
Serial.print (h); This to display the Rzero value continuously, uncomment this to get PPM value
Serial.println ("%");
Serial.print ("temp=");
Serial.print (t); This to display the Rzero value continuously, uncomment this to get PPM value
Serial.println ("C");

Rzero = Gassensor.getrzero (); The Rzero value, uncomment this to get PPM value
Serial.print ("rzero=");
Serial.println (Rzero); This to display the Rzero value continuously, uncomment this to get PPM value

ppm = gassensor.getppm (); This to get the PPM value, uncomment this to get Rzero value
Serial.print ("ppm=");
SERIAL.PRINTLN (ppm); This to display the PPM value continuously, uncomment this to get Rzero value

ppmbalanced = gassensor.getcorrectedppm (t, h); This to get the PPM value, uncomment this to get Rzero value
Serial.print ("PPM corrected=");
Serial.println (ppmbalanced); This to display the PPM value continuously, uncomment this to get Rzero value

} Iv. Summary

From the MQ135 documentation, we learned that MQ135 need to warm up not less than 48 hours to work properly. Chinese Document Portal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.