> For the complete documentation index, see [llms.txt](https://docs.monogoto.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.monogoto.io/developer/cloud-integrations/ubidots.md).

# Ubidots

[**Ubidots**](https://ubidots.com/) is an IoT platform, allowing IoT developers to rapidly assemble and launch applications without having to write complicated code. It supports multiple protocols to integrate data, including UDP, TCP, HTTP(S) and MQTT.

### Quick Navigation

* [Set up your Ubidots account](#set-up-your-ubidots-account)
* [Send data using UDP](#send-data-using-udp)
* [Send data using HTTP](#send-data-using-http)

### Prerequisites

* Monogoto SIM
* Access to an IoT modem
* Account on Ubidots

## Set up your Ubidots account

You can get started with Ubidots free of charge by [**signing up for a account**](https://industrial.ubidots.com/accounts/signup_industrial/).

In order to send data to Ubidots, you need the following parameters to create the data string:

* **Ubidots Token** starting with <mark style="color:red;">`BBFF`</mark> e.g. <mark style="color:red;">`BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123`</mark>\
  You can find your token when selecting your profile in the top-right corner and select **API Credentials.**

![](/files/T7GR8fCNxdxWYRvq18l6)

* **User agent** \
  You can think of name that will help you identify the IoT application you are working on, e.g. <mark style="color:red;">`iotfleet1`</mark>
* **Device Label** e.g. <mark style="color:red;">`iot-sensor`</mark>\
  The device label is the name of your device as registered in Ubidots. Visit your **Devices** page in the Ubidots console, and select the <mark style="color:blue;">**+**</mark> sign at the top right corner to add a new device and provide its name.

![](/files/P8Ujd2GRa5EQhSysFMBF)

## Send data using UDP

{% hint style="info" %}
Detailed information about using UDP to integrate data, see the [**Ubidots API documentation**](https://docs.ubidots.com/v1.6/reference/tcp-udp).
{% endhint %}

In order to send data using UDP, 4 AT Commands needs to be sent:

1. **Create UDP socket**
2. **Activate socket**
3. **Send UDP data**
4. **Close UDP Socket**

{% hint style="warning" %}
The example below is created for the **Murata Type 1SC module**. When using a different IoT modem, have a look at the AT Commands manual of your modem vendor as the commands might slightly differ.
{% endhint %}

### **1. Create UDP socket**&#x20;

```
AT%SOCKETCMD="ALLOCATE",1,"UDP","OPEN","3.19.87.203",9012 
```

{% hint style="info" %}
Ubidots IP address: <mark style="color:red;">`3.19.87.203`</mark>\
UDP port:<mark style="color:red;">`9012`</mark>&#x20;
{% endhint %}

Example response: <mark style="color:red;">`%SOCKETCMD:1`</mark>

### **2. Activate Socket**&#x20;

```
AT%SOCKETCMD="ACTIVATE",1
```

Example response: <mark style="color:red;">`%SOCKETCMD:1`</mark>

### **3. Send UDP data**&#x20;

In order to send data to Ubidots, you need the following parameters to create the data string:

* **User agent**, e.g. <mark style="color:red;">`iotfleet1`</mark>
* **Ubidots Token** e.g. <mark style="color:red;">`BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123`</mark>
* **Device Label** e.g. <mark style="color:red;">`iotsensor`</mark>
* **Variable Label** e.g. <mark style="color:red;">`temperature`</mark>
* **Value** e.g. <mark style="color:red;">`21`</mark>

To send data to Ubidots, a data string needs to be created with all the parameters mentioned above:

```
USER_AGENT|POST|TOKEN|DEV_LABEL=>[VAR_LABEL:VALUE|end

```

For example:

```
iotfleet1|POST|BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123|iotsensor=>temperature:21|end
```

{% hint style="danger" %}
It' s not possible to send text to the module, instead we need to send hexadecimal values. Convert this text string to hexadecimal numbers using a program like [rapidtables](https://www.rapidtables.com/convert/number/ascii-to-hex.html).
{% endhint %}

The same data, but converted to hexademical number:

{% code overflow="wrap" %}

```
696F74666C656574317C504F53547C424246462D4142434445464748494A4B4C4D4E4F505152535455565758595A303132337C696F7473656E736F723D3E74656D70657261747572653A32317C656E64
```

{% endcode %}

**AT Command**

```
AT%SOCKETDATA="SEND",1,<length>,"<data>"
```

`length` need to be replaced with the amount of bytes you're sending, `data` is replaced by the actual message.

{% hint style="warning" %}
Make sure to exactly count the number of characters you send, or you will receive an error.
{% endhint %}

Example AT Command:

{% code overflow="wrap" %}

```
AT%SOCKETDATA="SEND",1,80,"696F74666C656574317C504F53547C424246462D4142434445464748494A4B4C4D4E4F505152535455565758595A303132337C696F7473656E736F723D3E74656D70657261747572653A32317C656E64"
```

{% endcode %}

Expected response: <mark style="color:red;">`+`</mark><mark style="color:red;">`SOCKETDATA: 1,80`</mark>

{% hint style="info" %}
It may take up to 10 seconds for the message to be fully processed.&#x20;
{% endhint %}

### **4. Close UDP socket**

End your UDP session by closing the UDP socket.

```
AT%SOCKETCMD="DELETE",1
```

Expected response: <mark style="color:red;">`OK`</mark>

If all went well, the Ubidots platform will visualize and store your data:

![](/files/P5NAiQlejMNNjaqUgcda)

## Send data using HTTP

{% hint style="warning" %}
The example below is created for the u-blox SARA R412 modem. When using a different IoT modem, have a look at the AT Commands manual of your modem vendor as the commands might slightly differ.
{% endhint %}

{% hint style="info" %}
Detailed information about using HTTP(S) to integrate data, see the [**Ubidots API documentation**](https://docs.ubidots.com/v1.6/reference/http).
{% endhint %}

In order to send data using HTTP, 4 AT Commands needs to be sent:

1. **Set the HTTP base url** <mark style="color:red;">`AT+UHTTP`</mark>
2. **Set custom headers** <mark style="color:red;">`AT+UHTTP`</mark>
3. **Create a JSON file containing the data you want to send** <mark style="color:red;">`AT+UDWNFILE`</mark>
4. **Send data** <mark style="color:red;">`AT+UHTTPC`</mark>

### 1. Set the HTTP base url&#x20;

AT Command:

```
AT+UHTTP=<profile_id>,1,"<param_val>"
```

* Replace <mark style="color:red;">`<profile_id>`</mark> with an identifier, e.g. <mark style="color:red;">`0`</mark>
* Replace <mark style="color:red;">`<param_val>`</mark> with Ubidots' IP address or domain name: <mark style="color:red;">`industrial.api.ubidots.com`</mark>

The AT Command becomes:

```
AT+UHTTP=0,1,"industrial.api.ubidots.com"
```

To test if the base url was set correctly, enter: <mark style="color:red;">`AT+UHTTP=0,1`</mark>. Expected response:

```
+UHTTP: 0,1,"industrial.api.ubidots.com"
OK
```

### 2. Set custom headers

AT Command:

```
AT+UHTTP=<profile_id>,0,"<param_val>"
```

* Replace <mark style="color:red;">`<profile_id>`</mark> with the same identifier you used before, e.g. <mark style="color:red;">`0`</mark>
* Replace <mark style="color:red;">`<param_val>`</mark> with a counter, going up for each new header you set, followed by the custom header, e.g. <mark style="color:red;">`"0:X-Auth-Token:BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123"`</mark>

Set the first header, containing the **Ubidots authentication token**:

```
AT+UHTTP=0,9,"0:X-Auth-Token:BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123"
```

The second header, contains the **content type** JSON:

```
AT+UHTTP=0,9,"1:Content-Type:application/json"
```

### 3. Create a JSON file containing the data you want to send

AT Command:

```
AT+UDWNFILE="<file_name>",<size>
```

* Replace <mark style="color:red;">`<file_name>`</mark> with any name, e.g. <mark style="color:red;">`sensordata.json`</mark>
* Replace <mark style="color:red;">`<size>`</mark> with the exact number of characters in the file.

To create a new file with 49 characters, called <mark style="color:red;">`sensordata.json`</mark> and add the sensordata, for example: <mark style="color:red;">`{"temperature": 19,"humidity": 90,"pressure": 78}`</mark>

```
AT+UDWNFILE="sensordata.json",49
> {"temperature": 19,"humidity": 90,"pressure": 78}
```

**Read** the contents of the file you just create&#x64;**:**

```
AT+URDFILE="sensordata.json"
```

### 4. Send data&#x20;

AT Command:&#x20;

```
AT+UHTTPC=<profile_id>,4,"<url path>","<responseFilename>","<filesystemName>",4
```

* Replace <mark style="color:red;">`<profile_id>`</mark> with the same identifier you used before, e.g. <mark style="color:red;">`0`</mark>
* Replace <mark style="color:red;">`<url path>`</mark> starting with <mark style="color:red;">`/`</mark>, e.g. <mark style="color:red;">`/api/v1.6/devices/{Device Label}`</mark>&#x20;
* Replace <mark style="color:red;">`<responseFilename>`</mark> with any name to store the server response, e.g. <mark style="color:red;">`data.txt`</mark>
* Replace <mark style="color:red;">`<filesystemName>`</mark>  with the file containing the data you want to send, e.g. <mark style="color:red;">`sensordata.json`</mark>&#x20;

For example:

```
AT+UHTTPC=0,4,"/api/v1.6/devices/iotsensor","data.txt","sensordata.json",4
```

Expected response: <mark style="color:red;">`+UUHTTPCR: 0,4,1`</mark>

If the message was sent correctly, the Ubidots platform will visualize and store your data.

![](/files/FDDHlzDGUmNhaP8SisQm)

Optionally, **delete** the created file so you can recreate it when collecting new sensordata:

```
AT+UDELFILE="sensordata.json"
```

## Useful links

* [Ubidots API documentation](https://ubidots.com/docs/api/index.html)
* [Ubidots docs on UDP/TCP](https://help.ubidots.com/en/articles/702760-send-retrieve-data-from-ubidots-over-tcp-or-udp)

\ <br>
