LAN connected MQTT nodes
-
I try to rebuild my custom Arduino nodes with MySensors platform. Need some input as I can not recreate all functions I need.
I have 3 Arduino/ethernet boxes. By removing radio definitions I can make them act as individual gateways with their own root MQTT topic. In essence, they will have 6 digital inputs and 8 outputs/relays (will see how many pins are free at the end).
-
I selected different MQTT topics for each gateway as they all have NODE_ID 0 (hardcoded by MySensors). How to control/differentiate if all 3 post to the same topic? By sensor ID?
-
There is no support for MQTT Last Will in MySensors from what I searched... that is a pity. I will probably invent phantom sensor as a heartbeat that will contain a random value, then inspect that on a higher level (NodeRED most likely)
-
Is there a way to know the MQTT status from inside the node? For example, if my node/gateway loose Ethernet or the MQTT broker is down I want to set relays to a safe state.
-
Is there a watchdog implemented in the Arduino code by default? I know that Arduino can reset itself if stuck for longer then 8 secs (not getting confirmation message).
-
-
- I found that I can check like this
if (_MQTT_client.connected())
{}
-
For question 1, use MY_MQTT_CLIENT_ID and/or MY_MQTT_PUBLISH_TOPIC_PREFIX.
-
@mfalkvidd Yes I settled for different MY_MQTT_PUBLISH_TOPIC_PREFIX. per device. but the Client_ID can not be defined for gateway...but that is not a problem now
-
@8667 that’s strange. The documentation says
Set client ID for MQTT connections.
This define is mandatory for all MQTT client gateways.
Sonit seems to be for gateways. I have never used it myself though.
-
@mfalkvidd I was talking about MY_NODE_ID As each device will be a gateway with onboard sensors only they all have I think 1 as ID by default and that can not be changed.
MY_MQTT_CLIENT_ID is different as I create different MQTT user/pass for each device
For 2. I created a fake sensor that I update with 1 each minute.
present(99, V_VAR1, "Status");
Then at the software side (NodeRED) I create additional logic to find out if the device is dead.
-
You don’t need MySensors for a direct connection to MQTT. Just use pubsubclient.
-
@carywin Yes I know. I had my own "firmware" for few years but I want to use something mainstream that will be easier to maintain (by someone else
).
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
Radio waking up for no reason.
Development • 4 Jul 2020, 21:09 • Sasquatch 15 Jan 2025, 08:33 -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 15 Jan 2025, 08:51 -
MQTT GW on ESP8266 supporting SSL/TLS?
Development • 4 Jun 2024, 10:21 • bgunnarb 27 Jun 2024, 13:53 -
[mysensors] Not a valid message: invalid literal for int() with base 10: '\x00\x000'
Development • 18 Sept 2024, 20:34 • kiesel 20 Sept 2024, 08:28 -
MYSController with MQTT Gateway (via Node Red)
Development • 11 Aug 2024, 22:35 • slt1 11 Aug 2024, 22:35