Ubidots
Integrate IoT data with Ubidots
Last updated
Integrate IoT data with Ubidots
Last updated
Ubidots 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.
Monogoto SIM
Access to an IoT modem
Account on Ubidots
You can get started with Ubidots free of charge by signing up for a STEM account.
In order to send data to Ubidots, you need the following parameters to create the data string:
Ubidots Token starting with BBFF
e.g. BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123
You can find your token when selecting your profile in the top-right corner and select API Credentials.
User agent
You can think of name that will help you identify the IoT application you are working on, e.g. iotfleet1
Device Label e.g. iot-sensor
The device label is the name of your device as registered in Ubidots. Visit your Devices page in the Ubidots console, and select the + sign at the top right corner to add a new device and provide its name.
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.
Detailed information about using UDP to integrate data, see the Ubidots API documentation.
In order to send data using UDP, 3 AT Commands needs to be sent:
Create UDP socket AT+USOCR
Connect socket AT+USOCO
Send UDP data AT+USOST
AT Command:AT+USOCR=<protocol>
Replace <protocol>
with 17
for UDP, use 6
for TCP.
Example response: +USOCR: 0
AT Command:AT+USOCO=<socket>,"<remote_addr>",<remote_port>
Replace <socket>
with an identifier, e.g. 0
Replace <remote_addr>
with Ubidots' IP address or domain name: 169.55.61.243
, or industrial.api.ubidots.com
Replace <remote_port>
with 9012
(no TLS) or 9812
(TLS)
To connect your IoT modem to Ubidots without TLS, use the following command:
Expected response: OK
In order to send data to Ubidots, you need the following parameters to create the data string:
User agent, e.g. iotfleet1
Ubidots Token e.g. BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123
Device Label e.g. iotsensor
Variable Label e.g. temperature
Value e.g. 21
To send data to Ubidots, a data string needs to be created with all the parameters discussed above:
For example:
AT Command The AT Command to send UDP data is:
When adding all the parameters to the AT Command, the command becomes:
Expected response: +USOST: 0,80
Make sure to exactly count the number of characters you send, or you will receive an error.
If all went well, the Ubidots platform will visualize and store your data:
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.
Detailed information about using HTTP(S) to integrate data, see the Ubidots API documentation.
In order to send data using HTTP, 4 AT Commands needs to be sent:
Set the HTTP base url AT+UHTTP
Set custom headers AT+UHTTP
Create a JSON file containing the data you want to send AT+UDWNFILE
Send data AT+UHTTPC
AT Command:
Replace <profile_id>
with an identifier, e.g. 0
Replace <param_val>
with Ubidots' IP address or domain name: industrial.api.ubidots.com
The AT Command becomes:
To test if the base url was set correctly, enter: AT+UHTTP=0,1
. Expected response:
AT Command:
Replace <profile_id>
with the same identifier you used before, e.g. 0
Replace <param_val>
with a counter, going up for each new header you set, followed by the custom header, e.g. "0:X-Auth-Token:BBFF-ABCDEFGHIJKLMNOPQRSTUVWXYZ0123"
Set the first header, containing the Ubidots authentication token:
The second header, contains the content type JSON:
AT Command:
Replace <file_name>
with any name, e.g. sensordata.json
Replace <size>
with the exact number of characters in the file.
To create a new file with 49 characters, called sensordata.json
and add the sensordata, for example: {"temperature": 19,"humidity": 90,"pressure": 78}
Read the contents of the file you just created:
AT Command:
Replace <profile_id>
with the same identifier you used before, e.g. 0
Replace <url path>
starting with /
, e.g. /api/v1.6/devices/{Device Label}
Replace <responseFilename>
with any name to store the server response, e.g. data.txt
Replace <filesystemName>
with the file containing the data you want to send, e.g. sensordata.json
For example:
Expected response: +UUHTTPCR: 0,4,1
If the message was sent correctly, the Ubidots platform will visualize and store your data.
Optionally, delete the created file so you can recreate it when collecting new sensordata: