Ubidots (verified community library)

Summary

Name Value
Name Ubidots
Version 3.2.3
Installs 245790
Verification verified
License MIT
Author Ubidots devel@ubidots.com, Jose Garcia jose.garcia@ubidots.com
Maintainer Jose García jose.garcia@ubidots.com
URL https://github.com/ubidots/ubidots-particle
Repository https://github.com/ubidots/ubidots-particle
Download .tar.gz
All Versions 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 2.1.14, 2.1.13, 2.1.12, 2.1.11, 2.1.10, 2.1.9, 2.1.8, 2.1.7, 2.1.6, 2.1.4, 2.1.3, 2.1.2, 2.1.0, 2.0.5, 2.0.4, 2.0.3, 2.0.1, 2.0.0, 0.0.2

Ubidots library for Particle devices Intended to send or retrieve data from Ubidots through TCP/UDP/HTTP/ParticleWebhooks.

Example Build Testing

Device OS Version:

This table is generated from an automated build. Success only indicates that the code compiled successfully.

Library Read Me

This content is provided by the library maintainer and has not been validated or approved.

Particle

Here you will learn how to send data to Ubidots using Particle Photon or Electron devices. You just need the variable label and value that you want to send along with an Ubidots valid TOKEN. In addition you're able to get the last value of a variable from your Ubidots account.

Requirements

  • Particle Device
  • Micro USB cable
  • Internet connection
  • Note: For the last version of the library is necessary to have your particle device with firmware version 0.7.0 or above.

Setup

  1. Set up WiFi connection to the photon. There are two ways to do this:
  2. Using your smart phone.
  3. Connecting it to your computer over USB.
  4. After claiming your Photon and setting up your Ubidots account, let's go to Particle's Web IDE.
  5. In the Particle's Web IDE create a new app and set the name.
  6. Go to the library tab.
  7. In contributed library write Ubidots and select the Ubidots library.
  8. Click on INCLUDE IN APP. And return to "MYAPP.ino"

This library creates by default new Data Source. The name of this data source will be "Particle" by default, and his label will be you Particle ID.

The default method is TCP, if you want to change it go to the features sections and follow the example.

Warning: About Particle Mesh

After the announcement of the deprecation of the Particle Mesh IoT protocol, as Particle is no longer producing Mesh units, Ubidots has decided to stop to support it out of the box in this library. If you need to still use the Mesh IoT protocol in your project in conjunction with our library, please compile your project through the Particle CLI with the version v3.1.4 of this library.

Documentation

Constructor

Ubidots
Ubidots(char* token, UbiServer server, IotProtocol iot_protocol)
  • @token, [Required]. Your Ubidots unique account TOKEN.
  • @server, [Optional], [Options] = [UBI_INDUSTRIAL], [Default] = UBI_INDUSTRIAL.
  • @iot_protocol, [Optional], [Options] = [UBI_HTTP, UBI_TCP, UBI_UDP, UBI_PARTICLE], [Default] = UBI_TCP. The IoT protocol that you will use to send or retrieve data.

Creates an Ubidots instance.

NOTES

  • UBI_PARTICLE sends data using webhooks, so make sure to follow the instructions to set up your webhook properly here.

Methods

void add(char *variable_label, float value, char *context, unsigned long dot_timestamp_seconds, unsigned int dot_timestamp_millis)
  • @variable_label, [Required]. The label of the variable where the dot will be stored.
  • @value, [Required]. The value of the dot.
  • @context, [Optional]. The dot's context.
  • @dot_timestamp_seconds, [Optional]. The dot's timestamp in seconds.
  • @dot_timestamp_millis, [Optional]. The dot's timestamp number of milliseconds. If the timestamp's milliseconds values is not set, the seconds will be multplied by 1000.

Adds a dot with its related value, context and timestamp to be sent to a certain data source, once you use add().

Important: The max payload lenght is 700 bytes, if your payload is greater it won't be properly sent. You can see on your serial console the payload to send if you call the setDebug(bool debug) method and pass a true value to it.

float get(const char* device_label, const char* variable_label)
  • @device_label, [Required]. The device label which contains the variable to retrieve values from.
  • @variable_label, [Required]. The variable label to retrieve values from.

Returns as float the last value of the dot from the variable. IotProtocol getCloudProtocol()

std::map<int, float> tcpMap getMultipleValues(const char* deviceLabel, const char* variableLabels)
  • @deviceLabel [Mandatory] pointer that stores the label of the device to retrieve values from.
  • @variableLabels [Mandatory] comma separated variable labels to retrieve values from

Returns an ordered map list with the values retrieved for the provided variable labels. The values can be accesed by index, starting at position 0, and are mapped to every variable label set in the comma separated array.

void addContext(char *key_label, char *key_value)
  • @key_label, [Required]. The key context label to store values.
  • @key_value, [Required]. The key pair value.

Adds to local memory a new key-value context key. The method inputs must be char pointers. The method allows to store up to 10 key-value pairs.

void getContext(char *context)
  • @context, [Required]. A char pointer where the context will be stored.

Builds the context according to the chosen protocol and stores it in the context char pointer.

void setDebug(bool debug);;
  • @debug, [Required]. Boolean type to turn off/on debug messages.

Make available debug messages through the serial port.

bool send(const char* device_label, const char* device_name, PublishFlags flags);
  • @device_label, [Optional], [Default] = PARTICLE DEVICE ID. The device label to send data. If not set, the PARTICLE DEVICE ID will be used.
  • @device_name, [Optional], [Default] = @device_label. The device name otherwise assigned if the device doesn't already exist in your Ubidots account. If not set, the device label parameter will be used. NOTE: Device name is only supported through TCP/UDP, if you use another protocol, the device name will be the same as device label.
  • @flags, [Optional], [Options] = [PUBLIC, PRIVATE, WITH_ACK, NO_ACK]. Particle webhook flags.

Sends all the data added using the add() method. Returns true if the data was sent.

IotProtocol getCloudProtocol();

Retrieves the actual cloud protocol used to send data from the Mesh gateway.

Examples

Refer to the examples folder

Browse Library Files