Update Multiple data with Absolute time stamp


#1

Hello,

I’m developing a device, arduino based, for upload a meteo data to ubidots platform. I have a question about a possibility to upload a bulk file with absolute time stamp. Does it possible to Write many entries to my channel, with a single http request in Ubidots Environment?

I use arduino uno and sim 900 ( Ubidots Arduino GPRS library).

Thank you

Francesco-Italy


#2

Hello @idroino,

Firstly, I would like to clarify something… What do you mean by “Absolute timestamp”?

To upload multiple data with a different timestamp in single HTTP request you should use the following endpoint and payload structure:

http://things.ubidots.com/api/v1.6/devices/{LABEL_DEVICE}/{VARIABLE_LABEL}/values

[{“value”: 10, “timestamp”:1464661369000}, {“value”: 12, “timestamp”:1464661369999}, {“value”:n, “timestamp”:n}]

Please, refer to this link to find all the information needed.

All the best,
Maria C.


#3

Thank you very much.This is exatly that I wondering.
For Absolute timestamp i i mean a value that has a specific time of entry, different of the upload time, in ubidots personal dashboard.

I have another question about the code:

I use a specific library ubidots-arduino-gprs for connect my sim module to Arduino

I try to change this code but the upload don’t works appropiatly:

void loop() {

_ float value = 1;_
_ int timestamp;_
_ sprintf(timestamp, “1525635620”); //Sends latitude and longitude for watching position in a map_
_ client.add(VARIABLE_LABEL, value, timestamp); // Change for your variable name_
_ client.sendAll();_
}

the first part, is the same of Example UbidotsSaveValueWithContext;

Thank you for your help

Francesco P.


#4

Hey Francisco!

I’m glad to read that, we are here to help! :smiley:

In the loop of the code I can see that you have assigned the timestamp instead of the context as it’s mentioned in the comments of the code. Based on this, what do you desire to assign a context or timestamp?

Now, based on what you desire to sent you should follow the next points:

  • Send context:
Ubidots::add(char *variable_label, double value, char *ctext)

Example:

  sprintf(context, "lat=1.2343$lng=132.1233"); 
  client.add(VARIABLE_LABEL, value, context); 
  • Send timestamp:
 Ubidots::add(char *variable_label, double value, char *ctext, long unsigned timestamp_val)

Example:

  sprintf(timestamp, "1531143251");
  client.add(VARIABLE_LABEL, value, NULL, timestamp); // Change for your variable name

I hope this would help you!

All the best,
Maria C.


#5

Thank you,

yes I’ll send timestamp to ubidots.

I looked at your second example and I wrote the following code (the first part is the same of my last example):

void loop (){

double value = 9999;
long unsigned timestamp;
char context[25];

sprintf(timestamp, “1525635620”); //Sends latitude and longitude for watching position in a map
client.add(VARIABLE_LABEL,value,NULL,timestamp); // Change for your variable name
client.sendAll();
}

Unfortunately the value isn’t loaded on my dashboard.

Maybe something miss in my code, but i don’t now,

Thank you for your help

Francesco P.


#6

Hey @idroino,

Taking a look of the code everything seems to be ok! Anyway, I’m going to make a test by my side and I will let you how everything goes :smiley:

All the best,
Maria C.


#7

Thank You I’ll wait your text!:pray:

Best Regards,

Francesco P.


#8

Hi, finally I solved the problem with my script!

Now I have another question about the sim900 library and Arduino Mega.

Are they compatible? Is there something that I can change in the library for use Ubidots with sim 900 and arduino Mega?

With arduino uno everything is ok but i have some problem with free memory…

Thank you

Regards

Francesco P.


#9

Greetings, the library uses a stream client to send data to the GPRS shield using the unique serial port of the Arduino Uno, said that, I do not think that the library gives issues with the port of the Arduino Mega as always as the default one remains to be of Arduino UNO. BTW, we have not tested this library with a Mega, so you will have to test it to know if it works properly.

All the best


#10

Thank you for your clarification. I tryed to send values from arduino Mega to my Ubidots channel but unfortunately the sistem didn’t trasmit anything. I used the same sketch that i used with arduino Uno. A that time with uno everything was ok.

I ask you if can at this point, solve the problem changing t something in the GSM library or i have to think about at another solution?

Thank you,

Regards


#11

I would advise you to create your own script based on the provided example by the SIM 900 Arduino library official TCP client example, at our new docs you can find several payload examples build in pure C out of the box that can serve to you as reference.

All the best