FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
952 views 16 comments
by anonymous
Hi all, I hope someone can help me setting up my MQTT connection with ubisoft. I've read the few posts available out there but I can't get it resolved. I have attached a doc with screenshots of my RUTX11 setup.

Thanks, Simon
by anonymous
Hi Daumantas,

I've tried various things, pls see attached doc that describes what I tried.

I was able to setup a http to beeceptor and that worked instantly but keeps sending data every sec instead of once every 3600 seconds so in a heartbeat I'm out of my allotment of the subscription...

Best regards,

  Simon
by anonymous

Hello,

  

I've edited your comment to remove the attached file which may contain some confidential information. 

The best way to monitor the root cause would most likely be to watch the logs using logread -f command in the CLI/SSH window. I believe the issue might be with the URL.

In the Ubidots manual, they state that the URL mqtt://industrial.api.ubidots.com should be used, so I'd recommend trying that first, as everything else seems to be configured correctly.

You could also try subscribing to the same channel, to see if any data is actually sent. 

Also, please keep in mind, that the variable %b is what contains the Bluetooth data, not %d.

  

Let me know if that helps!

Best regards,
DaumantasG

by anonymous

Hi, using curl from my macbook I can send data to ubidots (replaced the token string obviously):

curl -X POST https://industrial.api.ubidots.com/api/v1.6/devices/ScheepkeOJH \

-H "X-Auth-Token: xxxxxxxxxxxxxxxx" \

-H "Content-Type: application/json" \

-d '{"temperature": 27}'

Data then is visible in Ubidots.
Next I'll try your flespi suggestion.
Thanks, Simon
by anonymous
Hi Daumantas,

So, using that curl command I can send via http data from my macbook to ubidots. I also have a python script running that successfully sends data via mqtt. That script however is using TLS.

So, I've tried to setup the rutx11 to use TLS, changed the port to 8883 and used the certificate file from ubidots as the certificates file. Does not work.

BTW, should the MQTT publisher itself also not be enabled? I tried with and without, with TLS and without, but it still won't work. QoS set to 1.

So a few check questions :

1) Are you really sure I only need to setup MQTT under "data to server", and the publisher does not need to run?

2) client ID to stay empty, and password to stay empty?

3) I have not rebooted the rutx11 every time I made a config change. Should I?

4) wiki documentation : on the RUTX11 MQTT page as well as the "send data to server" pages there is no reference to each other. It would be nice if those pages were more clear on eg the "data to server" not needing the MQTT publisher to be enabled. Because my thinking automatically is : the MQTT publisher is a generic = core process, it needs to be enabled before the "data to server" would even work. However the "data to server" page also has fields for the URL, so on the otherhand that indicates it can be on its own. But MQTT needs a publisher, my assumption is that in my use case the RUTX11 is the publisher.....

5) also in the documentation, sometimes the JSON strings show a variable %a that is not enclosed by double-quotes, while I think it should?

6) also on TLS, the teltonika wiki is not clear - perhaps for a specialist it is, but eg the ubidots system only has one pem file while the rutx11 screen has options for 3. For a newby it is hard to judge what is needed when.

Anyway, I've spent many hours trying to switch RUTX11 options on and off, experimenting really... Don't know what to do anymore.

Also I was hoping there are logs that would show MQTT connection problems, but I could not find them.

Hope you can assist.... thanks!

best regards,

  Simon
by anonymous

Hello,

   

Regarding your questions:

  • Are you really sure I only need to set up MQTT under "data to server", and the publisher does not need to run?
    • Correct, I believe it uses the same MQTT Publisher under the hood, but as in the WebUI, there are separate options for this MQTT Publisher that do not need to be enabled;
  • client ID to stay empty, and password to stay empty?
    • If there are no special requirements from the Ubidots, then yes;
  • I have not rebooted the rutx11 every time I made a config change. Should I?
    • While it would not hurt, I don't think that's the issue;
  • wiki documentation : on the RUTX11 MQTT page as well as the "send data to server" pages there is no reference to each other. It would be nice if those pages were more clear on eg the "data to server" not needing the MQTT publisher to be enabled. Because my thinking automatically is : the MQTT publisher is a generic = core process, it needs to be enabled before the "data to server" would even work. However the "data to server" page also has fields for the URL, so on the otherhand that indicates it can be on its own. But MQTT needs a publisher, my assumption is that in my use case the RUTX11 is the publisher.....
    • I'll add this to my notes for clarification;
  • also in the documentation, sometimes the JSON strings show a variable %a that is not enclosed by double-quotes, while I think it should?
    • It is because the data is already formatted in JSON, thus double quotes are not needed. Either way this should not prevent the RUTX from sending the data;
  • also on TLS, the teltonika wiki is not clear - perhaps for a specialist it is, but eg the ubidots system only has one pem file while the rutx11 screen has options for 3. For a newby it is hard to judge what is needed when.
    • When hovering over the "Client certificate" field, a tooltip appears: "Add client certificate file. If client certificate is not needed, leave both client certificate and client key fields empty". These tooltips can be useful when configuring something new. In this case, most likely only certificate authority is needed for your service. 

   

