Dragino is an IoT device with embed Linux. It is a low cost, open hardware Linux motherboard for micro-controllers. It has USB host port and has full Ethernet and 802.11 b/g/n WiFi capabilities.

Requirements

Dragino modules are the same as Arduino YÚN, so we’ll use the same Yun library for them

Use the Arduino 1.6.5 version or newer with the Dragino.

Setup

1.- Connect your Dragino to the power supply, be careful to use the correct DC adaptor of Dragino.

2.- Check for an unsecure wifi network starting with “Dragino”.

3.- Connect to this network and enter 192.168.240.1 into a web broswer to see the configuration page of the Dragino. The default password is “arduino”

4.- Once you’re connected click on “system”

5.- Specify the Wireless Parameters of your Wi-Fi connection, then press “configure & restart”. This may take several minutes.

6.- Download the UbidotsYUN library here

7.- Go to the Arduino IDE, click on Sketch -> Include Library -> Add .ZIP Library

8.- Select the .ZIP file of UbidotsYUN and then “Accept” or “Choose”

9.- Close the Arduino IDE and open it again.

 This library creates a Ubidots Data Source named YUN when you send variables. There the library will save your variables.

Send values to Ubidots

To send multiple values you can use our example in our library or copy the next code and do not forget to change set there your TOKEN

#include <UbidotsYUN.h>
#define TOKEN "YOUR_TOKEN_HERE"

Ubidots client(TOKEN);

void setup() {
  client.init();
  Serial.begin(9600);

}

void loop() {
  float value = analogRead(A0);
  float value1 = analogRead(A1);
  float value2 = analogRead(A2);
  client.add("Temperature", value);
  client.add("Humidity", value1);
  client.add("Heat Index", value2);
  client.sendAll();
}

Get one value from Ubidots

To get the last value of a variable from Ubidots, go to Sketch -> Examples -> UbidotsYUN library and select the “UbidotsGetValue” example.

#include <UbidotsYUN.h>
#define TOKEN "YOUR_TOKEN_HERE"
#define ID "YOUR_ID_HERE"

Ubidots client(TOKEN);

void setup() {
  client.init();
  Serial.begin(9600);
}

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

Send a value with latitude and longitude

// This example is to save multiple variables with context to the Ubidots API with TCP method

#include "Ubidots/Ubidots.h"

#define TOKEN "Your_Token_Here"  // Put here your Ubidots TOKEN

Ubidots ubidots(TOKEN);

void setup() {
    Serial.begin(115200);
}
void loop() {
    // Connect sensor at pin A0 of Arduino
    float value1 = analogRead(A0);
    char context[25];
    sprintf(context, "lat=%s$lng=%s", char(1.1232), char(4323.123));
    client.add("Temperature", value1, context);
    client.sendAll();
    delay(5000);
}

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.

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.

Did this answer your question?