MQTT Ethernet Gateway with Wired RS485 Network



  • Hi everyone.

    Somehow I miss real examples, such as coding examples for wired RS485 Sensor Networks.
    Maybe the wireless option is more famous because not everyone has the opportunity to wire up with all sensors.

    However I tried now to make an example code, with btw. doesn't work so far, but maybe you can help me and use this example for a later more detailed introduction into this approach?

    OK, I use Home Assistent (hassos 3.11 on Raspberry Pi 4) as Controller and tried now to get MQTT working. So far so good, the MQTT Example including the Ethernet Shield works now and made me happy 🙂

    Now I tried with the MAX485 Module to make a connection to a separate Sensor Node where I just used the MotionSensor Example for RS485 see here MotionSensorRS485

    Since I wasn't sure about how to wire up with RS485 I found with google the following example: https://maker.pro/arduino/tutorial/creating-long-distance-serial-communication-using-an-arduino-and-an-rs-485-module

    I'm using now an Arduino Uno as MQTT-Ethernet Gateway and an Arduino Nano as MotionSensor Node. Here a picture of my wiring:
    example-rs485-mqtt.png

    First of all, is that correct ??

    Second my code for the gateway:

    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enables and select radio type (if attached)
    //#define MY_RADIO_RF24
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    #define MY_GATEWAY_MQTT_CLIENT
    
    // Set this node's subscribe and publish topic prefix
    #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
    #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
    
    // Set MQTT client id
    #define MY_MQTT_CLIENT_ID "mysensors-1"
    
    // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
    //#define MY_W5100_SPI_EN 4
    
    // Enable Soft SPI for NRF radio (note different radio wiring is required)
    // The W5100 ethernet module seems to have a hard time co-operate with
    // radio on the same spi bus.
    #if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
    #define MY_SOFTSPI
    #define MY_SOFT_SPI_SCK_PIN 14
    #define MY_SOFT_SPI_MISO_PIN 16
    #define MY_SOFT_SPI_MOSI_PIN 15
    #endif
    
    // When W5100 is connected we have to move CE/CSN pins for NRF radio
    #ifndef MY_RF24_CE_PIN
    #define MY_RF24_CE_PIN 5
    #endif
    #ifndef MY_RF24_CS_PIN
    #define MY_RF24_CS_PIN 6
    #endif
    
    // Enable these if your MQTT broker requires username/password
    #define MY_MQTT_USER "mqtt_user"
    #define MY_MQTT_PASSWORD "mqtt_passwd"
    
    // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
    //#define MY_IP_ADDRESS 192,168,178,87
    
    // If using static ip you can define Gateway and Subnet address as well
    //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
    //#define MY_IP_SUBNET_ADDRESS 255,255,255,0
    
    // MQTT broker ip address or url. Define one or the other.
    //#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
    #define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 164
    
    // The MQTT broker port to to open
    #define MY_PORT 1883
    
    /*
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Flash leds on rx/tx/err
    // Uncomment to override default HW configurations
    //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
    //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
    //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
    */
    
    // Enable RS485 transport layer
    #define MY_RS485
    
    // Define this to enables DE-pin management on defined pin
    #define MY_RS485_DE_PIN 2
    
    // Set RS485 baud rate to use
    #define MY_RS485_BAUD_RATE 9600
    
    // Enable inclusion mode
    #define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    #define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    #define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    #define MY_INCLUSION_MODE_BUTTON_PIN  3
    
    #include <Ethernet.h>
    #include <MySensors.h>
    
    void setup()
    {
    	// Setup locally attached sensors
    }
    
    void presentation()
    {
    	// Present locally attached sensors here
    }
    
    void loop()
    {
    	// Send locally attached sensors data here
    }
    

    My Configuration.yml includes the MQTT Option:

    # Example configuration.yaml entry
    mysensors:
      gateways:
        - device: mqtt
          persistence_file: 'mysensors/mysensors_mqtt.json'
          topic_in_prefix: 'mygateway1-out'
          topic_out_prefix: 'mygateway1-in'
      persistence: true
      version: '2.3.2'
    

    So now I don't know how to get the sensor node up and running.
    Is there something wrong in the wiring?
    I have the option for the inclusion button? What is there to do, or what else can I do?
    I tried on D3 pin to pull down to simulate the inclusion button pressed. But I didn't get any reaction.

    So maybe someone is here more experienced with that topic?


  • Mod

    I don't have any experience with RS485, but the guide at https://www.mysensors.org/build/rs485 should contain everything you need about wiring.

    The MySensors build examples are not specific to wireless transports. They work regardless of transport.



  • @mfalkvidd Thank you for your reply

    Well I've read that guide. But anyway this doesn't answer my questions.
    What is necessary to do, that the 2nd sensor node shows up?
    Do you know how the MY_INCLUSION_MODE_BUTTON_PIN works?



  • You don't need inclusion mode for Home Assistant. I don't know if it is even supported. Once you power up your sensor node while HA is running, HA should detect it automatically during the presentation(), however HA will not show any sensor data until you send at least one value. Your persistance file mysensors_mqtt.json should tell you what HA knows about your sensors.

    I may have overlooked it, but I don't know what exactly is your issue here. Does your node send no data at all? Does the gateway receive data from it, but not the gateway? Does your controller receive data but doesn't display anything? Does any of the serial outputs on the node and gateway or the HA log give you hints at what might be wrong?

    How does your sensor node sketch look like? Do you send an initial value for your PIR sensor in the loop()?

    By the way - you should change version: '2.3.2' in your HA configuration to version: '2.3' because the prior is invalid and can cause (different) problems in the future.



  • @BearWithBeard Thanks for your reply

    Well the sensor doesn't show up.
    And I don't know if my wiring is correct, maybe you could review that, because I don't know, but I think this should be right.

    The motion sensor sketch is used as presented here: https://www.mysensors.org/build/rs485
    So the code looks like this:

    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    // Enable RS485 transport layer
    #define MY_RS485
    
    // Define this to enables DE-pin management on defined pin
    #define MY_RS485_DE_PIN 2
    
    // Set RS485 baud rate to use
    #define MY_RS485_BAUD_RATE 9600
    
    // Enable this if RS485 is connected to a hardware serial port
    //#define MY_RS485_HWSERIAL Serial1
    
    #include <MySensors.h>
    
    uint32_t SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define CHILD_ID 1   // Id of the sensor child
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    void setup()
    {
        pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    }
    
    void presentation()
    {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Motion Sensor", "1.0");
    
        // Register all sensors to gw (they will be created as child devices)
        present(CHILD_ID, S_MOTION);
    }
    
    void loop()
    {
        // Read digital motion value
        bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
        Serial.println(tripped);
        send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
    
        // Sleep until interrupt comes in on motion sensor. Send update every two minute.
        sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
    }
    

    I will change to configuration.yml as you've suggested to version: '2.3'. But I haven't recognized any issues so far with that.



  • I haven't worked with RS485 neither but your wiring looks good as far as I can tell.

    I asked you to look at the serial output. If your gateway receives data (presentation and triggering of the PIR sensor), your network is wired properly and the issue is somewhere else.

    In this case, an excerpt of your HA log would be helpful. Maybe you don't have write permissions for your persistance file. Does it even exist? Could it be that the node and sensor ID is already present from earlier projects, but the sensor type is different from the current one?

    I will change to configuration.yml as you've suggested to version: '2.3'. But I haven't recognized any issues so far with that.

    This is because the MySensors integration converts this version string you specify in the configuration into a float value. A string which contains more than one dot fails this conversion, which causes the pymysensors module to fall back to the 1.4 version of the serial protocol, which doesn't support some of the newer sensor types and features of later MySensors versions.



  • @BearWithBeard alright, I've changed the config version to 2.3 now and restarted HASS

    I also change the gateway code and removed the following lines:

    
    // Enable inclusion mode
    //#define MY_INCLUSION_MODE_FEATURE
    // Enable Inclusion mode button on gateway
    //#define MY_INCLUSION_BUTTON_FEATURE
    // Set inclusion mode duration (in seconds)
    //#define MY_INCLUSION_MODE_DURATION 60
    // Digital pin used for inclusion mode button
    //#define MY_INCLUSION_MODE_BUTTON_PIN  3
    

    I deployt the gateway node and this is the output of the Serial Monitor there:

    ⸮⸮Q8V⸮⸮⸮⸮0 MCO:BGN:INIT GW,CP=RSNGA---,FQ=16,REL=255,VER=2.3.2
    19:58:49.479 -> 4 TSM:INIT
    19:58:49.479 -> 5 TSF:WUR:MS=0
    19:58:49.479 -> 7 TSM:INIT:TSP OK
    19:58:49.479 -> 8 TSM:INIT:GW MODE
    19:58:49.479 -> 10 TSM:READY:ID=0,PAR=0,DIS=0
    19:58:49.516 -> 12 MCO:REG:NOT NEEDED
    10183 GWT:TPC:IP=192.168.0.220
    11186 MCO:BGN:STP
    19:59:00.662 -> 11188 MCO:BGN:INIT OK,TSP=1
    15335 GWT:TPC:IP=192.168.0.220
    16338 GWT:RMQ:CONNECTING...
    16996 GWT:RMQ:OK
    19:59:06.476 -> 16998 GWT:TPS:TOPIC=mygateway1-out/0/255/0/0/18,MSG SENT
    19:59:06.476 -> 17004 TSM:READY:NWD REQ
    19:59:06.512 -> 17024 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    

    btw. yes my mysensors_mqtt.json (persistent file) exists but only looks like this:

    {}
    

    And had no other sensors in this wired network with that id or child_id as far as I know.

    Now I've redeployt the sensor node and output on Serial Monitor is:

    ⸮⸮⸮z⸮⸮⸮⸮⸮Y⸮⸮⸮A⸮h⸮l⸮,ht⸮⸮⸮⸮⸮Q 
    20:14:41.610 ->  __  __       ____
    20:14:41.610 -> |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
    20:14:41.610 -> | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
    20:14:41.610 -> | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
    20:14:41.610 -> |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
    20:14:41.610 ->         |___/                      2.3.2
    20:14:41.610 -> 
    20:14:41.610 -> 16 MCO:BGN:INIT NODE,CP=RSNNA---,FQ=16,REL=255,VER=2.3.2
    20:14:41.645 -> 26 TSM:INIT
    20:14:41.645 -> 28 TSF:WUR:MS=0
    20:14:41.645 -> 29 TSM:INIT:TSP OK
    20:14:41.645 -> 31 TSM:FPAR
    20:14:41.645 -> 49 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2057 !TSM:FPAR:NO REPLY
    20:14:43.660 -> 2059 TSM:FPAR
    20:14:43.696 -> 2076 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4084 !TSM:FPAR:NO REPLY
    20:14:45.674 -> 4086 TSM:FPAR
    20:14:45.710 -> 4104 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6112 !TSM:FPAR:NO REPLY
    20:14:47.714 -> 6114 TSM:FPAR
    20:14:47.749 -> 6131 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8139 !TSM:FPAR:FAIL
    20:14:49.763 -> 8140 TSM:FAIL:CNT=1
    20:14:49.763 -> 8142 TSM:FAIL:DIS
    20:14:49.763 -> 8144 TSF:TDI:TSL
    18146 TSM:FAIL:RE-INIT
    20:14:59.754 -> 18148 TSM:INIT
    20:14:59.754 -> 18149 TSM:INIT:TSP OK
    20:14:59.754 -> 18151 TSM:FPAR
    20:14:59.790 -> 18169 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20178 !TSM:FPAR:NO REPLY
    20:15:01.773 -> 20180 TSM:FPAR
    20:15:01.809 -> 20199 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    22206 !TSM:FPAR:NO REPLY
    20:15:03.800 -> 22208 TSM:FPAR
    20:15:03.837 -> 22226 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    24235 !TSM:FPAR:NO REPLY
    20:15:05.829 -> 24237 TSM:FPAR
    20:15:05.867 -> 24255 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    26262 !TSM:FPAR:FAIL
    20:15:07.855 -> 26263 TSM:FAIL:CNT=2
    20:15:07.855 -> 26265 TSM:FAIL:DIS
    20:15:07.855 -> 26267 TSF:TDI:TSL
    36270 TSM:FAIL:RE-INIT
    20:15:17.879 -> 36272 TSM:INIT
    20:15:17.879 -> 36273 TSM:INIT:TSP OK
    20:15:17.879 -> 36275 TSM:FPAR
    20:15:17.913 -> 36293 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    38301 !TSM:FPAR:NO REPLY
    20:15:19.905 -> 38303 TSM:FPAR
    20:15:19.943 -> 38322 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    40329 !TSM:FPAR:NO REPLY
    20:15:21.944 -> 40331 TSM:FPAR
    20:15:21.944 -> 40349 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    42356 !TSM:FPAR:NO REPLY
    20:15:23.961 -> 42358 TSM:FPAR
    20:15:23.997 -> 42377 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    44384 !TSM:FPAR:FAIL
    20:15:25.987 -> 44385 TSM:FAIL:CNT=3
    20:15:25.987 -> 44387 TSM:FAIL:DIS
    20:15:25.987 -> 44389 TSF:TDI:TSL
    54392 TSM:FAIL:RE-INIT
    20:15:35.987 -> 54394 TSM:INIT
    20:15:35.987 -> 54395 TSM:INIT:TSP OK
    20:15:35.987 -> 54397 TSM:FPAR
    20:15:36.023 -> 54416 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    56424 !TSM:FPAR:NO REPLY
    20:15:38.017 -> 56426 TSM:FPAR
    20:15:38.055 -> 56444 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    58452 !TSM:FPAR:NO REPLY
    20:15:40.051 -> 58455 TSM:FPAR
    20:15:40.088 -> 58473 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    60480 !TSM:FPAR:NO REPLY
    20:15:42.099 -> 60482 TSM:FPAR
    20:15:42.099 -> 60500 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    62508 !TSM:FPAR:FAIL
    20:15:44.117 -> 62509 TSM:FAIL:CNT=4
    20:15:44.117 -> 62511 TSM:FAIL:DIS
    20:15:44.117 -> 62513 TSF:TDI:TSL
    72516 TSM:FAIL:RE-INIT
    20:15:54.121 -> 72518 TSM:INIT
    20:15:54.121 -> 72519 TSM:INIT:TSP OK
    20:15:54.121 -> 72521 TSM:FPAR
    20:15:54.157 -> 72540 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    74548 !TSM:FPAR:NO REPLY
    20:15:56.174 -> 74550 TSM:FPAR
    20:15:56.174 -> 74568 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    76575 !TSM:FPAR:NO REPLY
    20:15:58.190 -> 76577 TSM:FPAR
    20:15:58.190 -> 76596 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    78603 !TSM:FPAR:NO REPLY
    20:16:00.193 -> 78605 TSM:FPAR
    20:16:00.226 -> 78623 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    80630 !TSM:FPAR:FAIL
    20:16:02.238 -> 80631 TSM:FAIL:CNT=5
    20:16:02.238 -> 80633 TSM:FAIL:DIS
    20:16:02.238 -> 80635 TSF:TDI:TSL
    90638 TSM:FAIL:RE-INIT
    20:16:12.234 -> 90640 TSM:INIT
    20:16:12.234 -> 90641 TSM:INIT:TSP OK
    20:16:12.234 -> 90643 TSM:FPAR
    20:16:12.270 -> 90661 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    92670 !TSM:FPAR:NO REPLY
    20:16:14.274 -> 92673 TSM:FPAR
    20:16:14.312 -> 92691 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    94698 !TSM:FPAR:NO REPLY
    20:16:16.302 -> 94700 TSM:FPAR
    20:16:16.340 -> 94718 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    96726 !TSM:FPAR:NO REPLY
    20:16:18.335 -> 96728 TSM:FPAR
    20:16:18.371 -> 96746 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    98753 !TSM:FPAR:FAIL
    20:16:20.373 -> 98754 TSM:FAIL:CNT=6
    20:16:20.373 -> 98756 TSM:FAIL:DIS
    20:16:20.373 -> 98758 TSF:TDI:TSL
    108761 TSM:FAIL:RE-INIT
    20:16:30.382 -> 108763 TSM:INIT
    20:16:30.382 -> 108764 TSM:INIT:TSP OK
    20:16:30.382 -> 108766 TSM:FPAR
    20:16:30.382 -> 108784 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    110792 !TSM:FPAR:NO REPLY
    20:16:32.394 -> 110794 TSM:FPAR
    20:16:32.431 -> 110813 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    112821 !TSM:FPAR:NO REPLY
    20:16:34.425 -> 112823 TSM:FPAR
    20:16:34.463 -> 112841 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    114849 !TSM:FPAR:NO REPLY
    20:16:36.443 -> 114851 TSM:FPAR
    20:16:36.477 -> 114870 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    116878 !TSM:FPAR:FAIL
    20:16:38.485 -> 116880 TSM:FAIL:CNT=7
    20:16:38.485 -> 116882 TSM:FAIL:DIS
    116884 TSF:TDI:TSL
    176886 TSM:FAIL:RE-INIT
    20:17:38.493 -> 176888 TSM:INIT
    20:17:38.493 -> 176889 TSM:INIT:TSP OK
    20:17:38.493 -> 176891 TSM:FPAR
    20:17:38.529 -> 176910 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    178918 !TSM:FPAR:NO REPLY
    20:17:40.521 -> 178920 TSM:FPAR
    20:17:40.558 -> 178938 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    180947 !TSM:FPAR:NO REPLY
    20:17:42.544 -> 180950 TSM:FPAR
    20:17:42.579 -> 180968 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    182976 !TSM:FPAR:NO REPLY
    20:17:44.599 -> 182978 TSM:FPAR
    20:17:44.599 -> 182996 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    185005 !TSM:FPAR:FAIL
    20:17:46.606 -> 185007 TSM:FAIL:CNT=7
    20:17:46.606 -> 185009 TSM:FAIL:DIS
    185011 TSF:TDI:TSL
    

    I don't see something in the HA logs which has to do with mqtt gateway.



  • @ATha1 Okay, thank you for the logs. There were people with similar issues recently, who weren't able to get their sensor values to show up on HA. At least one of them "fixed" it by switching from an ethernet to a serial gateway, so I quickly setup a new MySensors network with an EthernetMQTT gateway (Arduino Uno + W5500), but using NRF24 radios instead to see if there is a fundamental issue regarding ethernet gateways in combination with HA.

    With only the gateway connected, my newly created persistance file contains an object of my gateway right away:

    {
        "0": {
            "sensor_id": 0,
            "children": {},
            "type": 18,
            "sketch_name": null,
            "sketch_version": null,
            "battery_level": 0,
            "protocol_version": "2.3.2",
            "heartbeat": 0
        }
    }
    

    If yours is empty, I suspect that the link between gateway and controller is incorrect. This might be a stupid question, but did you confirm that your gateway is publishing successfully to the topic HA is subscribed to? If you manually subscribe to mygateway1-out/0/255/0/0/18, you should see a 2.3.2 payload after powering up the gateway, according to its serial output. And is MQTT setup correctly in configurations.yml?

    After I confirmed that my gateway does connect to the controller, I added a sensor node to the network, which found its parent right away, received a dynamically assigned ID from HA, got added to the persistance file and started reporting messages as expected. Atleast we now know there is no fundamental issue with the ethernet gateway and HA.

    If your MQTT setup is working fine, I don't know what causes your problem. You could try using static routing between your sensor node and gateway, see if a serial gateway works, double-check your wiring or if replacing RS485 with any other transport method gets you further. I'm out of ideas at this point, sorry.



  • @ATha1 What tool do you use to draw a diagram ?



  • @Michal
    I’ve downloaded an older version of fritzing.
    I think this is a beta version btw.
    I’ve just googled fritzing download.



  • Back then when I built my RS485 network with normal ethernet GW and domoticz I had to define static node id's for all the nodes(except GW) to get RS485 network working. Not sure if thats the case anymore.

    #define MY_NODE_ID 123
    


  • @pjr said in MQTT Ethernet Gateway with Wired RS485 Network:

    #define MY_NODE_ID 123

    wow awesome!
    I've just tried and it seems to recognize the other wired node ☺

    Now I did some soldering, so that the wiring is easier and moved to a serial gateway.
    Later I will try again to use the MQTT with Ethernet Gateway



  • Hey @ATha1, I'm sorry for reviving this old topic but I'm currently struggling with getting RS485 and RF24 to work together. I can't find any other threads mentioning this so I'm really wondering if you did manage to make them work together and how.


Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 5
  • 3
  • 3

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts