Connect the WEMOS D1 Mini ESP8266 with Ubidots

Set up your WEMOS D1 mini with Ubidots in a few minutes using the Arduino IDE.

Similar projects worth following
In this tutorial we will demonstrate how to setup and program the WEMOS D1 mini and an ESP8266 with the Arduino IDE to display your data with Ubidots.
  • Connect the WEMOS D1 Mini ESP8266 with Ubidots

    Maria Carlina Hernandez01/11/2018 at 15:33 0 comments

    The WEMOS D1 Mini ESP8266 is a development board similar to Arduino and developed especially for cost effective Internet of Things applications and solutions. Also compatible with Expressif's ESP32, the WEMOS series is perfect for educational and hobby IoT projects. With a 32 bit architecture (more powerful than the Arduino Due) and WiFi connectivity, you can choose between the Arduino and Lua languages for your application's development.

    In this tutorial we will demonstrate how to setup and program the WEMOS D1 mini and an ESP8266 with the Arduino IDE to display your data with Ubidots.

View project log

  • 2
    Setup WEMOS D1 Mini using the Arduino IDE

    Begin by connecting your WEMOS D1 mini to your computers USB port to configure the device. 

    1.- Download the Arduino IDE if you do not already have it. 1a. - Open the Arduino IDE, select Files -> Preferences and enter the URL below into Additional Board Manager URLs field. You can add multiple URLs and can separate them with commas if needed.

    NOTE: If you're a Mac user, please note that in the Arduino software configurations are slightly different from Windows and Linux. Further, you may have to install the following driver to be able to upload your NodeMCU.

    2.- Open Boards Manager from Tools -> Board -> Boards Manager and install the esp8266 (or esp32) platform. To simply find the correct device, search ESP8266 within the search bar.

    3.- Select your WEMOS D1 mini from Tools > Board menu.

    4.- Additionally, we need to be able to communicate with the WEMOS D1 min, we also need to select the port com. Go to Tools > Port >  Select the appropriate PORT for your device.

    Also, to keep everything running fast and smooth - let's make sure the upload speed is optimized to 115200. Go to Tools > Upload Speed > 115200:

    5.- Close and reboot the Arduino IDE.

  • 3
    Ubidots account Setup

    With the following example you will be able to publish ANALOG readings taken from the A0 pin of the WEMOS D1 mini to Ubidots. 

    1. To post your first value to Ubidots, open the Arduino IDE and paste the code below. Once you have copied the code, you will need to assign the parameters: Wi-Fi name and password, plus your individual, unique Ubidots TOKEN
     * Libraries included
    #include <ESP8266WiFi.h>
     * Constants and objects
    const char* SSID_NAME = "....."; // Put here your SSID name
    const char* SSID_PASS = "....."; // Put here your password
    const char* TOKEN = "....."; // Put here your TOKEN
    const char* DEVICE_LABEL = "wemos-d1"; // Your device label
    const char* VARIABLE_LABEL = "temperature"; // Your variable label
    const char* USER_AGENT = "ESP8266";
    const char* VERSION = "1.0";
    const char* HTTPSERVER = "";
    int HTTPPORT = 80;
    WiFiClient clientUbi;
     * Auxiliar Functions
     * Gets the length of the body
     * @arg variable the body of type char
     * @return dataLen the length of the variable
    int dataLen(char* variable) {
      uint8_t dataLen = 0;
      for (int i = 0; i <= 250; i++) {
        if (variable[i] != '\0') {
        } else {
      return dataLen;
     * Main Functions
    void setup() {
        /* Connects to AP */
      WiFi.begin(SSID_NAME, SSID_PASS);
      while (WiFi.status() != WL_CONNECTED) {
      Serial.println(F("WiFi connected"));
      Serial.println(F("IP address: "));
    void loop() {
      char* body = (char *) malloc(sizeof(char) * 150);
      char* data = (char *) malloc(sizeof(char) * 300);
      /* Space to store values to send */
      char str_val[10];
      /* Read the sensor from the analog input*/
      float sensor_value = analogRead(A0);
      /*---- Transforms the values of the sensors to char type -----*/
      /* 4 is mininum width, 2 is precision; float value is copied onto str_val*/
      dtostrf(sensor_value, 4, 2, str_val);
      /* Builds the body to be send into the request*/   sprintf(body, "{\"%s\":%s}", VARIABLE_LABEL, str_val);
        /* Builds the HTTP request to be POST */
      sprintf(data, "POST /api/v1.6/devices/%s", DEVICE_LABEL);
      sprintf(data, "%s HTTP/1.1\r\n", data);
      sprintf(data, "%sHost:\r\n", data);
      sprintf(data, "%sUser-Agent: %s/%s\r\n", data, USER_AGENT, VERSION);
      sprintf(data, "%sX-Auth-Token: %s\r\n", data, TOKEN);
      sprintf(data, "%sConnection: close\r\n", data);
      sprintf(data, "%sContent-Type: application/json\r\n", data);
      sprintf(data, "%sContent-Length: %d\r\n\r\n", data, dataLen(body));
      sprintf(data, "%s%s\r\n\r\n", data, body);
      /* Initial connection */
      clientUbi.connect(HTTPSERVER, HTTPPORT);
      /* Verify the client connection */
      if (clientUbi.connect(HTTPSERVER, HTTPPORT)) {
            Serial.println(F("Posting your variables: "));
            /* Send the HTTP Request */
      /* While the client is available read the response of the server */
      while (clientUbi.available()) {
            char c =;
       /* Free memory */
      /* Stop the client */
      /* Five second delay */

    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 WEMOS D1 mini. To do this, choose the "right-arrow" icon beside the check mark icon. 

    4. To verify the connectivity of the device, open the serial monitor by selecting the "magnifying glass" icon in the top right corner of our Arduino IDE. 

    5. Confirm your data in Ubidots. Now you should see the published data in your Ubidots account, locate the device called "wemos-d1" and visualize your data. 

View all 4 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates