Introduction: How to Connect the ESP8266 NodeMCU to the IoT Cloud
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.
Step 1: Materials You Need
To follow along with this tutorial you will simply need:
- Computer running arduino software
- ESP8266 Node MCU
- 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:
- Click on 'New Sensor' to create a communication channel with unique ID and Api Keys. Give a name and description to your sensor.
- Add a module for the data you will be plotting.
- 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
- 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.
- Return back to your sensor page on askSensors, click on 'visualize' and 'Show Graph' to view your sensor data in graph.
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!
1 Person Made This Project!
- YoussefG11 made it!
10 Discussions
Question 10 months ago on Step 3
Where does it put/post data?
The only thing I can see in the github code is get commands.
And I cannot see where it sends data? Probably me who is blind
Answer 9 months ago
Hello,
Please read this article, it shows you with more details how to create a sensor device from the AskSensors web application and how to visualize your data.
https://asksensors.com/doc/create-sensor-device.ht...
1 year ago
So does this means that it will take atleast 25 seconds(delay) to respond to the instruction/commands from the cloud ?
Reply 11 months ago
Hello,
No, The delay of 25sec is set as example.
With paid account you can send data every second.
With free account, you can send data every 10 seconds.
1 year 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.
Reply 1 year 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/
2 years ago
it works fine me, thanks
Reply 2 years ago
good, Thanks :-)
2 years ago
Great first Instructable. Thanks for sharing it with the community.
Reply 2 years ago
Thanks.
happy to join the instructables community :-)