A guide that will show you how easy it is to integrate your NodeMCU with AllThingsTalk interactively without any additional hardware.
This guide will also work with any ESP8266 based device with minimal modifications.
After following this guide, you’ll have your NodeMCU sending values from its analog pin to your AllThingsTalk Maker page.
If you’d like to go a step further, you’ll be able to do so at the end of this guide where you’ll be challenged to set a counter that’s triggered once you touch the analog port of your NodeMCU, increasing the number of the counter by one and uploading the number to the platform! (Don’t worry, we got your back if you need help)
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 Arduino compatible boards (such as our NodeMCU) require board support to be installed additionally inside the Arduino IDE. It’s a simple step, so let’s get on with it!
Note: If you already have ESP8266 support installed, skip this step and go straight to Installing Libraries.
In the Arduino IDE, Go to File > Preferences for Windows and Arduino > Preferences on MacOS and add the following URL to Additional Board Manager URLs:
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 NodeMCU board using the sketch (program) below.
To do this, download the following code below and open it in Arduino IDE, or just copy/paste it into your Arduino IDE:
As you may have noticed, the code has a lot of comments (shown after each “//”).
There’s a reason for that. If you’re curious on how the program works, you’ll be delighted to see that the purpose of every line of code was explained so you could understand what’s going on and hopefully play with it and change it in your own way!
However, if you’re eager to see the whole thing in action, let’s jump straight into it and configure the code!
Once done, yours should look a little something like this:
Now comes the part where we upload the program to our NodeMCU board!
Now you’re going to upload the sketch you just configured onto your NodeMCU:
In the bottom part of the Arduino IDE, you should see a message “Compiling sketch” and it should start uploading it to your NodeMCU right after that.
Once you see “Done Uploading.”, the code has been uploaded to your NodeMCU and you’re all set!
You can now go to Tools > Serial Monitor to actually see what’s happening on your NodeMCU. We suggest giving your NodeMCU a reset (by pressing the RST button on your NodeMCU) once you actually enter the Serial Monitor, just so you could see what’s going on from the beginning:
If your NodeMCU has connected to the internet and if you see the “Now publishing data to AllThingsTalk” in your Serial Monitor, it means you’re good to go!
Go to your AllThingsTalk device page and you should see the Analog asset show you the value of your NodeMCU’s Analog pin!
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!
You’ve just successfully integrated your 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 start poking through the code and try to make it do something different!
Could you make a counter that would increment every time you touch the analog pin of your NodeMCU and upload the current number 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!