The Autonomo is a compact Arduino-compatible board that uses the Atmel Cortex M0+ 32bit microcontroller. It was designed to be autonomous (self-sufficient) by enabling it to be powered by a solar panel.

This guide explains how to send data to Ubidots from the SODAQ Autonomo over GPRS.

Requirements

Setup

  1. Download the Arduino IDE here
  2. In the Arduino IDE go to File -> Preferences -> Additional Boards Manager URLs and add this line there “http://downloads.sodaq.net/package_sodaq_index.json”.
  3. Open the Boards Manager via Tools -> Board -> Boards Manager and search for “SODAQ” boards, then select the “SODAQ SAMD” boards for the Autonomo.
  4. Download the ubidots-sodaq-gprsbee library here
  5. Go to the Arduino IDE, click on Sketch -> Include Library -> Add .ZIP Library
  6. Select the downloaded .ZIP file and then click on “Accept” or “Choose”
  7. Close the Arduino IDE and open it again.

SODAQGPRSbee library creates a new Ubidots Data Source named “SODAQGPRSbee”. There the library will save your variables

Send one value to Ubidots

To send one value to Ubidots flash this code into the Autonomo. Please don’t forget to change your TOKEN, APN, USER_APN and PASS_APN.

#include <SODAQGPRSbee.h>

// Put here your SIM APN
#define APN "Your_APN"
// Put here your USER of SIM APN
#define USER "Your_USER_APN"
// Put here your PASSWORD of SIM APN
#define PASSWORD "Your_PASSWORD_APN"

Ubidots Client;

void setup()
{
    // The code will not start unless the serial monitor is opened or 10 sec is passed
    // incase you want to operate Autonomo with external power source
    while ((!SerialUSB) && (millis() < 10000))
        ;

    SerialUSB.begin(115200);
    Serial1.begin(115200);
    Client.setOnBee(BEE_VCC, BEEDTR, BEECTS);
    while(!Client.setApn(APN, USER, PASSWORD));
}

void loop() {
    float value = analogRead(A0);
    Client.add("Temperature",value);
    Client.sendAll();
    delay(1000);
}

Send multiple values to Ubidots

To send multiple values to Ubidots flash this code into the Autonomo. Please don’t forget to change your TOKEN, APN, USER_APN and PASS_APN.

#include <SODAQGPRSbee.h>

// Put here your SIM APN
#define APN "Your_APN"
// Put here your USER of SIM APN
#define USER "Your_USER_APN"
// Put here your PASSWORD of SIM APN
#define PASSWORD "Your_PASSWORD_APN"

Ubidots Client;

void setup()
{
    // The code will not start unless the serial monitor is opened or 10 sec is passed
    // incase you want to operate Autonomo with external power source
    while ((!SerialUSB) && (millis() < 10000))
        ;

    SerialUSB.begin(115200);

    Serial1.begin(115200);
    Client.setOnBee(BEE_VCC, BEEDTR, BEECTS);
    while(!Client.setApn(APN, USER, PASSWORD));
}

void loop() {
    float value0 = analogRead(A0);
    float value1 = analogRead(A1);
    float value2 = analogRead(A2);
    float value3 = analogRead(A3);
    Client.add("Temperature",value0);
    Client.add("Speed",value1);
    Client.add("Heat Index",value2);
    Client.add("Humidity",value3);
    Client.sendAll();
    delay(1000);

Send multiple values with geoposition

The library has a feature to add extra information inside of a variable. In the next example, the code will send a Temperature value and inside of the variable will be saved an extra information: latitude and longitude. Please don’t forget to change your TOKEN, APN, USER_APN and PASS_APN.

Ubidots has a widget to show the position in a map. To show the position this widget need to receive the latitude and longitude in a specific format. The format is “lat” for latitude and “lng” for longitude.

#include <SODAQGPRSbee.h>

// Put here your SIM APN
#define APN "Your_APN"
// Put here your USER of SIM APN
#define USER "Your_USER_APN"
// Put here your PASSWORD of SIM APN
#define PASSWORD "Your_PASSWORD_APN"

Ubidots Client;

void setup()
{
    // The code will not start unless the serial monitor is opened or 10 sec is passed
    // incase you want to operate Autonomo with external power source
    while ((!SerialUSB) && (millis() < 10000))
        ;

    SerialUSB.begin(115200);

    Serial1.begin(115200);
    Client.setOnBee(BEE_VCC, BEEDTR, BEECTS);
    while(!Client.setApn(APN, USER, PASSWORD));
}
void loop() {
    float value1 = analogRead(A0);
    float value2 = analogRead(A1);
    float value3 = analogRead(A2);
    char context[25];
    char context_2[25];
    char context_3[45];

    // Send latitude and longitude to Ubidots to see it in a map widget
    sprintf(context, "lat=1.2343$lng=132.1233");

    // You can send multiple key:value pairs to one variable; just add a "$" symbol between every pair:    
    sprintf(context_3, "Name_Of_Context=Value_Of_Context$Name_Of_Context_2=Value_Of_Context_2$Name_Of_Context_3=Value_Of_Context_3");

    ubidots.add("Temperature", value1, context);  // Change for your variable name
    ubidots.add("Temperature in my house", value3,  context_3);
    ubidots.sendAll();
    delay(5000);
}

Did this answer your question?