Skip to main content
All CollectionsConnect your Devices
Connect an impExplorer Kit to Ubidots over HTTP
Connect an impExplorer Kit to Ubidots over HTTP

Build an end-user ready IoT application with Electric Imp and Ubidots over the HTTP Protocol.

Sergio M avatar
Written by Sergio M
Updated over a month ago

Electric Imp offers an innovative and powerful Internet of Things platform that securely connects devices to the internet using advanced cloud computing resources. Every device on the Electric Imp platform is powered by impOSTM, a small, efficient, and secure operating system. The imp Platform includes unique management layers for full lifecycle management, such as secure Over the Air (OTA) updates, secured communications, and remote monitoring. Electric Imp hardware seamlessly connects devices to the cloud, enabling innovative commercial and industrial applications that empower developers and integrators to manage and quickly scale their connected products and services to millions of users.

Developers can leverage the Electric Imp’s platform and Ubidots to quickly deploy end-user ready IoT applications. In this guide you’ll learn how to use Electric Imp's impExplorer™ Kit to send data from its sensors to Ubidots.

The Electric Imp impExplorer™ Kit is the ideal hardware for building self-contained connected IoT solutions. It includes not only a lineup of temperature, humidity, motion, and pressure sensors, but also an RGB LED for visible feedback. Additionally, the impExplorer also provides Grove System headers for expansion modules when needed. Two of these connectors are intended for I²C peripherals, the others for analog and/or digital devices.

In this guide you’ll learn how to setup and send data from the Electric Imp's impExplorer™ Kit to Ubidots IoT Application Development Platfrom using HTTP.

Requirements

Step-By-Step

  1. Electric Imp Setup

  2. Programming the ImpExplorer

  3. Data visualization  

  4. Summary 

1. Electric Imp Setup

To start with the Electric Imp Environment, refer to this Ubidots guide which provides a detailed and usable explanation of how to:

  • Activate & Connect your Imp Device

  • Create Product in impCentral

  • Create a Development Group in impCentral

  • Code Management

IMPORTANT NOTE: If you are already familiar with the points mentioned above, feel free to continue with the guide :)  

2. Programming the ImpExplorer

We're going to provide you a sample code to send the sensor's readings to Ubidots.

1. Below you will find the sample codes for the Agent & Device section blocks in the impCentral IDE. Copy and paste each code into its respective IDE in the impCentral development portal.

Once you've pasted the Agent code, you will need to assign your Ubidots token inside the client constructor. This will look a little something like: 

 Ubidots <- Ubidots.Client("BBFF-YTP65d9ngV6*******************")

PRO TIP:  The Ubidots library takes the Device ID and creates a new device in your Ubidots account the first time a dot is sent. If desired, you can change this default configuration using the method setDeviceLabel("New-Device-Name") where applied in the sample code below.

  • Agent code

#require "Ubidots.agent.lib.nut:1.0.0"

Ubidots <- Ubidots.Client("Your_Ubidots_TOKEN_here");

Ubidots.setDeviceLabel("impExplorer"); // to set the device label

device.on("saveValue", function(data){
   
    Ubidots.sendToDevice(data);
    server.log("Sending data to Ubidots");
    server.log(http.jsonencode(data));
});
  • Device code

#require "HTS221.device.lib.nut:2.0.0"
#require "LPS22HB.class.nut:1.0.0"

data <- {};
data.temp <- 0;
data.humid <- 0;
data.pressure <-0;

hardware.i2c89.configure(CLOCK_SPEED_400_KHZ);

// Temperature and humidity sensor
tempHumid <- HTS221(hardware.i2c89);
local dataRate = tempHumid.setMode(HTS221_MODE.CONTINUOUS, 7);

//pressure sensor
pressureSensor <- LPS22HB(hardware.i2c89);
pressureSensor.softReset();


function mainLoop() {
   
    pressureSensor.read(function(result) {
       data.pressure = result.pressure;
   
        tempHumid.read(function(result) {
           
            data.temp = result.temperature;
            data.humid = result.humidity;
           
           
            agent.send("saveValue", data);
           
            imp.wakeup(1.0, mainLoop);
        });

    });
}

mainLoop();

Once you've pasted the codes to the respective windows in the impCentral portal, you will see a little something like this:

2. At this point, you need to verify if the codes included are in the right format. To do this, just press the "Check"  button. 

3. With the code verified, it's now time to run the code into the imp module. To run and download the code into the hardware you have to press the button "Build and Force Restart"

Once the downloading process starts you will begin receiving the logs of the download process and the payload which is being sent to Ubidots.

3. Data visualization

Go to your Ubidots account to confirm everything is correct. In the device tab in your Ubidots account, you will see a new device created called "impexplorer.":

Select any device in your Ubidots account to visualize a particular sensor's readings that are being visualized and enabled by Ubidots platform. 

4. Summary

This guide strolled you through the fundamentals of setting up and sending data from the impExplorer Kit to Ubidots. As always, with any questions or concerns, please contact your friendly Ubidots Engineers for assistance by starting a conversation with our In-App services at Ubidots.com or you may also find your answer in our ever growing Ubidots Help Center.

Now it is time to create a dashboard to control and manage the variables of your impExplorer. If you don't know how Ubidots dashboards and widgets work, be sure to check out the Ubidots Academy to find other guiding video tutorial and examples. 

Happy hacking! :)

Other readers have also found helpful...

Did this answer your question?