MQTT Publish and Subscribe using MQTTX (Desktop) - Publish OK subscribe not OK

Hi there :slight_smile:

I am using the desktop app MQTTX before trying Arduino libraries to try MQTT with thinger.io as I believe this gives me a better “feel” for what is going on in the background. It is also nice because I can evaluate and test without any hardware.

I have managed to get an MQTT connection as well as an MQTT publish up and running with MQTTX and thinger.io, but I am missing something when subscribing.

When I publish data from MQTTX, on the device inspector and on the dashboard I can see the data updating.

When I create the widget, I select the device and name the resource name as “Button2”.

On MQTTX I have tried subscribing to “Button2” as well as to “SWLINK/devices/A7670DeviceID/Button2”. I can see the device topic describe events in the inspector.

However, when I toggle the widget I do not see anything in my MQTTX window. Can anyone perhaps please identify what I am doing wrong or guide me in the right direction?
Thank you.

Hi @SWLINK

May I ask why don’t you use the Thinger library for Arduino? I ask this because the widgets were made to work natively with the thinger devices, so the integration is easy and works perfectly.

Note that the “resource” field at the widget refers to a Thinger resource at the remote device, not a MQTT topic or message trigger.

There is a way to emulate Thinger resources to interact with MQTT devices, but this implies the usage of Products business feature, I share the link https://docs.thinger.io/business-features/products/product-profile/api-resources

Hope this helps.

Hi @ega

Thank you for replying so quickly. To answer your first question:

The main reason is that I intend to use a cellular module (A7670) to publish my data to ThingerIO and not a “thinger friendly” device such as an ESP32. Also, I prefer to understand the basics before using libraries… I have found it is easy for libraries to bite you if you just dive in without understanding a few basics at least first. The second reason is that I have managed to use MQTTX to publish and subscribe to numerous IOT platforms so I know it works well and is easy to use with just using my PC and not any other equipment for testing.

I understand in a way where you are coming from. I am “guided” (perhaps misguided) by my experience with other platforms with the assumption that the MQTT broker somehow interfaces with either data buckets or widget data somehow by default.

In Ubidots for example, the method to subscribe to a value is by creating a variable, linking a widget to it and entering the following in your topic field (After first establishing the MQTT connection with usernames, passwords adress etc. of course)
/v1.6/devices/{LABEL_DEVICE}/{LABEL_VARIABLE}/lv
After that, if you change the widget value, MQTT receives an update on the changed variable it is subscribed to. I would imagine the inner workings of ThingerIO is probably similar.

The ThingerIO documentation explains the publish sequence very nicely here using the MQTTFX program (Similar to my desktop program), but I cannot find any information on what the topic or procedure should be to subscribe to an MQTT topic.

https://thinger.io/thinger-io-mqtt-broker/

Is there any way to subscribe to a widget value on the dashboard without using the product feature? (Using the product feature seems like a bit of a workaround for me if it can simply be done directly) Perhaps there is a format to the subscription topic I am not aware of or a step that I am missing? I will dive into the Arduino examples in the mean time and see if maybe I can decipher an answer in there I can implement using MQTTX :blush:

Thank you :clap:

I see, MQTT is a standard protocol, that is why most IoT platform have it supported, at thinger it was ported to be supported when the platform had an advanced maturity level, at thinger’s first steps there was just the IOTMP protocol, therefore was implemented MQTT in order to fully support available devices, for sure the MQTT option suits the best for you if you are going to use 3rd party devices.

The easiest way to show into a widget a MQTT value is to subscribe a bucket to the MQTT topic and call the values from the bucket at the widget.

Hope this helps

Hi Ega,

Thank you for the reply, sorry I am only responding now.
I am glad you agree that MQTT is a good way to go when using third party devices.

With regards to your answer:

That is exactly how I implement MQTT publish from my device to the thinger platform, and this is the part that I am managing to do :blush: My MQTT device publishes the data, the thinger data bucket is subscribed to that published data from the device and the widget shows the value, works like a charm.

Where I get stuck is getting the data from the thinger platform to MY device. (In other words, subscribing my device to a widget using MQTT on the thinger platform, not the other way around.) For example, if I want to see if I need to turn a switch on and off based on a dashboard widget.

Kind regards,
Hermann Havenstein

Hi,

I understand your challenge, that is covered by the product feature or by a node red flow, however those are private instance features, not available at the free community server.

Thinger’s widgets could not be aimed to a MQTT topic directly, they work with “thinger resources” that could be emulated easily by an script and the product feature, in order to interact directly from a widget to a MQTT topic.

Best regards,