Easy Arduino Air Quality Monitor Tutorial WiFi Connected

In this article, I’m going to give you step-by-step instructions to make your own wifi connected air quality sensor. This means you’ll be able to monitor your home air quality from anywhere! Even if you have no experience, this tutorial is for you.

This Tutorial Will Cover:

  • Parts Used and Where To Purchase Them
  • Software Requirements
  • Building An Arduino Air Quality Monitor
  • Programing An Arduino Air Quality Monitor
  • Real Life Examples Using The Air Quality Monitor

Why Measure Indoor Air Quality?

Poor indoor air quality is one of the global leading causes of mortality.

Parts for Arduino WiFi Air Quality Monitor

For this build, you’ll need the Arduino Uno, Arduino Upload Cable, a breadboard, ESP8266 Wi-Fi chip, Wi-Fi Adaptor, MQ-135 gas sensor, and Male to Male cables, and a small prying tool, such as a Swiss army knife. You’ll also need a computer capable of running Arduino software. 

Arduino Uno

Arduino Uno
Arduino Uno

The Arduino Uno is the board we will be using for this project. Other Arduino boards may work for this project as well, but this board is all I needed. It’s a great price and you can purchase it on many different websites.

You can purchase the Arduino Uno here.

Arduino Uno Upload Cable

Arduino Upload Cable
Arduino Upload Cable

This cable is used to program the Arduino board and WFi chip. It can also be used as a power supply for the air quality monitor. It has a USB on one end, which plugs into a USB port on your laptop or desktop. The other end plugs into the Arduino Uno board. 

You can purchase the Arduino Upload Cable here.

Breadboard

Breadboard for electronic hobby projects
Breadboard

Breadboards are a really useful tool for building circuits without the need for soldering. You simply connect cables from one of the small holes you see in the image above to either another hole, a circuit component, or to your Arduino. 

All holes along a numbered row are connected along the bottom from column a-e. This means you can plug a cable into hole 1-a and another into hole 1-d and they will be in electrical contact, allowing you to create your circuit. 

Columns f-j are not in contact with a-e unless you “jump” across the center by plugging a cable into a row on one side and the same row on the other side.

Last, the red and brown (sometimes blue) lines, also known as rails, you see along the side of the board are where we typically connect our high and low end of our circuits. The positive and negative does not mean the board itself is high or low, it’s just a suggestion on how to wire your circuit.

One important difference with these holes is they are connected along the bottom of the columns rather than rows. 

In order to get the board to actually be powered and have electricity flowing through it, you’ll need to wire in a power source such a battery. You can also wire over from the arduino to one of the positive red rails to bring power onto the board.

Breadboards come in different sizes, so if you plan on creating other projects with a single breadboard, checkout a variety to see which is best for you.

You can purchase a breadboard here.

ESP8266 WiFi Chip

ESP8266 WiFi Chip
ESP8266 WiFi Chip

This is the chip that will allow your project to send data wirelessly. In order to program it, we must build a separate  circuit and use a separate code then we will use for the main air quality monitor build. 

There are no extra parts required for this extra build and I’ll walk you through those parts as well.

You can purchase the ESP8266 WiFi chip here.

ESP8266 WiFi Chip Adaptor

Esp8266 WiFi Chip Adaptor
ESP8266 WiFi Chip Adaptor​

The WiFi adaptor chip is important for two reasons.

First, the pins on the back of the ESP8266 WiFi chip are not configured in a way that is usable on our breadboard. If you try to put it on the breadboard, you’ll see the pins don’t fit properly into the holes. 

Second, the result of this is that you’ll be left trying to wire the ESP8266 chip directly to the board. None of the connections to the chip will feel secure and they will often fall out of contact with the chip. You could try wrapping the wires together with tape, but this does not always guarantee your connections will stay secure.

This adaptor fits nicely onto the board and will keep your connection from coming loose.

You can purchase the ESP8266 WiFi adaptor here.

MQ-135 Gas Sensor

mq-135-gas-sensor
MQ-135 Gas Sensor​

The MQ-135 gas sensor is capable of detecting a bunch of different gases. We could build an air quality sensor for individual gases, such as carbon monoxide, but that would only give us a small snapshot of the overall air quality. 

Since we want to know the overall air quality, we need a sensor that can detect multiple common home air pollutants.

You can purchase the MQ-135 gas sensor here

Male to Male Cables

Male to Male Jumper Cables
Male to Male Jumper Cables

