Air Quality Monitoring with MQ135 and Cayenne

About This Project

This project is to monitor the Air Quality especially CO2 with NodeMCU as microctroller and wifi.
By create this project now I can monitor if the air quality is good or not and it will trigger automatically if the air quality is poor.
This is very simple project created with Cayenne, no more code.
Only need MQ135 library and little modification to connect internet

What’s Connected

  • NodeMCU ESP-12E
  • MQ135 Gas Sensor

Triggers & Alerts

Triggers will send email when the Air Quality is poor

Scheduling

No scheduling used

Dashboard Screenshots

Photos of the Project

1 Like

I like easy. Very cool and useful!

Thank you for your support to my project. :wink:

Cool, I didn’t know about this sensor, I just ordered one!

Really super project :slight_smile: - thanks for telling me about this, I have to build a weather station so this will help loads :slight_smile:

Kewl!:sunglasses:

You’re welcome sir

Thank you brother

Must try this kind of sensor

Just got it in the mail today, hopefully I’ll get to give it a try this week.

Hello , thanks for sharing this good project, i just wanted to know how can i edit this below code to be able to add my Nodemcu ESP-12E module with MQTT authentication(username, password, client_id, ssid, passwd), because we can’t add Nodemcu with token, we should use MQTT authentication instead to add nodemcu module to cayenne. can you help me? :pray:

#include “MQ135.h”
#include “CayenneDefines.h”
#include “CayenneWiFi.h”
#include “CayenneWiFiClient.h”
#define CAYANNE_DEBUG
#define CAYANNE_PRINT Serial
#define VIRTUAL_PIN 5
#define ANALOGPIN A0

char token = “”; // Insert your token here
char ssid = “”; // Insert your SSID here
char pwd = “”; // Insert your SSID password here
MQ135 gasSensor = MQ135(ANALOGPIN);

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Cayenne.begin(token, ssid, pwd);
}

void loop() {
// put your main code here, to run repeatedly:
Cayenne.run();
// float rzero = gasSensor.getRZero(); //this to get the rzero value, uncomment this to get ppm value
// float ppm = gasSensor.getPPM(); // this to get ppm value, uncomment this to get rzero value
// Serial.println(rzero); // this to display the rzero value continuously, uncomment this to get ppm value
// Serial.println(ppm); // this to display the ppm value continuously, uncomment this to get rzero value
// Cayenne.virtualWrite(VIRTUAL_PIN,ppm); // uncomment after rzero define and get your ppm calculation
}

1 Like

You can actually use a NodeMCU board with the standard Arduino library too, it’s just not officially supported. On the dashboard select Arduino Uno as the device and then upload the code above like normal. I should still have my sensor somewhere, I’ll see if I can get it working with the MQTT library.

Cool project :slight_smile: Think you could post your code for others to follow along?

can any one help me how to write programs in python for cayenne platform??

What do you need help with? If you don’t know anything about python you can start here https://www.learnpython.org/

1 Like

Hi thanks for sharing the project.
Where can I have access to the code of the project please? I would like to see how you could use Cayenne with the sensor.

Thanks

Hello, did you manage to make this sensor work with Nodemcu?

@sara.loukili.lasri first try to get sensor data without adding cayenne code. once you get data it is very easy to connect to cayenne.

1 Like

Okay, thank you. And what about if I use MG811 instead of MQ135, can this work with Cayenne?

yes you can use MG811 instead of MQ135. the first thing is always to get the data from the sensor. then we can add any sensor to cayenne.

1 Like