Perhaps we could organize a remote troubleshooting session? I'd like to test out your setup with different brokers and see if the data is actually sent. Perhaps you're using RMS?

  

Best reagrds,
DaumantasG 

by anonymous
Hello,

Indeed, it seems like there might be an issue with TSL and MQTT.

Could you try downgrading to v7.02.7, reconfigure the router and see if it works?

Best regards,
DaumantasG

2 Answers

0 votes
by anonymous

Hello,

  

Thank you for reaching out!

A few things to note:

  • If you'd only like to send Bluetooth data periodically to your MQTT Broker ('server') which is xxx.ubidots.com, then MQTT Broker and MQTT Publisher should be disabled. MQTT Publisher is used for requesting data from the RUTX11 when needed, while MQTT Broker is used for MQTT subscribers ('clients') to connect to. Since I presume that Ubidot only receives and stores the data, both of these services are not needed.
  • ClientID field should be left empty, as that way the router will generate a random string to use for this purpose, which will minimize any chances of name conflict (ClientID is a unique ID for each client on the same broker).
  • JSON format field seems to be empty. Text that is in the gray font is only a placeholder for how the string should look like. If you'd only like to send the data from the Bluetooth pucks (without timestamp, name, etc.), then in this field simply leave %b
  • MQTT Gateway is also not needed, as that is used for Modbus devices (thus being in the Modbus menu).

As for how MQTT works, this is a great diagram from mqtt.org:

 

In this case, RUTX11 will be the thermometer in this diagram. It will be publishing temperature data, that it received from the Bluetooth pucks (not visible in the diagram). It will publish on the topic test/temperature to MQTT Broker Ubidots. If I understand correctly, Ubidots stores and processes data. If you'd like to monitor what the RUTX11 is sending to the broker, an MQTT subscriber ('client') can be used by connecting to the same topic (test/temperature) or using a wildcard to subscribe to multiple topics (test/#, where # represents any higher level topic). On the MQTT Subscriber, you'll be able to see the messages that RUTX11 is sending out. This can be useful for troubleshooting.

  

If the setup does not work after addressing these issues, please navigate to System → Administration → Troubleshoot and generate a troubleshoot file. It can be attached to the original post and will only be visible to Teltonika moderators.

  

Best regards,

DaumantasG

by anonymous
Hi Daumantas,

Thanks for the switft reply, much appreciated!

This morning I ran the cmd line command "blesemd -D" and got errors, since then the DB is not updated anymore.

I just ran bledemd -D again and get error "Failed to initialize BLE ubus interface, exiting"

The full output :

Login: root

Password:

BusyBox v1.34.1 (2022-12-15 13:23:19 UTC) built-in shell (ash)

   ____        _    ___  ____

  |  _ \ _   _| |_ / _ \/ ___|

  | |_) | | | | __| | | \___ \

  |  _ <| |_| | |_| |_| |___) |

  |_| \_\\__,_|\__|\___/|____/

 ---------------------------------

   Teltonika RUTX series 2022

 ---------------------------------

root@Teltonika-RUTX11:~# cd /tmp

root@Teltonika-RUTX11:/tmp# blesemd -D

Initializing blesemd...

Warning: debug messages will be shown!

Preparing bluetooth interface...

Attempt to detect HCI device...

Attempt to open 0 HCI device...

Reading config...

Devices loaded: 9

Creating database...

Initializing uloop...

Connecting to ubus...

Initializing BLE device...

Initializing BLE ubus interface...

Adding ubus object...

[main:181] error: Failed to initialize BLE ubus interface, exiting...

How can I fix this? Thanks, Simon
by anonymous
troubleshoot file added.
by anonymous
Hello,

  

In your troubleshoot file I can see, that blesemd is already running. It cannot run when it's also enabled in WebUI, so make sure it's disabled there and try again.

   

Best regards,
DaumantasG
by anonymous
Hi Daumantas,

In the WebUI I can only find something similar on the page where I've paired my bluetooth devices. There is a "save" checkbox. I had them checked, now unchecked. Is that what you mean or is there a separate entry in WebUI to enable/disable blesemd as such?

Thanks, Simon
by anonymous
Hello,

Sorry for not clarifying, that is correct, disabling the Bluetooth in WebUI is what I meant, as it uses blesemd. If you disabled it, it should work now.

Best regards,
DaumantasG
by anonymous
Thx. No, nothing yet, sorry...
by anonymous
Just to clarify, even after router restart and Bluetooth being disabled in the WebUI, blesemd throws the same error?
0 votes
by anonymous
Hi Daumantas,

I've added "mqtt://" to the URL : mqtt://industrial.api.ubidots.com        ....but still no events in ubidots.

According to the screen in server data, %d is the date, and %b is the data. And that is correct as I get those details into beeceptor correctly : %d gives me date info, %b the bluetooth. But indeed I made a typo, I had twice "%d% and now corrected that into { "Device" : "%n", "TS" : "%d", "Data" : "%b" }

I have no blesemd errors that I am aware of, where can I see those errors?

