>

ESP8266 NodeMCU 1.0

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

Requiremets

Setup

  1. Go to the Arduino IDE, click on Files -> Preferences and enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas
  2. Open Boards Manager from Tools -> Board menu and install esp8266 platform (and don’t forget to select your ESP8266 board from Tools > Board menu after installation)
  3. Download the UbidotsMicroESP8266 library here
  4. Now, click on Sketch -> Include Library -> Add .ZIP Library
  5. Select the .ZIP file of UbidotsMicroESP8266 and then “Accept” or “Choose”
  6. Close the Arduino IDE and open it again.

Send one value to Ubidots

The next code is an example that send a Temperature value to the Ubidots variable. The device read a sensor via Analog Pin A0. If you want to use this example don’t forget to change TOKEN, WIFISSID and PASSWORD.

#include "UbidotsMicroESP8266.h"
#define TOKEN  "Your_token_here"  // Put here your Ubidots TOKEN
#define WIFISSID "Your_WiFi_SSID"
#define PASSWORD "Your_WiFi_Password"

Ubidots client(TOKEN);

void setup(){
    Serial.begin(115200);
    delay(10);
    client.wifiConnection(WIFISSID, PASSWORD);
}
void loop(){
    float value = analogRead(A0);
    client.add("Temperature", value);
    client.sendAll(true);
}

Get one value from Ubidots

The next code explain how to get the last value of a Ubidots value, the code will save the value inside “value” variable. If you want to use this example don’t forget to change TOKEN, WIFISSID and PASSWORD.

#include "UbidotsMicroESP8266.h"
#define TOKEN  "Your_token_here"  // Put here your Ubidots TOKEN
#define ID "xxaaaaaxxxxx"  // Variable ID of Ubidots
#define WIFISSID "Your_WiFi_SSID"
#define PASSWORD "Your_WiFi_Password"

Ubidots client(TOKEN);


void setup() {
    Serial.begin(115200);
    delay(10);
    client.wifiConnection(WIFISSID, PASSWORD);
}

void loop() {
    float value = client.getValue(ID);
    Serial.println(value);
}

Send multiple values to Ubidots

In the next code, we will send three values of diferents sensors. If you want to use this example don’t forget to change TOKEN, WIFISSID and PASSWORD.

#include "UbidotsMicroESP8266.h"
#define TOKEN  "Your_token_here"  // Put here your Ubidots TOKEN
#define WIFISSID "Your_WiFi_SSID"
#define PASSWORD "Your_WiFi_Password"

Ubidots client(TOKEN);

void setup(){
    Serial.begin(115200);
    delay(10);
    client.wifiConnection(WIFISSID, PASSWORD);
}
void loop(){
    float value = analogRead(A0);
    float value2 = analogRead(D1);
    float value3 = analogRead(D2);
    client.add("Temperature", value);
    client.add("Humidity", value2);
    client.add("Heat Index", value3);
    client.sendAll(true);
}

GET STARTED
Join thousands of fellow IoT developers using Ubidots to build production-ready IoT solutions.

Sign up for free