Ubidots Community

Doubts about tokens and multiple nodes

Hello!
I’m having problems connecting multiple devices to ubidots. I’m using (for now) ubidots STEM and trying to connect 3 nodes through MQTT.

I’ve seen that I can only connect one node to the MQTT broker, and the other nodes get rejected from the broker when they try to connect.
Do I need to use different tokens for every device? (3 devices connected simultaneously to mqtt broker = 3 different tokens) ?


Different question… Is there any way to use SECOND timestamps (like its used worldwide)? I found it pretty “uncomfortable” using a millisecond timestamp on a embedded device.
How is that ubidots is delegating the need to have a 64bits variable on embedded devices instead of just multiplying a SECOND timestamp on the endpoint? Your MQTT library just does that. Mutiplies a SECOND timestamp *1000 so it just wastes memory.
Isn’t it better to multiply it on the server that has GB of memory instead of the 300kb of an embedded device?
Can’t timestamp formant (second-milisecond) be configured by the user? Thats something I can’t understand about a platform meant to receive data from constrained devices, like embedded devices are…

Thanks!

Good day @Emilianoqs

I hope all is well.

Regarding your first question, please keep in mind that you can make 1 request per second per token across all devices, and send up to 4,000 dots per day . You can use a token per device instead of one to avoid hit the request per second limit. As you are using MQTT, make sure that both devices use a different MQTT clientID as the broker allows just one connection per clientID.

Now, about the timestamp, since the beginning, we designed it with milliseconds as it is common to find that a device sends multiple data in the same second, and in some applications, it is important to differentiate them.

An alternative to not consume 64 bits would be using seconds throughout the program (32 bits) and only at the end when you insert that value in the JSON payload, add 3 zeros at the end. Although it still requires more memory, this is only at the end, not during the entire program. Please remember that using the timestamp key is optional, if you don’t send it, Ubidots will assign the timestamp automatically based on the current time.

Additionally, can you please let us know which library are you referring to? normally our library adds 3 zeros at the end of the timestamp instead of multiplying the value for 1000.

Finally, we are working on the documentation of MQTT V2.0 that will allow sending a global timestamp for multiple values, instead of one per value.

Please let me know if you have additional questions.

All the best,
-Isabel

Hello @isalogi. Thanks for your response!

I was trying to connect to the broker from 3 different devices (at the same time). All three using the same token but with different clientIDs. Update interval = 7 min, so no “request per second” problem.

The issue is that when I connect the third device, one of the other two starts disconnecting randomly from the MQTT broker. When one device entablishes connection, the other disconnects and so on (both devices try to reconnect every time connection is lost).

Data was sent -eventually- in between those reconnections, but having the device reconnecting constantly is an unnecessary overhead…

Could not solve that problem, as I think it has something to do with the broker and not my device.

Anyways, now I’m working to use HTTP insted of MQTT. I thing that’ll solve the problem.


That global timestamp feature will be awesome! I’ll be waiting for it. :slight_smile:

Hi @Emilianoqs,

Thank you for your response.

Can you please let me know which devices are you connecting to Ubidots? Also, which library are you using to send data? Please make sure to be using the correct URL industrial.api.ubidots.com for data sending. Finally, since you move to HTTP protocol, are you experiencing the same behavior?

Best,
-Isabel

Hello isalogi.

I was trying to connect 3 ESP32 modules using ESP MQTT client. The data is a JSON created using “ArduinoJson” library. And yes, I was using industrial.api.ubidots.com.

I’m not experiencing problems with HTTP. However I’ve experienced a few moments in which the server refused the data… It gave me error 402 I think, o 403. When I googled it, it was related to something like “Authentication failed” or like that. Anyways, that only happened a few times and for a short period of time (I suppose due to server congestion).

Best!

Hi @Emilianoqs,

Thank you for your response and clarification. In case you move again to MQTT and experience this problem, please let us know so we can investigate what could be happening. Additionally can you please send us a screenshot of the error you get sometimes using HTTP? in that way we can determine if the error is something related to the frequency of the data sending or as you say due to server congestion that we may experience.

All the best,
-Isabel