Skip to content

IoT Workshop Labs using the NodeMCU (ESP8266) board.

Notifications You must be signed in to change notification settings

jamesguitar3/AzureNodeLab

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Azure IoT Workshop: NodeMCU Lab

IoT Workshop Lab using the NodeMCU (ESP8266) board.

This serves as a working document for the Azure Internet of Things Workshop in which the NodeMCU (ESP8266) Arduino compatible prototyping board is used to connect to Azure IoT.

Table of Contents

Activity Summary

In this lab, we'll walk through the basics of:

  • Creating and configuring an Azure IoT Hub
  • Configuring a sample Arduino sketch to communicate with Azure IoT Hub
  • Deploying the sketch to the NodeMCU device
  • Monitoring the data received from the NodeMCU
  • Visualizing and analyzing the IoT data in PowerBI

Requirements

The following components are required to follow this lab in its entirety.

Hardware

Note: If you have some experience with prototyping boards and developing Arduino sketches, you can substitute many of the sensors and components in this guide and achieve the same general output. This is the power of Azure IoT Hub - device agnostic support through standards based protocols like AMQP, MQTT, and HTTPS. That being said, the lab is written for use with the following hardware:

Software

Similar to the hardware, if you have a preferred Arduino / ESP8266 IDE, you may be able to use an alternative development environment to achieve the goals of this lab, but the instructions are designed with the following in mind:

  • Arduino IDE
  • ESP8266 Board Package (for Arduino IDE)
  • CP210x Driver (if it's not already installed on your system)
  • Azure Subscription
    • If you already have an Azure Organizational Account, you may use that for this lab.
    • If you don't already have an Azure Subscription, you can create a free trial
  • Azure Device Explorer

Create Azure IoT Hub

//TODO: Instructions on creating and configuring IoT Hub

Software Installation

Install the Arduino IDE

  1. Download the Windows Installer
  2. Run the arduino-1.8.2-windows.exe
  3. Leave the default options selected to install the IDE and supporting drivers Installation Options
  4. Leave the default installation Destination Folder unchanged and select Install
    Installation Folder
  5. Wait for the installation to complete. Toward the end of the installation, you may be prompted to install several drivers. Select Install for each prompt.
    • Adafruit Ports
    • Arduino USB Driver (from Arduino srl)
    • Arduino USB Driver (from Arduino LLC)
      Arduino USB Driver LLC
  6. Click Close to complete the Arduino IDE installation
    First Driver

Configure Arduino IDE for ESP8266

  1. Open the Arduino IDE and click on FilePreferences
    Arduino Desktop Icon
    Arduino File Preferences
  2. Find the Aditional Boards Manager URLs and enter the following: http://arduino.esp8266.com/stable/package_esp8266com_index.json
    Note: If you already use the Arduino IDE and already have a URL in this field, you can also click the small box to the right of the field to open a larger window to enter the ESP8266 package on a new line. Boards Manager URLs
  3. Click OK to close the Preference Screen
  4. Open the menu: ToolsBoardBoards Manager
    Arduino File Preferences
    Note: If this is your first time running the Boards Manager, you may have to wait a moment while it downloads the packages.
  5. Type ESP8266 in the search box at the top of the Boards Manager screen
  6. Click the esp8266 record to select the row then select Install to install the package. ESP8266 Package Installation
    Note: The installation may take several minutes as the file is a large download. The version of the esp8266 package used in this lab is 2.3.0
  7. Open the menu: ToolsBoard and select NodeMCU 1.0
    Select Board 1
    Select Board 2

Note: If any of the board configuration settings have been changed, be sure to change them back to the defaults documented below:

  • Board: "NodeMCU 1.0 (ESP-12E Module)"

  • CPU Frequency: "80 MHz"

  • Flash Size: "4M (3M SPIFFS)"

  • Upload Speed: "115200"

  • Port: {see Device Manager}

    Board Configuration

Configure Libraries

  1. Sketch → Include Library → Manage Libraries

  2. Type azure in the filter box

  3. Select each of the below libraries and choose install for each

    Library Author Version
    AzureIoTHub Arduino 1.0.30
    AzureIoTProtocol_HTTP Microsoft 1.0.30
    AzureIoTProtocol_MQTT Microsoft 1.0.30
    AzureIoTUtility Microsoft 1.0.30

FAQ

  • Q: The text in my Serial Port Monitor is all boxes/squares, what should I do?
    A: Make sure to select the correct baud rate in the bottom-right corner of the Serial Port Monitor. For this lab, we are using 115200.
  • Q: I'm getting a XYZ error in my Serial Port Monitor, what should I do?
    A: Try closing reopening the Serial Port by selecting Tools → Port and then reselecting your desired port.
  • Q: Are there other debugging steps I can take related to a failed WiFi connection?
    A: Set "Debug Port: Serial" and "Debug Level: Core" in the Arduino IDE Tools menu. Add Serial.setDebugOutput(true); after Serial.begin(9600);. This will print additional information from the WiFi stack which may provide hints as to what is going wrong.
  • Q: How can I check if the WiFi connection is established before connecting?
    A: Use the following snippet:
    if (WiFi.status() != WL_CONNECTED) {
      WiFi.begin(ssid, password);
    }
    
  • Q: I'm still having issues connecting to WiFi even after trying the above troubleshooting steps
    A: Try the following:
    WiFi.persistent(false);
    WiFi.mode(WIFI_OFF);   // this is a temporary line, to be removed after SDK update to 1.5.4
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    
  • Q: This isn't working for me on ESP-01, ESP-003, or other alternative board - what can I do?
    A: Try adding the following snippet immediately before the WiFi.begin(ssid, password); line:
    WiFi.setOutputPower(0);
    
  • Q: Can I set a fallback where the device will broadcast it's own Access Point?
    A: Check out the following snippet: AP Fallback GitHub comment

About

IoT Workshop Labs using the NodeMCU (ESP8266) board.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published