Skip to main content
All CollectionsConnect your Devices
Connect the Arduino UNO + Adafruit CC3000 WiFi Shield to Ubidots over HTTP
Connect the Arduino UNO + Adafruit CC3000 WiFi Shield to Ubidots over HTTP

Learn to setup and connect the Arduino Uno board with Adafruit CC3000 WiFi Shield to Ubidots using HTTP.

Sergio M avatar
Written by Sergio M
Updated over 3 months ago

Arduino is an open-source electronics platform based on easy-to-use hardware and software. The primary board for Arduino is the Arduino UNO which connects to a series of different shields to expand it’s possibilities.  

The Arduino UNO is a microcontroller board based on the ATmega328P, which contains everything needed to support the microcontroller including simple power supplies via a USB cable, an AC-to-DC adapter, or by battery. For official overviews of the Arduino UNO please refer to its documentation here.
​ 
The Adafruit CC3000 comes in two forms, a WiFi breakout board (the small one shown in the picture above) and an Arduino Shield (the bigger one shown in the picture above). This article uses the Arduino Shield, but the sample firmware provided is the same for each of the CC3000 modules.  

Adafruit CC3000 WiFi shield has a built in TCP/IP stack that allows it to communicate with external servers like Ubidots very simply. For a detailed review of the CC3000 module please reference its official overview.  

Following this guide you will be able to POST and GET data to/from Ubidots using the CC3000 WiFi Shield connected to an Arduino UNO Board in just a couple of minutes!

Requirements

Step-by-Step

 1. Hardware Setup
2. Setting up the Arduino IDE
3. Sending (POST) Data to Ubidots  
4. Receiving (GET) Data from Ubidots
5. Summary

1. Hardware Setup

1. To begin, assemble your CC3000 shield using this Adafruit CC3000 Shield guide. Soldering is required if your shield is not already prepared. 

2. With the shield assembled, place the CC3000 shield atop the Arduino UNO and apply gentle pressure to connect the shield's pins with the board's headers. Now with the Arduino Uno + CC3000 shield is able to connect to the internet over WiFi. 

2. Setting up the Arduino IDE

WARNING: Use the Arduino 1.6.4 version or newer with the CC3000, EXCEPT for the firmware update sketches in the library examples folder. Use 1.0.6 for those!

WARNING: Make sure your Arduino is powered by a 1 amp or higher rated external power supply when using with the CC3000! Powering an Arduino + CC3000 from a computer/laptop USB port will lead to unstable behavior and lockups because the USB port can't supply enough power. :(

1. Download the libraries required & install them :

NOTE: For a detailed explanation of how to install libraries using the Arduino IDE, refer to this guide.

3. Sending (POST) Data to Ubidots  

With the following sample code you will be able to post the ANALOG readings taken from Arduino Board analog port.

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 must assign your unique Ubidots TOKEN, SSID (WiFi Name) and Password of the available network.

/********************************
 * Libraries included
 *******************************/
#include <UbidotsCC3000.h>
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>

/********************************
 * Constants and objects
 *******************************/
#define WLAN_SSID       "SSID_here"  // Your WiFi SSID, cannot be longer than 32 characters!
#define WLAN_PASS       "Your_pass_here"  // Replace it with your WiFi pass
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
/* Assigns the Ubidots parameters */
#define TOKEN "Your_token_here"  // Replace it with your Ubidots token
#define VARIABLE_LABEL "temperature" // Assign the Ubidots variable label

/* initialize the instance */
Ubidots client(TOKEN);

/********************************
 * Main Functions
 *******************************/
void setup() {
  Serial.begin(115200);
  client.initialize();
  client.wifiConnection(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
  //client.setDeviceLabel("my-new-device"); // Uncomment this line to change the default device name
  //client.setDebug(true); // Uncomment this line to set DEBUG on
}

void loop() {
   /* Sensors readings */
  float value = analogRead(A0);
 /* Sending value to Ubidots */
  client.add(VARIABLE_LABEL,value);
  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 Arduino UNO + CC3000 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 your Arduino 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 "arduino-cc3000".  

4. Receiving (GET) Data from Ubidots

With the following sample code you will be able to get a value from Ubidots to start controlling any asset you desire. 

1. To start getting values from Ubidots, open the Arduino IDE and paste the sample code below. Once you have pasted the code, be sure to assign the following parameters:

/********************************
 * Libraries included
 *******************************/
#include <UbidotsCC3000.h>
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>

/********************************
 * Constants and objects
 *******************************/
#define WLAN_SSID       "SSID_here"  // Your WiFi SSID, cannot be longer than 32 characters!
#define WLAN_PASS       "Your_pass_here"  // Replace it with your WiFi pass
// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
/* Assigns the Ubidots parameters */
#define TOKEN "Your_token_here"  // Replace it with your Ubidots token
#define DEVICE_LABEL "Your_label_here" // Replace it with your Ubidots' device label
#define VARIABLE_LABEL "Your_label_here" // Replace it with your Ubidots' variable label

/* initialize the instance */
Ubidots client(TOKEN);

/********************************
 * Main Functions
 *******************************/
void setup() {
  Serial.begin(115200);
  client.initialize();
  client.wifiConnection(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);
  //client.setDebug(true); // Uncomment this line to set DEBUG on
}

void loop() {
  /* Getting the last value from a variable */
  float value = client.getValue(DEVICE_LABEL, VARIABLE_LABEL);
  /* Print the value obtained */
  Serial.print("The value obtained is: ");
  Serial.println(value);
  delay(5000);
}
NOTE: If no response is seen, try unplugging your Arduino and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code.

2. Verify & Upload the code into the board following the same steps provided in the POST step above.

3. To verify the connectivity of the device and the data which is being received, 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 your Arduino and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code.

4. In the serial monitor, you will be able to see the last value received in Ubidots of the variable specified in the firmware.  

5. Summary  

With this simple tutorial you are able to POST & GET data to/from Ubidots with the ease of the Arduino IDE and an Arduino UNO Board + CC3000 Module. If your wish to find more examples to handle context or timestamp values in your request checkout Ubidots documentation with the CC3000 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?