How can I subscribe to "the same" channel to see the data? Sorry, I'm a real newby to this MQTT concept. I do get the data (http-data) into beeceptor. So the core of things on the RUTX11 works (it sends http data), but now the trick is to get MQTT data, and to get it sent to ubidots. Or : any other (preferably free or cheap) platform. I don't mind, my aim is to get temperature data off my RUTX11 into some form of historic data platform. Ideally my Synology NAS at home....

Output of logread :

^Croot@Teltonika-RUTX11:~# logread -f

Mon Jan 23 14:47:01 2023 authpriv.info dropbear[19638]: Exit before auth from <192.168.1.1:56524>: (user 'root', 1 fails): Timeout before auth

Mon Jan 23 14:50:53 2023 daemon.info hostapd: wlan0: STA 70:3e:97:c1:b6:91 WPA: group key handshake completed (RSN)

Mon Jan 23 14:50:53 2023 daemon.info hostapd: wlan0: STA 90:48:6c:a1:64:95 WPA: group key handshake completed (RSN)

Mon Jan 23 14:50:54 2023 daemon.info hostapd: wlan1: STA f4:d1:08:3c:fd:61 WPA: group key handshake completed (RSN)

Mon Jan 23 14:50:54 2023 daemon.info hostapd: wlan1: STA 7e:4e:40:f9:c3:41 WPA: group key handshake completed (RSN)

Mon Jan 23 14:50:54 2023 daemon.info hostapd: wlan1: STA e8:a0:cd:48:ee:16 WPA: group key handshake completed (RSN)

Mon Jan 23 15:00:53 2023 daemon.info hostapd: wlan0: STA 70:3e:97:c1:b6:91 WPA: group key handshake completed (RSN)

Mon Jan 23 15:00:54 2023 daemon.info hostapd: wlan1: STA f4:d1:08:3c:fd:61 WPA: group key handshake completed (RSN)

Mon Jan 23 15:00:54 2023 daemon.info hostapd: wlan1: STA 7e:4e:40:f9:c3:41 WPA: group key handshake completed (RSN)

Mon Jan 23 15:00:54 2023 daemon.info hostapd: wlan1: STA e8:a0:cd:48:ee:16 WPA: group key handshake completed (RSN)

Mon Jan 23 15:00:54 2023 daemon.info hostapd: wlan0: STA 90:48:6c:a1:64:95 WPA: group key handshake completed (RSN)

Mon Jan 23 15:04:50 2023 kern.notice Authentication was successful from HTTPS 192.168.1.1

Mon Jan 23 15:04:50 2023 daemon.err uhttpd[3741]: vuci: accepted login for admin from 192.168.1.1

Mon Jan 23 15:08:51 2023 kern.notice Authentication was successful from HTTPS 192.168.1.1

Mon Jan 23 15:08:51 2023 daemon.err uhttpd[3741]: vuci: accepted login for admin from 192.168.1.1

Mon Jan 23 15:09:49 2023 kern.info kernel: modbus_data_sender configuration has been changed

Mon Jan 23 15:10:53 2023 daemon.info hostapd: wlan0: STA 70:3e:97:c1:b6:91 WPA: group key handshake completed (RSN)

Mon Jan 23 15:10:53 2023 daemon.info hostapd: wlan0: STA 90:48:6c:a1:64:95 WPA: group key handshake completed (RSN)

Mon Jan 23 15:10:54 2023 daemon.info hostapd: wlan1: STA f4:d1:08:3c:fd:61 WPA: group key handshake completed (RSN)

Mon Jan 23 15:10:54 2023 daemon.info hostapd: wlan1: STA 7e:4e:40:f9:c3:41 WPA: group key handshake completed (RSN)

Mon Jan 23 15:10:54 2023 daemon.info hostapd: wlan1: STA e8:a0:cd:48:ee:16 WPA: group key handshake completed (RSN)

Connection is not active anymore.Connection Reset By Peer
by anonymous
Hello,

  

I'll ask you to attach a new troubleshoot file, perhaps I'll find something wrong with the configuration.

  

Best regards,
DaumantasG
by anonymous

Dear Daumantas, 

https://community.teltonika-networks.com/?qa=blob&qa_blobid=2194599477902489248

new troubleshoot file attached.

Kind regards,

  Simon

by anonymous

Hello,

  

In the Data-to-Server configuration, could you try replacing the existing JSON string with the example given in the Ubidots manual:

{"temperature": 10, "luminosity": {"value":10}, "wind_speed": [{"value": 11, "timestamp":10000}, {"value": 12, "timestamp":13000}]};

This will not send any of your Bluetooth device data, but it's useful for testing. It might also help to set the QoS of the data sender to 1 (or 2, if supported by the broker).

  

Further steps for troubleshooting would be to subscribe to the topic you're publishing to, using a third-party MQTT client to see if any data is actually being sent to the Ubidots MQTT Broker. This could be done using a client like Flespi and connecting to the Ubidots broker using the instructions provided in the "Subscribe" section of this page.

  

Let me know how this goes.

Best regards,
DaumantasG