This document has been moved to AllThingsTalk Learning Centre.
Integrate your ESP8266-based NodeMCU (or any ESP8266-based board) with AllThingsTalk interactively without any additional hardware in less than 15 minutes.
After following this guide, you’ll have your ESP8266 (NodeMCU) sending values from its analog pin to your AllThingsTalk Maker page.
And, if you’d like to go a step further, you’ll be able to do so at the end of this guide!
The Arduino Integrated Development Environment (IDE) is an open source, cross-platform application that’s used for programming Arduino boards! It runs on Windows, Mac OS X, and Linux.
Some boards (such as the ESP8266) require board “cores” to be installed inside the Arduino IDE. This enables Arduino IDE to program the board. It’s a simple step, so let’s get on with it!
In the Arduino IDE, Go to File > Preferences for Windows (Arduino > Preferences on MacOS) and add the following URL to Additional Board Manager URLs:
1 | http://arduino.esp8266.com/stable/package_esp8266com_index.json |
We’ll need a few libraries that the example sketch relies on, so let’s install them:
To create a new device in AllThingsTalk maker, do the following:
Now we’re going to program our ESP8266 (NodeMCU) board using the sketch (program) below.
To do this, click download below and open it in Arduino IDE, or just copy/paste the code into your Arduino IDE:
1 | #include <AllThingsTalk_WiFi.h> // Load (include) the AllThingsTalk WiFi SDK - Read more about it on https://gitub.com/allthingstalk/arduino-wifi-sdk |
As you may have noticed, the code has a lot of comments (shown after each “//”), so if you’re curious about how it works, you’ll get it in no time!
Alright, let’s see the thing in action by configuring the code:
Now you’re going to upload the sketch you just configured onto your ESP8266:
In the bottom part of the Arduino IDE, you should see a message “Compiling sketch” and it should start uploading it to your ESP8266 right after that.
Once you see “Done Uploading.”, the code has been uploaded to your ESP8266 and you’re all set!
You can now go to Tools > Serial Monitor to actually see what’s happening on your ESP8266. Make sure to set the baud rate of your Serial Monitor to 115200.
Give your ESP8266 a reset (by pressing the RST button on your NodeMCU) after you open Serial Monitor so you could see what’s going on from the beginning:
If your ESP8266 (NodeMCU) has connected to the internet and if you see the “Connected to AllThingsTalk!” in your Serial Monitor, you’re good to go!
You should see the blue LED on your ESP8266 start fading in/out (it’s a new feature of our SDK), which means it’s connecting to WiFi and AllThingsTalk.
Once it blinks quickly and goes off, it means you’re connected!
Go to your AllThingsTalk Maker device page and you should see 2 new assets in your device: “Analog Value” and “WiFi Signal Strength”. These were automatically created by your ESP8266 (NodeMCU).
You’ll see the analog pin value being shown on the “Analog Value” asset and WiFi Signal Strengh of your ESP8266 on the other.
And now, for the real trick, try touching the Analog pin (marked as “A0” on your NodeMCU) and see the value of your Asset on AllThingsTalk update in real-time!
Congratulations!
You’ve just successfully integrated your ESP8266 (NodeMCU) with the platform. And yes, it’s that easy!
Now, this is barely scratching the surface of what’s possible with our platform and the device in front of you, so if you’re curious, we suggest you check our Arduino WiFi SDK and the examples that come with it!
Could you make a counter that would increment every time you touch the analog pin of your ESP8266 (NodeMCU) and upload the current counter value to your AllThingsTalk device page?
Don’t be discouraged, it may sound hard, but it’s actually very easy and doesn’t require a whole lot of stuff to make it happen. Oh, and you also have the comments on the code to help you understand what’s going on!
Give it a try and if you get stuck, we’ve already wrote the code for you to help you out, and you can use it if you need it (don’t cheat!). Happy making!
1 | #include <AllThingsTalk_WiFi.h> // Load (include) the AllThingsTalk WiFi SDK - Read more about it on https://gitub.com/allthingstalk/arduino-wifi-sdk |