Node-RED Mqtt and Cayenne


I’ve noticed something strange when using a flow with the standard Mqtt node in Node-RED.
There is a constant changing of connect/not connect status of both screens (Node-Red canvas/Cayenne Dashboard). If the Node RED Mqtt node is connected, the dashboard is offline and if the Node-RED Mqtt node is disconnected the dashboard is online

The node is configured with the Mqttname,Password,ClientID etc for a Cayenne device.

What could that be?

do you have two device with same MQTT client id, then it will cause disconnect frequently as both are trying to connect at same time.

Hi Shramik, I double checked, no devices with the same ID.
If I make the Node-RED tab with the flow inactive (disabled) then the Cayenne communication is stable.
I 've checked this with two different devices and also on 2 different Node-RED installations (1 on pi and the other on a Synology NAS), same effect.
So, I wonder if Node-RED and Cayenne can work together

that means you have two device that are connecting to cayenne with same client id. when you disable the node-red, the second device is stable as there is no other device causing it to disconnect.

it works, and there are many examples on the forum, here is one of the best Using Node-RED as a Local Fallback Server

1 Like

I saw that topic but that’s a different setup I think. (Mqtt broker is on the pi, device is publishing to the broker, and Cayenne subscribes).
In my setup is the broker.


Connect / disconnect happens when I enter the client ID here (which I find in the configuration of the device in Cayenne)

Isn’t this meant the clientID of the device?

okay, so you have a MQTT receive node on node-red named Wemos D1 HC-SR04 with client_id 123456. From where is the node receiving the data from?

from port:1883

but what is the data?

from the distance sensor (type HC-SR04)

so this distance sensor is coming from which device?

The HC-SR04 is connected to a Wemos D1 mini who has WiFi onboard. This device is added to Cayenne (generic ESP8266) and dashboard created as you can see.

what is the client id you have added on yo your wemos D1 ?

Client ID:433edf90-xxxxxxxxx

it’s behind the configuration gear wheel

so isnt this client_id the same as in the node-red???

that’s what i meant here, but you never understood it. I hope now you got that you are using the same client id to connect two devices at the same time which is causing the disconnect.

1 Like

That sounds plausible …:wink:. or actually … you are absolutely right:joy:
But I’m still thinking how to to use that Node-RED Mqtt node in a flow and get measurements in the output node :thinking:

you can use cayenne API to get the data on node-red How to access Cayenne API using Insomnia, Node-red and Thunkable
or create another device on the cayenne dashboard and use the MQTT client_id of this device on node-red. then you can subscribe to the topic of the first device.

Great! Thanks for pointing me to these options :+1:. I ''ll try them out!