Male to male jumper cables are a very important item when working with breadboards. Male to male cables are ones that have a pin at both ends. This allows both sides to be plugged into something.

It’s helpful to have a range of colors of wires so that you don’t get confused about which wires are which. 

For example, if you have two blue wires close together, it’s often not easy to tell which one you may need move.

For this reason it could also be helpful to have different lengths of wire. Overly long wires crowd the board and short wires either don’t reach their destination at all or make weak contact.

You can purchase male to male cables here.

Software Requirements

In order to be able to use the Arduino, you need a computer capable of downloading and running Arduino Software. You can find download options of the Arduino Development Software for Windows, MacOS, and Linux.

Find the one suitable for your needs and follow the download process.

Once complete, you’ll have access to the Arduino development area, where you will place your code.

Building An Air Quality Monitor with Arduino

There are two separate circuits we will need to build in order to have the air quality monitor up and running. One is to program the ESP8266 WiFi chip, and the other to program the Arduino. 

Building and Programming the ESP8266 Circuit

Removing the Arduino Microcontroller
Remove the Arduino Microcontroller

Step 1: Remove the microcontroller

First, you’ll have to remove the microcontroller on the Arduino board. This is because the ESP8266 chip has a microcontroller of its own that we are trying to program. In order to be able to program it, we need to avoid the Arduino microcontroller.

To do this, I used a Swiss Army knife to slowly pry up the controller. Be careful here because you don’t want to damage any of the pins.

Eventually, the microcontroller will be loose enough that you’ll be able to grab it and pull it out the rest of the way. Once you get it out, take a look at the bins and very carefully bend any pins back into place that may have bent when prying the microcontroller out.

Step 2: Build The ESP8266 Circuit

ESP8266 Microcontroller Adaptor

Next, place the ESP8266 chip adaptor on the board as seen in the picture above. As you can see, the pins on the adaptor “jump” across the gap that runs across the center of the board. 

This ensures all of the pins are each in their own column and are not in electrical contact with each other. 

Then, plug the ESP8266 WiFi chip into the the adaptor.

We can now start to wire up the circuit. The first wire is going to go from the 3.3v pin on the Arduino over to the positive rail on the breadboard.

We can now start to wire up the circuit. The first wire is going to go from the 3.3v pin on the Arduino over to the positive rail on the breadboard.

Then, take another wire and plug one end into the positive rail as well. The other end of the wire gets plugged into the breadboard in the same column as the Vcc labeled on the adaptor.

This will bring power to our ESP8266 when it’s time to use it.

We will also need another wire to go from the positive rail over to CHPD of the chip. This will enable the chip to work when the power is set to high, which in our case is 3.3v. 

Next, take a wire and connect the Rx pin on the chip to the Rx pin on the Arduino.

So far, your build should look something like the image above. I have also placed a rough sketch of the build in the image above as well.

Connect the Tx pin of the chip to the Tx pin of the Arduino.

We’re just about done  with the initial circuit. One of the last things to do is to add in the ground to our circuit. 

On the Arduino you have a bunch of different ground pins. There’s two on one side and one on the other.  

Plug a wire into one of these ground pins, it doesn’t matter which one, and go over to the blue rail. Remember, all of the holes along the blue rail are connected to each other. So, anything that you connect to this blue rail is going to be grounded.

With that said, take another wire and plug it into the blue rail at one end and GND of the chip at the other end

Last, plug a wire into the blue rail one more time and go over to GPO of the chip.

What that does is when GPO is connected to voltage, or not connected, it’s going to use the code that’s already on the chip. GPIO is a flash pin so if GPO is connected to the ground or the low voltage, it’ll take new code. 

So when we want to put our new code on the chip, we have to connect GPO to the ground

As you can see, we still have two pins left open: the reset pin and GP2. There are some circuits where you could connect the reset pin, but I prefer this one since it’s a little bit faster.

Summary of Build:

  • Rx to Rx
  • Tx to Tx 
  • 3.3v to the positive rail
  • Positive rail to Vcc
  • Positive rail to CHPD 
  • Ground pin to ground rail 
  • Ground rail chip ground
  • Ground rail to GPO

Step 3: ESP8266 Code

2 thoughts on “Easy Arduino Air Quality Monitor Tutorial WiFi Connected”

  1. Pingback: What Is E-Waste? E-Waste Explained By An Expert – Go Green Post

  2. Pingback: Testing If House Plants Clean Air – Here’s How Many You Need – Go Green Post

Leave a Reply

%d bloggers like this: