Overview

Skill Level: Any Skill Level

This recipe series shows how to use an ESP32 to send and receive data to/from Watson IoT Platform, store it in CloudantDB and display it using a Node-Red dashboard.

In "Part 1", you will learn how to configure Arduino IDE to work with ESP32.

Ingredients

Hardware required:

  • 1 ESP32 board
  • 1 USB cable (A to micro-B)

 

Software required:

  • Arduino IDE

 

 

Step-by-step

  1. Download and Install Arduino IDE

    Download and install the Arduino IDE from the official Arduino website:
    https://www.arduino.cc/en/main/software

     

    During installation, select all checkboxes:

    01

     

     

    If asked to install LLC Ports, select ‘Install’:

    02

     

    If asked to install Arduino USB Driver, by Arduino slr, select ‘Install’:

    03

     

    If asked to install “Arduino USB Driver” by “Arduino LLC”, select “Install”:

    04

     

    After the installation, click on “Close”:

    05

     

    Start Arduino IDE and allow access if prompted by Windows Firewall
    06

     

    Arduino IDE looks like this:

    07

  2. Adding ESP32 libraries to the Arduino IDE

    In this step, we’re going to configure Arduino IDE to work with ESP32 libraries.

     

    Go to File > Preferences:

    b01

     

    Add the URL below to the “Additional Boards Manager URLs” and click OK:

    https://dl.espressif.com/dl/package_esp32_index.json

    b02

     

    Go to Tools > Board > Boards Manager:

    b03

     

    Search for ESP32, wait for it to appear and click on “Install”:

    b04

     

    Download in progress:

    b05

     

    After the installation, click on “Close”:

    b06

  3. Selecting your board

    In this step, we’re going to select the ESP32 board model.

    Note that the board model may vary. The board model can usually be found written under the board itself.

     

    Go to “Tools” menu, “Board: *****” and then select your board on the list.
    In this case, it’s DOIT ESP32 DEVKIT V1.

    c01

     

     

    Select the COM port:
    Go to “Tools” menu, “Port” and select an available port (usually COM1 or COM3 but it may vary).

    c02

     

     

  4. Adding the project specific libraries

    In this step, we’re going to add the required libraries for the project.

    There are 4 libraries:

    • DHT Sensor library: to work with DHT sensors;
    • Adafruit Unified Sensor: aditional library to work with sensors;
    • NTPClient: connects to the Internet to retrieve date/time information;
    • PubSubClient: to connect to MQTT.

     

    Go to “Tools” menu, “Manage libraries…“:

    c03

     

    In the “Library manager” screen, search for the library name you want to install.

    Search for “dht“, wait for the result list to load and click on “Install“:

    c04

    Wait untill the install process completes.

     

    Search for “Adafruit Unified Sensor“, wait for the result list to load and click on “Install“:

    c06

    Wait untill the install process completes.

     

    NTPClient and PubSubClient needs to be downloaded and added manually.

    First, download both libraries and then add to the “Arduino/libraries” folder (detailed steps below).

     

    PubSubClient

    Download: https://github.com/knolleary/pubsubclient/archive/master.zip

    NTPClient:

    Download: https://github.com/taranais/NTPClient/archive/master.zip 

     

    Unzip both files to your “Arduino/libraries” folder and rename them as follows:

    • pubsubclient-master” to “pubsubclient
    • NTPClient-master” to “NTPClient

     

     c05

    Note: renaming is not necessary but facilitates the library use later on in the code. 

  5. Ready to code!

    With the ESP32 set up with all the needed libraries, you’re ready to start writing the code! 

    Please go to “Temperature monitor using ESP32 and Watson IoT Platform (Part 2)” to continue (coming soon!).

Join The Discussion