mysgw not responding on RS485 data - raspberry pi zero

  • Hi!

    I set up MySensors gateway on RPI Zero. The goal is to have a gateway for RS485 nodes and a HomeAsisstant on the same board.

    I set up the UART like described here:

    ... and tested using Python script and separate TTL<->USB converter to view what is going on on TX/RX pins of RPI and Arduino (Node).

    • (irrelevan for this topic) What is interesting - I have two systems set up (two SD cards) based on the same instruction. First I tried to install MySensors first (plain system) - the right device is /tty/AMA0. Second, I installed HomeAsisstant (Docker) first, then prepared ports and install MySensors - the right device is /ttyS0.

    The installation process for the gateway was as follows:

    sudo apt-get install git
    git clone --branch master
    cd MySensors
    sudo touch /dev/ttyUSB020 && sudo chmod 660 /dev/ttyUSB020 && sudo chown root:dialout /dev/ttyUSB020

    and the configuration as follows:

    sudo ./configure --my-debug=enable --my-config-file=/etc/mysensors.conf --my-transport=rs485 --my-gateway=serial --my-port=/dev/ttyUSB020 --my-serial-baudrate=115200 --my-serial-is-pty --my-rs485-de-pin=7 --my-rs485-serial-port=/dev/ttyAMA0 --my-rs485-baudrate=9600 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18

    After I started the gateway using

    sudo ./bin/mysgw

    It started as follows:

    Sep 21 12:43:27 ERROR Failed to open log pipe.
    Sep 21 12:43:27 INFO  Starting gateway...
    Sep 21 12:43:27 INFO  Protocol version - 2.3.2
    Sep 21 12:43:27 DEBUG MCO:BGN:INIT GW,CP=RSNGL---,FQ=NA,REL=255,VER=2.3.2
    Sep 21 12:43:27 DEBUG TSF:LRT:OK
    Sep 21 12:43:27 DEBUG TSM:INIT
    Sep 21 12:43:27 DEBUG TSF:WUR:MS=0
    Sep 21 12:43:27 DEBUG Serial port /dev/ttyAMA0 (9600 baud) created
    Sep 21 12:43:27 DEBUG TSM:INIT:TSP OK
    Sep 21 12:43:27 DEBUG TSM:INIT:GW MODE
    Sep 21 12:43:27 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
    Sep 21 12:43:27 DEBUG MCO:REG:NOT NEEDED
    0;255;3;0;14;Gateway startup complete.
    Sep 21 12:43:27 DEBUG MCO:BGN:STP
    Sep 21 12:43:27 DEBUG MCO:BGN:INIT OK,TSP=1
    Sep 21 12:43:28 DEBUG TSM:READY:NWD REQ

    Then I turned on the Node and it could not get response from gateway:

    227278 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    229287 TSM:UPL
    229306 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    231314 TSM:UPL
    231332 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    233341 TSM:UPL
    233360 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    235368 !TSM:UPL:FAIL
    235370 TSM:FPAR
    235371 TSM:FPAR:STATP=0
    235373 TSM:ID
    235375 TSM:ID:OK
    235376 TSM:UPL

    ..untill I pressed <Enter>

    Sep 21 12:49:40 DEBUG TSM:READY:NWD REQ
    Sep 21 12:49:40 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    Sep 21 12:49:40 DEBUG TSF:MSG:READ,50-50-0,s=255,c=3,t=24,pt=1,l=1,sg=0:1
    Sep 21 12:49:40 DEBUG TSF:MSG:PINGED,ID=50,HP=1
    Sep 21 12:49:40 DEBUG TSF:MSG:SEND,0-0-50-50,s=255,c=3,t=25,pt=1,l=1,sg=0,ft=0,st=OK:1

    and on the node:

    388210 TSF:MSG:BC
    388353 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
    388360 TSF:MSG:READ,0-0-50,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    388365 TSF:MSG:PONG RECV,HP=1
    388368 TSM:UPL:OK
    388369 TSM:READY:ID=50,PAR=0,DIS=1
    388391 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    390421 TSF:MSG:SEND,50-50-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
    390446 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    392480 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Light Sensor
    392508 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    392531 TSF:MSG:SEND,50-50-0-0,s=0,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=OK:
    392538 MCO:REG:REQ
    392557 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    394582 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    396605 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    398628 TSF:MSG:SEND,50-50-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
    400635 MCO:BGN:INIT OK,TSP=1

    So it seems fine - there is communication etc... The problem is that nothing happens on the gateway side untill I press <Enter>. It does not work "by it self". After I hit the key again (in putty) the program shows all data sent by Node since last press.

    Same problem seems to be when the mysgw is stared as daemon (--daemon or as service) - there is no reaction on Nodes. I waited 45min :(.

    Any idea for that?

  • I have checked with ethernet port instead of serial:

    sudo ./configure --my-debug=enable --my-config-file=/etc/mysensors.conf --my-transport=rs485 --my-gateway=ethernet --my-port=5003 --my-rs485-de-pin=7 --my-rs485-serial-port=/dev/ttyS0 --my-rs485-baudrate=9600 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18

    The results is:

    1. The gateway works with nodes as expected - no need to hit Enter for updates. It works as daemon as well.
      So why it not works on gateway with serial? My suspicious is the port - I was using fake ones (/dev/ttyMySensorsGateway and /dev/ttyUSB020) and the real one /dev/ttyAMA0. Always the same. I tried to listen the (fake) port with "screen" command - nothing was there.

    2. I have another finding/problem. When the gateway starts:

    Sep 21 14:20:57 ERROR Failed to open log pipe.
    Sep 21 14:20:57 INFO  Starting gateway...
    Sep 21 14:20:57 INFO  Protocol version - 2.3.2
    Sep 21 14:20:57 DEBUG MCO:BGN:INIT GW,CP=RSNGL---,FQ=NA,REL=255,VER=2.3.2
    Sep 21 14:20:57 DEBUG TSF:LRT:OK
    Sep 21 14:20:57 DEBUG TSM:INIT
    Sep 21 14:20:57 DEBUG TSF:WUR:MS=0
    Sep 21 14:20:57 DEBUG Serial port /dev/ttyS0 (9600 baud) created
    Sep 21 14:20:57 DEBUG TSM:INIT:TSP OK
    Sep 21 14:20:57 DEBUG TSM:INIT:GW MODE
    Sep 21 14:20:57 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
    Sep 21 14:20:57 DEBUG MCO:REG:NOT NEEDED
    Sep 21 14:20:57 DEBUG Listening for connections on F▒▒:5003
    Sep 21 14:20:57 DEBUG MCO:BGN:STP
    Sep 21 14:20:57 DEBUG MCO:BGN:INIT OK,TSP=1
    Sep 21 14:20:57 DEBUG TSM:READY:NWD REQ
    Sep 21 14:20:57 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    Sep 21 14:21:10 DEBUG TSF:MSG:READ,50-50-0,s=0,c=1,t=23,pt=2,l=2,sg=0:58

    ... you can find that instead of IP address (I was expecting or I get a garbage:

    DEBUG Listening for connections on F▒▒:5003

    After another trial (make clean -> ./configure .... -> make I get similar but with different "garbage":

    DEBUG Listening for connections on ▒ݾ:

    Home Assistant is unable to find the gateway on ports and I tried local network IP (static) - it was "accepted" (no connection error returned), but no Nodes has been found.
    I'm really stubborn to find single board solution for Gateway (RS485 nodes) and Controller but I'm getting tired :(.

  • @Konrad-Winiarski
    I have the same issue with this, Did you ever fins a resolve for this??
    The only diff is that with the newer distro its listed a serial0
    But I also show the ethernet as garbage, Home assistant does connect to the IP specified, so it says.

  • @Jstoaks no, I did not. I gave up. After some research I found better solution:
    Raspberry PI zero + mysgw (485) + Mqtt + Node Red with Dashboard UI. It works great. I use mqtt for both mysensors and wifi devices (esp32/esp8266).
    Node Red handles my home automation very well.

  • Hello @Konrad-Winiarski and best wishes for 2023

    if you have time you can tell us more about the architecture you have chosen.

    the part

    • mysgw (485) : gateway USB?
    • Mqtt : Mosiquitto !
    • Node Red : flow exemple?

    yes examples for a small test installation


Log in to reply

Suggested Topics

  • 3
  • 2
  • 15
  • 2
  • 24
  • 2