Ubidots Community

Ubidots library for Particle

I’m using the Ubidots library with a Particle Boron to send sensor data to Ubidots via Particle webhooks.

This basic code works fine:

> ubidots.add("battery", av1, NULL, timestamp_seconds);
>   ubidots.add("sensor1", av2, NULL, timestamp_seconds);
>   ubidots.add("sensor2", av3, NULL, timestamp_seconds);
>   bool bufferSent = false;
>   bufferSent = ubidots.send(WEBHOOK_NAME, PRIVATE);
>   if(bufferSent){
>     Serial.println("Values sent by the device");

This represents a single sample. I was sampling every second and I observed many samples were “missing” at Ubidots. I’d like to build larger payloads - maybe 10 samples - and send those every 10 seconds. If I take a second sample and use ubidots.add() will it overwrite the previous sample?

I have no coding experience, so any help with the actual code or an example would be much appreciated.

Hi @Wineisgud4u,

To answer your question, yes, using ubidots.add() multiple times for the same variable will cause Ubidots to only receive the first sample. To better explain, let’s assume the following code example:

ubidots.add("battery", av1_sample_1, NULL, timestamp_seconds);
ubidots.add("battery", av1_sample_2, NULL, timestamp_seconds);

The above will render a payload as follows (I made up the values :wink:)

  "battery": {"value": 10, "timestamp": 1659632998000},
  "battery": {"value": 11, "timestamp": 1659632999864}

As JSONs cannot contain repeated keys, Ubidots will only save the first “battery” value, the second will be discarded. I guess this is why you were missing data, because other than that, I don’t see why you’d miss data. With this in mind, the Ubidots’ library for Particle doesn’t support sending bulk data, only single samples at a time, and for the foreseeable future, at least in the short-term, it will remain that way.

Now, I recently found a new library developed by a Particle engineer that helps better managing sleep mode while at the same time allows sending bulk data to Ubidots. I’m not sure about the complexity of using it (maybe @chipmc can shed some light about that), but it’s getting traction and I’d recommend checking it out. This is the official post for the library:

I’d also point you to this specific replies that address sending bulk data to Ubidots:


I hope this helps pointing you in the right direction.



Yes, I have been using this approach to send multiple data points in a single payload (and therefore a single data operation). It works well.

@Wineisgud4u , Please take a look at the posts and let me know if you have any questions.


1 Like