Easy Air Quality Report With NodeMCU+MQ135+Cayenne




Introduction: Easy Air Quality Report With NodeMCU+MQ135+Cayenne

This simple project is to monitoring the air quality with NodeMCU and MQ135 sensor.

The ppm value displayed to Cayenne.

With Cayenne we can add some trigger without code.

This simple project is very easy to beginner (even I'm beginner too) and have real time air quality monitor over internet.

Step 1: Bill of Materials

This is the hardware required for this project :

- NodeMCU 1.0 ESP8266

- MQ135 Sensor

Software :

- Arduino IDE with NodeMCU board compatible. You can follow this link to add NodeMCU board on Arduino IDE (Thanks to Magesh Jayakumar for the tutorial)

- MQ135 Arduino Library

- Cayenne for iOS/Android/Web browser (if you didn't have account, create first and make new project and new device to get token)

Step 2: Setting Up Cayenne

After adding device in Cayenne, add analog sensor and setting the sensor like the picture.

And now you can monitor air Air Quality from your device.

Step 3: Connection Beetwen NodeMCU & MQ135

This is the connection beetwen NodeMCU and MQ135 :

NodeMCU MQ135




I recommend MQ135 have the separate power supply because it's a heater that need big current (800mA aprox)

Step 4: Define RZero for Your MQ135 and Upload Code to NodeMCU

As we know that MQ gas sensor is need to burn in to get more accurately.

And for the MQ135 in this case we need define RZero to calculate ppm.

Upload the sketch to NodeMCU with this line uncomment :

float rzero = gasSensor.getRZero();


Burn your MQ135 for 24 hours in fresh air, aprox. 20-25 Celcius. After that check RZero value from serial monitor. If the value become stable. Write the value to MQ135.h in libraries/MQ135.h file.

Change this line to your value :

#define RZERO 76.63

After getting RZero value, back to MQ135 sketch on Arduino IDE, comment/delete the previous line which get RZero, and then you can uncomment this line to get ppm value :

float ppm = gasSensor.getPPM();



Be the First to Share


    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    4 Discussions


    2 years ago

    This is missing the part to add and include Cayenne libraries to arduino and that part seems to be the problematic part for me whatever libraries I try to include I always get errors compiling. The code also has spelling mistakes, I presume this was just copy/pasted here without anyone verifying it works

    #define CAYANNE_DEBUG

    #define CAYANNE_PRINT Serial


    3 years ago

    Hey where shall i connect MQ135's analog output and digital output when i have to use raspberry pi ?


    4 years ago

    Highly functional in Ahvaz.
    thank you.