The Development Kit based on ESP8266, integrates GPIO, PWM, IIC, 1-Wire and ADC all in one board. Power your development in the fastest way by combining with NodeMCU Firmware!

By following this guide you will be able to POST data to Ubidots using the NodeMCU ESP8266 module in just a couple of minutes!    

Requiremets

Step-by-Step

1. Setting up Arduino IDE
2. Sending (POST) Data to Ubidots
3. Summary 

1. Setting up Arduino IDE

1. To be able to work with the NodeMCU ESP8266 platform in the Arduino IDE, you will need to install the ESP8266 platform using the preconfigured Arduino Board Manager. If you are not familiar with adding a board with the Arduino IDE, refer to this article for additional guidance.

2. With the ESP8266 platform installed, select the ESP8266 device you are working with. In the case, we are working with a “NodeMCU 1.0(ESP12E module)”. To select your board from the Arduino IDE, select Tools > Board NodeMCU 1.0(ESP12E module)”.

3. Download and install the UbidotsMicroESP8266. For a detailed explanation of how to install libraries using the Arduino IDE, refer to this guide.   

Note: The library will create a new Ubidots device named "ESP8266" receiving the mac address of the ESP8266 as the unique device label. If you desire assign a different device name and label, please implement the follow lines of code into your setup of your code (no changes are needed in the loop).

  • To change the Device Name:
client.setDataSourceName("New_name");
  • To change the Device label:
client.setDataSourceLabel("New_label");

2. Sending (POST) Data to Ubidots

With the following sample code you will be able to post readings taken from the ANALOG pin of the NodeMCU ESP8266.

1. To post your first value in Ubidots, open the Arduino IDE and paste the sample code below. Once you have pasted the code, you will need to assign your unique Ubidots TOKEN, SSID (WiFi Name) and Password of the available network. 

#include "UbidotsMicroESP8266.h"

#define TOKEN  "Your_token_here"  // Put here your Ubidots TOKEN
#define WIFISSID "Your_WiFi_SSID" // Put here your Wi-Fi SSID
#define PASSWORD "Your_WiFi_Password" // Put here your Wi-Fi password

Ubidots client(TOKEN);

void setup(){
    Serial.begin(115200);
    client.wifiConnection(WIFISSID, PASSWORD);
    //client.setDebug(true); // Uncomment this line to set DEBUG on

}
void loop(){
    float value1 = analogRead(A0);
    client.add("temperature", value1);
    client.sendAll();
    delay(5000);
}

2. Verify your code within the Arduino IDE. To do this, in the top left corner of our Arduino IDE you will see the "Check Mark" icon; press it to verify your code. 

3. Upload the code into your “NodeMCU 1.0(ESP12E module)”. To do this, choose the "right-arrow" icon beside the "check mark" icon. 

4. To verify the connectivity of the device and the data sent, open the serial monitor by selecting the "magnifying glass" icon in the top right corner of the Arduino IDE to see the connectivity logs. 

NOTE: If no response is seen, try unplugging the NodeMCU  and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code 115200.

5. Confirm your data in Ubidots. Now you should see the posted data in your Ubidots account, located the device called "esp8266".  

3. Summary  

With this simple tutorial you are able to POST data to Ubidots with the ease of the Arduino IDE and a NodeMCU ESP8266. If your wish to find more examples to handle context or timestamp values in your request checkout Ubidots documentation with the ESP8266 by clicking here

Now its time to create Ubidots Dashboards to visualize your data and deploy your IoT solution!  Happy Hacking! :) 

Other readers have also found useful...

Did this answer your question?