MQTT connection status

Hi everyone!


I have some problem with my solution. I have an esp8266 witch communicate with my node-red server. It sends a sensor's value and publish an "ALIVE" text if callback happens(if a msg arrive in a specified topic) . So I want to observe it ,if it's working or not . But in not specified regularity it sends me an "DEAD "sign , when it is plugged . Please watch the code , cause it is hard to explain .Thanks for your help.

[{"id":"9c6b26c1.5aa238","type":"mosca in","z":"e7c02894.549188","mqtt_port":"1884","mqtt_ws_port":"","name":"","username":"","password":"","dburl":"","x":108,"y":32,"wires":[[]]},{"id":"f88767e0.301628","type":"mqtt out","z":"e7c02894.549188","name":"","topic":"topic/stop","qos":"","retain":"","broker":"db15ab6a.2297f8","x":454,"y":211,"wires":[]},{"id":"9c2442b0.a3e14","type":"mqtt in","z":"e7c02894.549188","name":"","topic":"topic/status","qos":"0","datatype":"auto","broker":"db15ab6a.2297f8","x":598,"y":207,"wires":[["7cc2fdbc.4dbc44"]]},{"id":"3d03d032.27fc3","type":"debug","z":"e7c02894.549188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":559,"y":363,"wires":[]},{"id":"7cc2fdbc.4dbc44","type":"switch","z":"e7c02894.549188","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ALIVE","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":718,"y":139,"wires":[["53383026.9f427","37fe4314.d466dc"]]},{"id":"53383026.9f427","type":"trigger","z":"e7c02894.549188","op1":"DEADquest","op2":"DEAD","op1type":"str","op2type":"str","duration":"40","extend":true,"units":"ms","reset":"ALIVE","bytopic":"all","name":"","x":130,"y":200,"wires":[["9e5cc363.add56"]]},{"id":"9e5cc363.add56","type":"switch","z":"e7c02894.549188","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"DEADquest","vt":"str"},{"t":"eq","v":"DEAD","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":280,"wires":[["f88767e0.301628"],["3d03d032.27fc3","991552b7.efc5c"]]},{"id":"5c8d9d24.758444","type":"ui_toast","z":"e7c02894.549188","position":"top right","displayTime":"28","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"","name":"","x":758,"y":329,"wires":[]},{"id":"991552b7.efc5c","type":"change","z":"e7c02894.549188","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"NO MQTT CLIENT DETECTED","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":565,"y":327,"wires":[["5c8d9d24.758444"]]},{"id":"24ed7dc3.c6b3f2","type":"inject","z":"e7c02894.549188","name":"","topic":"","payload":"","payloadType":"date","repeat":"15","crontab":"","once":false,"onceDelay":0.1,"x":111,"y":75,"wires":[["53383026.9f427"]]},{"id":"37fe4314.d466dc","type":"debug","z":"e7c02894.549188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":910,"y":139,"wires":[]},{"id":"db15ab6a.2297f8","type":"mqtt-broker","z":"","name":"Laptopwifi","broker":"192.168.137.1","port":"1884","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

You have the trigger set to 40 milliseconds, so 40 milliseconds after receiving an input it will send DEAD. Is that what you meant?

I dont know that the time beween 2 "DEAD" sign is 40msec or more ... but it shouldn't send any , if my esp is communicating . am i wrong ? image

How often are you expecting messages in? In the flow you posted the trigger is set to 40ms so if there is a gap of 40ms between messages it will send DEAD.

Ok maybe the 40msec is not enough ....

How often are you expecting messages in?

i changed the value to 2sec , and now it works great . I expected the temperature values in 1000msec, and i wanted to check the communication at every pubish at the (topic/stop) from the server side, but i realized that it was to high expecting from the esp side . Thnaks for your help

Glad to be of help.