Ubidots Community

[SOLVED] Receiving variables that holds strings (Mqtt)

Hello ubidots,
we are iotbits an startup company on the Iot world that is trying to understand your platform and see if it will work for our customers.
I have paid subscription that is registered under another email.

Our device is mod-bus master that collect’s data from industrial VFD, each vfd has hundreds of variables, but we only read the most important ones and send all them using MQTT to “cloud” or alternative local platforms for data visualization and analysis (Node-red, Grafana).
Each device send 3 different data topics, Slaves data & alarms, and it also send Iot device status.

See below how our json data looks like:

See below how our json status looks like,

We know that ubidots Mqtt publish format must be in the form of
/v1.6/devices/{LABEL_DEVICE} , this means that we can’t use our structure of 3 x mqtt topics per devices I am right?

If the answer to the previous question is yes I would like to hear your advice the best way to blend the variable pairs of our current status topic to the data topic.

In our status topics we have some variables that are not really important so we can get rid of those, but there are other variables that actually are strings and that is problem that we had with ubidot, we tried to send variable holding strings via MQTT, but ubidots do not show them .
for example I have tested the following json object ( took from your guides)
{“temperature”: {“value”:10, “timestamp”: 1464661369000, “context”:{“lat”:-6.2, “lng”:75.4, “my-key”:“hello there”}}, “humidity”: 50}

“my-key” --> hello there is not recognized by ubidots.
Please notice that our status object has several variables that hold strings.
for example
hostame :“hostname”
these variables holding strings are very important for us to be available in the dashboards.
Summarizing we need to know how we have to build the json object with strings pair in order to ubidos can show up them.


See this quick example.
this the Json object:

see what i got under devices variables, notice all the variables holding strings are lost.

Greetings, answering your questions:

You have to use a topic per device, so you should be able to use your actual structure as always as every topic have an unique device label.

I have made a small test with that payload and at my side it works properly:


mosquitto_pub -h "industrial.api.ubidots.com" -t "/v1.6/devices/weather-station" -u "BBFF-MYTOKEN" -p 1883 -q 1 -m '{"temperature": {"value":10, "timestamp": 1464661369000, "context":{"lat":-6.2, "lng":75.4, "my-key":"hello there"}}, "humidity": 50}'

my advise to you is that please make sure that you are using industrial.api.ubidots.com as broker url or, if you are using an educational account, set up things.ubidots.com.

Ubidots only accepts numerical values, that is the reason of your not updated variables. Please modify your strings variables as follows:

  app_version: {"value": 1, "context": {"app_version": "1.0.8"},
  "ssid": {"value": 1, "context": {"ssid": "HEXACAMFL"}},

Besides of my previous answer, please note that Ubidots also offer customized MQTT gateways, with this option you may set up your own topics and JSON parsers in order to avoid these kind of modifications at your device side. If this is something that you are interested in, just shoot a note to an IoT specialist using the embedded chat in your account.

All the best