Hi,
I have an esp8266-12F with dht22 sensor and I have node red installed on a rapberry pi 4.
I am trying to connect the esp to node red by using domoticz mqtt.
It always disconnected!
Could you please verify if I am on the right way.
Thank you.
Hi,
I have an esp8266-12F with dht22 sensor and I have node red installed on a rapberry pi 4.
I am trying to connect the esp to node red by using domoticz mqtt.
It always disconnected!
Could you please verify if I am on the right way.
Thank you.
I dont know that device but i suspect it is NOT a broker.
for MQTT clients to communicate, you need an actual MQTT broker to sit between clients.
See this post for a very quick intro
The salient detail from that post is you can set up an MQTT broker simply by installing mosquito or adding node-red-contrib-aedes to node-red.
I installed mosquitto on the raspberry
And is it working/running?
Try setting the server address on node-red to localhost.
Try the mosquito command line tools.
Check the service is running.
Ps it looks like you're attempting to connect to a broker on the esp. I doubt very much you're running a broker on that.
Am I right in thinking node-red and broker are on the same machine (the pi)?
Yes they are on the same pi
So having followed the advise is it now working?
I'm not familiar with Domoticz, but I have used OpenHAB (MQTT) running on a number of Wemos D1 Mini devices (ESP8266) flashed with ESP Easy.
I've quickly built a breadboard with these temperature sensors... DHT11, DS18B20 and a BME280.
I give all my Wemos devices a unique node number that directly relates to its fixed IP address.
Here are some screen-shots showing my set-up talking to Node-RED and Mosquitto running on a RPi-4B.
Note:
The MQTT broker is running on the Pi.
The Wemos device will simply 'publish' readings to the broker.
Hope this helps.
Thank you.
Honestly I am beginner on nod-red (mqtt part) so I don't know how to use it.
On the raspberry I installed mosquitto but I don't find how to install openhab and what should I do to connect node red to openhab.
If you only want the ESPEasy device to connect to Node-RED via MQTT you don't need Domoticz or openHAB. ESPEasy doesn't have a setting for "plain MQTT" so you need to use the openHAB template to connect to your MQTT broker. Then ESPEasy should connect to MQTT and you will be able to subscribe to the relevant topics on Node-RED. So just ignore that it says openHAB.
I agree with what @ristomatti said...
I installed Mosquitto on Node-RED and it ran 'straight-out-of-the-box'.
In the above example my Wemos will publish to a topic called... node92/dht11/temperature
So all you need to do in Node-RED is use one of the core nodes MQTT-In with a subscribe topic of... node92/dht11/#
Hope this helps.
I can post some sample NR flows if you get stuck.
When you have your set-up working, you could try using 'rules' within the Wemos.
Enter this in Rules Set 1
On interrogate Do
Publish,temperature/reading,'{"node_number":"%sysname%","temp":[bme280#temperature]}'
EndOn
Then create this NR-flow...
This is what's in the 'function' node.
The advantage of the above is you can publish a 'json' string (with a number of name/value pairs) from the Wemos and then select which value you want with a simple function node or change node in Node-RED.
To keep things simple, I've just used MQTT-In that subscribes to everything.
So what happens with the above is... you can send an event from Node-RED to the Wemos (via MQTT).
Rules Set 1 is listening for the event and when it receives it, it will publish the json string to Node-RED.
This is just a very simple set-up that allows you to interrogate the Wemos from Node-RED.
Have fun.