Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Kuncono Liem
Published © GPL3+

Easy Air Quality Report With NodeMCU+MQ135

This simple project is to monitoring the air quality with NodeMCU and MQ135 sensor. The ppm value will display to Cayenne.

BeginnerShowcase (no instructions)1 hour18,821
Easy Air Quality Report With NodeMCU+MQ135

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
MQ135
×1

Software apps and online services

Arduino IDE
Arduino IDE
Cayenne
myDevices Cayenne

Story

Read more

Schematics

Connection beetwen NodeMCU to MQ135

Connect NodeMCU A0 to MQ135 AO
Connect NodeMCU GND to MQ135 GND
Connect NodeMCU VIN (5V) to MQ135 VCC

Code

Sketch

C/C++
#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
}

Credits

Kuncono Liem
7 projects • 10 followers

Comments