Categories
TUTORIALS

Monitoring Air Quality data with ThingSpeak using an ESP8266 module

Overview

In this tutorial, we will show you how to connect an Arduino UNO R3 with an ESP8266 WiFi module mounted on an ESP-01 adapter. We will also explain the steps for setting up a new channel on ThingSpeak and how to write data on the channel. This tutorial is suitable for beginners who want to learn how to use an Arduino UNO R3 and ESP8266 WiFi module to send data to ThingSpeak and can potentially work as a base to connect any air quality sensor and share data online.

Materials Required:

  1. Arduino UNO R3
  2. ESP8266 WiFi module mounted on an ESP8266 ESP-01 adapter
  3. USB cable
  4. Breadboard or Prototype Expansion Module (Optional)
  5. Female to male Dupont wires

The ESP-01 Adapter is used for easier interfacing with the ESP8266 WiFi module, it includes an 3.3V voltage regulator and 5V to 3.3V logic level shifting.

ESP-01 can be wired directly to UNO but in case that you are also considering to connect a sensor, using a breadboard or the prototype expansion module (which can be mounted on top as a shield) allows you to have more space and connections for more sensors.

Wiring Diagram

Wiring Steps

ESP8266 WiFi module (Black) and ESP-01 adapter (Blue)
Mount the ESP8266 module on the adapter first before wiring, it should look like this.

Connect the ESP-01 with ESP8266 WiFi module to the Arduino UNO R3 board. To do this, connect the following pins:

  • ESP-01 GND pin to Arduino GND pin
  • ESP-01 VCC pin to Arduino 5V pin
  • ESP-01 RX Receive Data pin to Arduino pin 11
  • ESP-01 TX Transmit Data pin to Arduino pin 10
ESP-01 with ESP8266 mounted over a Prototype Expansion Module.

Setting up ThingSpeak Channel

  1. Create an account on ThingSpeak
  2. Create a new channel, on Channel Settings tab you can configure the name, description and fields used on your channel. Each channel can have up to 8 fields
  3. On Sharing tab, under Channel Sharing Settings select the option “Share channel view with everyone” this will make it public and anyone will be able to see your shared data.
  4. On API Keys tab you can get the keys to write or send data to the channel.
For this tutorial we only checked Field 1 and named it as Random Number

Writing the code

  1. Open Arduino IDE on your computer and start a new sketch.
  2. In this tutorial we’ll only need SoftwareSerial library, if we try to connect ESP-01 RX/TX pins to Uno’s Serial TX/RX it will block the connection between Uno and IDE as the USB serial works on the same pins to communicate to our computer, Software serial allows us to connect ESP-01 through pins 10 and 11.
  3. Write the following code into your sketch:

Now we can upload our code into Uno and test how it generates a random number and writes it into our channel, ThingSpeak allows us to share and visualize publicly our data, for our PhillyAir Mist Alert project we will replace this number with air quality sensor data.

Screenshot of how our channel looks like and the graph from the random number

One reply on “Monitoring Air Quality data with ThingSpeak using an ESP8266 module”

Leave a Reply

Your email address will not be published. Required fields are marked *