Ubidots Community

[SOLVED] Issue with Sending Data

I’m using a group of 50 Particle Electrons to send environmental data (every 4 hours) to Ubidots. I’ve noticed that in very select few cases, although my Particle Electrons connect to the Particle Cloud, they do not actually send their data correctly to Ubidots. I would say this happens probably less than 2% of the time, but it is still big enough of an issue that on some days it renders sensors useless as the correct environmental data can’t be accessed by people.

Here’s (a simplified) part of my code responsible for sending the data:

case UPLOAD:
   if (Particle.connected()) {
     volt = batteryMonitor.getVCell();
     soc = batteryMonitor.getSoC();
     EEPROM.get(statusadd, status);
     ubidots.add("Voltage", volt);
     ubidots.add("Charge", soc);
     ubidots.add("Status", status);
     if (ubidots.sendAll()){
         Serial.println("Ubidots values sent");
     state = VERSIONCHECK;
   if (millis() - stateTime >= 20000) {
        state = VERSIONCHECK;

I have at least two examples from today where the Simcards were shown to have connected to the data network, and the Particle Cloud. So my assumption is that delay(10000); in some cases is not sufficient enough time for Ubidots. Are there any kind of while/if-statements I could use to mitigate this? I would prefer not to increase the delay even further, as this would reduce the battery lifetime of my sensor.

Hi there @Vitesze,

I would advise you to use Particle webhooks for the reasons below:

  1. All your data will be encrypted, our actually library does not support encrypted data due to the limitations of the microcontroller to manage SSL certificates.
  2. Using webhooks you will not have any need for delay times.
  3. Using webhooks you can use our HTTP endpoint that supports a higher sampling request.

For more information about how to create particle webhooks for sending data to Ubidots, please refer to this article.

All the best.

1 Like

I’m experiencing some slight issues with using a webhook to retrieve my sensor data. The sensor publishes the data fine, and it also shows up in Particle’s internal webhook screen, but for some reason the data won’t appear in Ubidots. It is currently happening for about 70-80% of the data I send.

For instance, for one of my devices I can tell that the sim was active at 1.04pm, and that it also established a connection with the Particle Cloud. The Ubidots webhook was triggered at 1.04pm as well, but the following HTTP response was generated:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 21 Feb 2018 21:04:04 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Vary: Cookie

{“status”: [{“status_code”: 204}], “charge”: [{“status_code”: 204}], “voltage”: [{“status_code”: 204}], “collection”: [{“status_code”: 400, “errors”: {“value”: [“A valid number is required.”]}}]}

My webhook currently looks like this (Token value changed for obvious reasons)

The data I send typically looks like this:

{“vlt”: “3.45”, “soc”: “1.30”, “stt”: “1”, “cll”: “1”}

My Webhook for Thingspeak works just fine, so I’m not really sure what the problem here is.

Hi there, I see that you are getting a 400 response error which means that your payload was not built properly or an invalid token was used. Do you have some examples of the payload that you sent once you got a 400 response error?

Hi, I’m pretty sure I identified the issue already, and fixed it. The problem was that depending on the time of the day, I would send different environmental data to Ubidots. So in one case, I would not be sending any data for a variable that the Ubidots webhook was expecting information for, creating the ‘‘A valid number is required’’ error. So I created a second webhook that gets triggered instead for cases like these.

Hi @Vitesze,

I am glad that you found the issue, hope your project goes on the wheels! :slight_smile:

All the best