8.6 Temperature and Humidity Monitoring with Adafruit IO

In this project, we will guide you on how to use a popular IoT platform. There are many free (or low-cost) platforms available online for programming enthusiasts. Some examples are Adafruit IO, Blynk, Arduino Cloud, ThingSpeak, and so on. The usage of these platforms is quite similar. Here, we will be focusing on Adafruit IO.

We will write an Arduino program that uses the DHT11 sensor to send temperature and humidity readings to Adafruit IO’s dashboard. You can also control an LED on the circuit through a switch on the dashboard.

Required Components

In this project, we need the following components.

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

ESP32 Starter Kit

320+

ESP32 Starter Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

ESP32 WROOM 32E

BUY

ESP32 Camera Extension

-

Breadboard

BUY

Jumper Wires

BUY

Resistor

BUY

LED

BUY

DHT11 Humiture Sensor

BUY

Setting up the Dashboard

  1. Visit Adafruit IO, then click on Start for free to create a free account.

    ../../_images/sp230516_102503.png
  2. Fill out the form to create an account.

    ../../_images/sp230516_102629.png
  3. After creating an Adafruit account, you’ll need to reopen Adafruit io. Click on the Dashboards, then click on New Dashboard.

    ../../_images/sp230516_103347.png
  4. Create a New Dashboard.

    ../../_images/sp230516_103744.png
  5. Enter the newly created Dashboard and create a new block.

    ../../_images/sp230516_104234.png
  6. Create 1 Toggle block.

    ../../_images/sp230516_105727.png
  7. Next, you’ll need to create a new feed here. This toggle will be used to control the LED, and we’ll name this feed “LED”.

    ../../_images/sp230516_105641.png
  8. Check the LED feed, then move to the next step.

    ../../_images/sp230516_105925.png
  9. Complete the block settings (mainly Block Title, On Text, and Off Text), then click on the Create block button at the bottom right to finish.

    ../../_images/sp230516_110124.png
  10. We also need to create two Text Blocks next. They will be used to display temperature and humidity. So, create two feeds named temperature and humidity.

    ../../_images/sp230516_110657.png
  11. After creation, your Dashboard should look something like this:

    ../../_images/sp230516_111134.png
  12. You can adjust the layout by using the Edit Layout option on the Dashboard.

    ../../_images/sp230516_111240.png
  13. Click on API KEY, and you will see your username and API KEY displayed. Note these down as you’ll need them for your code.

    ../../_images/sp230516_111641.png

Running the Code

  1. Build the circuit.

    ../../_images/iot_6_adafruit_io_bb.png
  2. Then, connect ESP32-WROOM-32E to the computer using the USB cable.

    ../../_images/plugin_esp32.png
  3. Open the code.

    • Open the iot_6_adafruit_io.ino file located in the esp32-starter-kit-main\c\codes\iot_6_adafruit_io directory, or copy the code into the Arduino IDE.

    • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.

    • Always displaying “Unknown COMxx”?

    • The Adafruit_MQTT Library and DHT sensor library are used here, you can install them from the Library Manager.

  4. Find the following lines and replace <SSID> and <PASSWORD> with the specific details of your WiFi network.

    /************************* WiFi Access Point *********************************/
    
    #define WLAN_SSID "<SSID>"
    #define WLAN_PASS "<PASSWORD>"
    
  5. Then replace <YOUR_ADAFRUIT_IO_USERNAME> with your Adafruit IO username and <YOUR_ADAFRUIT_IO_KEY> with the API KEY you just copied.

    // Adafruit IO Account Configuration
    // (to obtain these values, visit https://io.adafruit.com and click on Active Key)
    #define AIO_USERNAME "<YOUR_ADAFRUIT_IO_USERNAME>"
    #define AIO_KEY      "<YOUR_ADAFRUIT_IO_KEY>"
    
  6. After selecting the correct board (ESP32 Dev Module) and port, click the Upload button.

  7. Once the code is successfully uploaded, you will observe the following message in the serial monitor, indicating successful communication with Adafruit IO.

    Adafruit IO MQTTS (SSL/TLS) Example
    
    
    Connecting to xxxxx
    WiFi connected
    IP address:
    192.168.18.76
    Connecting to MQTT... MQTT Connected!
    Temperature: 27.10
    Humidity: 61.00
    
  8. Navigate back to Adafruit IO. Now you can observe the temperature and humidity readings on the dashboard, or utilize the LED toggle switch to control the on/off state of the external LED connected to the circuit.

    ../../_images/sp230516_143220.png