Subscribe to topic on another device


Is it possible to subscribe to a topic that is published by another device using cayenne mqtt? can someone point me to an example?
Using this now but only works on the same device.

CAYENNE_LOG(“CAYENNE_IN_DEFAULT(%u) - %s, %s”,, getValue.getId(), getValue.asString());
digitalWrite(13, getValue.asInt());

tried using mqttfx and changing the client ID but wont work


Hello @brianb6000,

Yes this is possible. I have played with MQTT a bit (well acutally a lot) in Cayenne and you can achieve this very simply.

Within second mqtt device you need to subscribe for topic like v1/username/things/clientID/data/channel/+. The clientID should be the clientID of the first device.

Eventually you can subscribe for v1/username/things/# to receive any messages related to any clientID.



Cant get it to work. iIhave esp8266 publishing the example sketch “current millis” to my dashboard on channel O working.
how can i subscribe to it using MQTT.fx. i tried ;

v1/username/things/clientID/data/channel -the client ID of the esp8266
i receive nothing
The dashboard puts MQTTfx in as a seperate device.
using MQTT.fx i can only receive and send to topics on the dashboard with the same client id (same device)
can you give me an example to push a button on one device and turn on an led on another device?
without using triggers
I am not a coder but i can make things work by taking working examples and modifying to fit my projects
i am having a hard time finding working examples other than the basic ones that come with the libraries
which are TOO basic. thanks for your help.



it is a while when I was playing with this idea within my own project (check this jIoT - home automatization).

I remember I was able to make it work but now when I tested it I’m not receiving any message in second device, even I’m successfully connected to Cayenne and subscribed to particular topic.

But you’re lucky, you can use already published REST API where you can query ALL sensors coupled with all devices.

I will try to play with MQTT topic in order to be sure I don’t have any mistake over there.



Same problem here. I have an esp8266 connected with cayenne.
I’m trying to use MQTT.fx to read temperature from a ds18b20 (which it is showed in cayenne’s dashboard at channel 1). MQTT.fx connect to the broker but no topic “path combination” seems to work (no messages)


I’m confused what you are trying to do. Are you trying to read the value from the ESP or Cayenne?


Hi, thank you for your reply.
I’m trying to read value from cayenne


@cybermerlo to read value from cayenne follow this steps:
add new > devices/widgets > custom widgets > button > fill all the details with channel 1.

  int currentValue = getValue.asInt();
  if (currentValue == 1)
  //do whatever you want if button is turned on
   //do whatever you want when button is turned off


Thank you very much shramiksalgaonkar for your reply, but my need is a little different.
I will try to explain myself better.

I need to get the value from a different client than the esp8266.
In fact, I need to get the value in a raspberry pi (a magic mirror running which have a module that support mqqt).
To test if this could work I’m trying to access data with a client like Mqttx, just for a test. It succesfully connect to cayenne mqtt broker but it doesn’t show any data…

What am I doing wrong? :slight_smile:


nice. what do you want to do and achieve with it.
you can have a look at this tutorial.


Sorry I’m still not really following what you are trying to do. Can you put it something like this? I need to read a temperature sensor that is connected to a Pi from an ESP8266 using MQTT. If I’m understanding correctly you are trying to connect 2 MQTT clients with the same credentials which is not going to work.


The ESP has the sensor, Raspberry just need to read the sensor value from cayenne.
Same credentials for both clients, different ClientID


As a beginner I am not sure to understand but I can describe my project.
Devices : 3 ESP8266 + DS18B20 in 3 rooms + 1 ESP32 and raspberry pi in test with same credentials and different ClientID for each device.
I made a project in dashboard and dragged an dropped the widgets of each device.
My dashboard is on my Linux PC.
If I missed the point … shame on me :slight_smile:


The Cayenne MQTT server can only handle 1 client per set of credentials at a time. Ex: you will need to create a new Bring Your Own Thing device for every device that connects via MQTT. If you want to read the values strictly between the two devices (ex. you need to have the value stored in memory on the Pi) you’ll have to send that directly between the two devices using whatever method you choose (not Cayenne). If you only need to see the values on the dashboard then you can create a project page and drag in the widgets you want to see.

@rsiegel Do you have any suggestions? It would be nice to have some feature that would allow us to send values device to device.


My understanding is that setting the retain flag on our broker would allow clients to request the values for all widgets, which would in effect allow this to happen. We do have a task for it internally, it will require some investigation and test to make sure it doesn’t have any unintended consequence.


I think this is something I am looking for. I am experimenting with MQTT with Cayenne. Device 1 subscribes to a topic published by Device 2. This would be a good feature of Cayenne if this isn’t implemented yet.


What’s the status of this topic? I was following the guide to simulate a device using MQTT.fx. I successfully had it appear as a new device, I could publish data from it, but it throws an exception anytime I want to subscribe to any topic, be it from the same device or a different one.

So I went ahead and tried it with the Ruby MQTT library. It also connected successfully using the same credentials and client ID. It successfully subscribes to topics published by the same client or another one. However, while it receives the command from a button attached to that same dashboard, it doesn’t receive any data updates from a different device, despite apparently having successfully subscribed to the appropriate topic.

Let me mention here that when I check the configuration of each of my devices, both the username and password displayed by Cayenne are the same across them - and only the device ID is different. So basically, if Cayenne would only allow one simultaneous connection using the same credentials (user/pw), then there would be no way to handle multiple devices by the same user.

In a broader perspective: what are the exact access rules applied to users, and their various devices with regards to the topics they can subscribe to?