How to Connect the ESP8266 NodeMCU to the IoT Cloud

3,165

11

6

About: IoT Maker, co-founder of asksensors.com

This instructable shows you a simple Internet of Things demo using the ESP8266 NodeMCU and an online IoT service called AskSensors. We demonstrate you how to quickly get data from the ESP8266 HTTPS client and plot it in graph into the AskSensors IoT Platform.

Supplies:

Step 1: Materials You Need

To follow along with this tutorial you will simply need:

    1. Computer running arduino software
    2. ESP8266 Node MCU
    3. USB micro cable to connect the node MCU to the computer.

      Step 2: Sign Up for AskSensors

      First, Create a new account at AskSensors. You will receive an email containing all the instructions you need follow to login (It is super easy).

      Follow this getting started guide which explains you how to create and set up a new Sensor so we will be able to write data to this sensor. Here are the main steps:

      1. Click on 'New Sensor' to create a communication channel with unique ID and Api Keys. Give a name and description to your sensor.
      2. Add a module for the data you will be plotting.
      3. Copy down the Api Key In value. We will use in the ESP8266 code later.

      Step 3: Write the Code

      Example sketch and ESP8266 WIFI libraries are available in github.
      The provided code is ready to use as is. It connects the ESP8266 to wireless network as HTTPS client, and then push data to AskSensors every 25 seconds . You need to fill the following:

      • Your WIFI SSID and password.
      • The Api Key In generated before by AskSensors.
      • If needed, the time period between two successive data updates (set to 25 second in this example).
      // Wifi config
      
      const char* wifi_ssid = "..........";             // SSID
      
      const char* wifi_password = "..........";         // WIFI
      const char* apiKeyIn = "..........";      // API KEY IN, example: FALOAPPKH17ZR4Q23A8U9W0XPJL0F6OG
      delay(25000);     // delay 25sec

      Step 4: Run the Code

      1. Open Arduino IDE and upload the code into ESP8266 nodeMCU. Follow this tutorial if you still need to get started with programming the ESP8266 ESP-12E NodeMCU using Arduino IDE.
      2. Return back to your sensor page on askSensors, click on 'visualize' and 'Show Graph' to view your sensor data in graph.
      3. Open serial terminal. You can cross-check the graph readings with the values being printed on your Arduino Terminal.

      Step 5: DONE!

      That's it!

      Thanks for reading this instructable!

      You can try more tutorials here.

      Finally, your feedback will be appreciated. please leave a comment below!

      Share

      Recommendations

      • Gardening Contest

        Gardening Contest
      • Woodworking Contest

        Woodworking Contest
      • Party Challenge

        Party Challenge

      6 Discussions

      0
      None
      Tod333

      14 days ago

      Thank you for this tutorial. I did everything but I have one error in Arduino IDE. The error is:
      'class axTLS::WiFiClientSecure' has no member named 'setInsecure'
      client.setInsecure();
      ^
      Can you help me?
      Thank you in advance.

      1 reply
      0
      None
      askSensorsTod333

      Reply 12 days ago

      Hello Tod333,
      Thank you for trying this tutorial.
      It seems that you have some issues with including the right WiFiClientSecure.h file.
      1. First, Do an upgrade of your Arduino IDE, and make sure that the ESP8266 target is well installed as shown in this documentation: https://asksensors.com/doc/ConnectHardware.html#re...
      2. make sure that you are compiling the file with the right Target configuration (ESP8266..).
      3. If the issue of setInsecure persists, try out with this example code (where the setInsecure is not used): https://github.com/asksensors/AskSensors-ESP8266-A...
      The result should be the same.

      Hope it helps. It you have any other inquiries, please ask directly in the community Forum so you will get quick answers ;)
      https://forum.asksensors.com/