Air Quality Monitor With MQ135 and External Temperature and Humidity Sensor Over MQTT

Introduction: Air Quality Monitor With MQ135 and External Temperature and Humidity Sensor Over MQTT

This is for test purposes.

Step 1: Motivation

A few days ago a friend of mine comes across with an Air Purifier. Used for about few days but he could not come agree if the Air purifier really do something or not... so we decided to motorize somehow this. I've came across with the MQ135 air quality sensor.

Here is my setup of the system. MQTT broker (MqB), environmental client that sends Temperature/Humidity (TH) to the broker and finally we've added an Air Quality (AQ) client. MqB will send every 5 minutes the temperature/humidity from TH to AQ. Of course this depends of your setup, you can increase or decrease this timing, is up to you. This dates will be stored, processed and reported back by the AQ.

Step 2: Hardware Setup

Hardware:
1. NodeMCU V3

2. MQ135

3. Cables

4. Connect the MQ135 sensor to NodeMCU as follows:

MQ135 -> NodeMCU

VCC -> VU

AOUT -> AO

GND -> GND

DOUT will not be connected!

Step 3: Software

First of all you'll need Arduino IDE installed on your machine.
Than you have to add your board, check this article.

Start your Arduino IDE and go to: Tools/Manage Libraryes or press CTRL+Shift+I. In filter search type: esp8266wifi - install IoTtweet and MFUthings, than type:PubSubClient - install PubSubClient by Nick O'Leary and PubSubClientTools by Simon Christmann.

Download the MQ135 Library from: this GitHub_Link. In Arduino IDE navigate to Sketch/Include Library/Add .ZIP Library, and load your zip file donloaded.

Download ArduinoThread. In Arduino IDE navigate to Sketch/Include Library/Add .ZIP Library, and load the

downloaded zip file .

The sketch is based on the example provided by Arduino IDE, witch can be found in: File/Examples/PubSubClientTools/mqtt_esp8266.


Load the sketch provided in this tutorial. Of course you will have to modify some things like:

#define WIFI_SSID "xxxxxxxx" //add your SSID

#define WIFI_PASS "xxxxxxxx" //add your Password

#define MQTT_SERVER "192.168.1.xxx" //add the IP of your MQTT brocker
#define MQTT_PORT 1883 //add port of your MQTT brocker

#define mqtt_user "xyz" //add username of your MQTT Brocker

#define mqtt_password "xwz" //add password of your MQTT Brocker

For the rest should be ok. Upload the sketch to your NodeMCU and open the Serial Monitor (top right hand side)

Step 4: Conclusions

The system works as expected.

Picture from 13.Mar is without the Air Purifier working, but window opened.

Picture from 15.Mar is with the Air Purifier working between 13:00 - 21:00, and window closed.

Test it for yourself and let me know if it works for you.

Be the First to Share

    Recommendations

    • Robots Contest

      Robots Contest
    • Rocks, Gems, and Stones Speed Challenge

      Rocks, Gems, and Stones Speed Challenge
    • Retro Tech Challenge

      Retro Tech Challenge

    Comments