Raspberry Pi 3 as Gateway using RS485



  • Hi all,

    Radio is not working between my node and my Raspberry gateway, because they are too far. When I put the node in the same room as the RPI3 it is ok but when i put the node where it should stand, it can not find parent anymore. The configuration was totally OK on RPI3 side and Node side and they can communicate, the only problem is the distance.

    I decided to switch to wired network with rs485 using MAX485 modules like this one because I have wires between them. I followed the guide on the site but it seems it lacks some info for rs485 to work. I read a lot the forum and found a lot of useful info, but node still can not find parent.

    I think my problem is on RPI3 side and the conf of RS485. What i have done :

    1. Wiring on RPI3
    I followed the 1st schema on this thread as Luc3as said he could make it worked after having set the NODE_ID. So :
    0_1496673446610_rpi3.png

    2. Wiring on Arduino Node
    I followed the same schema, so :
    0_1496674998474_arduino2.png

    3. Configuration on RPI3
    I installed everything like on the guide of the site. And configure like this :

    ./configure --my-transport=rs485
    ./configure --my-gateway=ethernet --my-port=5003
    make
    sudo ./bin/mysgw -d
    

    No errors doing that. On RPI3 console after launching gw in debug mode, no error message.

    4. Arduino code
    On arduino codfe side, i specified the node as it seems to help on a rs485 configuration like said
    here and lhere :

    #define MY_NODE_ID 23
    

    5. Result
    On Arduino, parent not found.

    I tried to change the DE pin as it seems to be 2 as default and in the first schema it seems to be 26 :

    ./configure --my-rs485-de-pin=26
    make
    sudo ./bin/mysgw -d
    

    Still no parent found.

    I googled a bit and i specified a serial :

    ./configure --my-rs485-serial-port=serial1
    make
    sudo ./bin/mysgw -d
    

    Still no parent found. I tried serial2 not better. I tried just 1 or 2, same thing. I tried also those values for serial with the DE pin set back to 2, same problem.

    Where am i wrong ? Can you help me ?

    Regards

    Matz


  • Mod

    @matz this might be totally wrong, but I thought all parameters had to be added at the same time to the configure script. Does it help if you run everything in one go, like this?

    ./configure --my-rs485-serial-port=serial1 --my-rs485-de-pin=26 --my-gateway=ethernet --my-port=5003 --my-transport=rs485
    


  • I add that i di not change the baud rate on RPI side so it is 9600 and i specified it correctly on Arduino side :

    //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
    


  • @mfalkvidd it seems you're right, because after doing that, do a new make and launch the gw, i have this error

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RSNG---,VER=2.1.1
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: Unable to open the serial port serial1
    mysgw: Failed to open serial port.
    

    What can i do ?



  • After some search there seem to be a problem on serial on RPI3. I disabled bluetooth and done the recommendation in this link https://raspberrypi.stackexchange.com/questions/45570/how-do-i-make-serial-work-on-the-raspberry-pi3. Rebooted. But same problem even if i change the config to point to serial0 or serial1. Each time i have

    mysgw: Failed to open serial port.
    

    Any idea ?



  • Ok i found the problem : serial must be set with full path : /dev/serial0

    Config is then like this :
    ./configure --my-rs485-serial-port=/dev/serial0 --my-gateway=ethernet --my-port=5003 --my-transport=rs485 --my-rs485-baudrate=9600 --my-rs485-de-pin=26

    I do another "make" to have everything taken into account.

    Also, serial on RPI3 need some attention. I followed instructions here. I have not disabled the bluetooth. I then run

    sudo ./bin/mysgw -d
    

    And i have :

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.1.1
    mysgw: MCO:BGN:INIT GW,CP=RSNG---,VER=2.1.1
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0
    mysgw: TSM:INIT:TSP OK
    mysgw: TSM:INIT:GW MODE
    mysgw: TSM:READY:ID=0,PAR=0,DIS=0
    mysgw: MCO:REG:NOT NEEDED
    mysgw: Listening for connections on 0.0.0.0:5003
    mysgw: MCO:BGN:STP
    mysgw: MCO:BGN:INIT OK,TSP=1
    

    👏

    But my problem is that node can not find parent... I don't understand why. Maybe the GPIO 26 on which i attach the DE ? Should i use anything else ?

    Here is what i have on node side :

    0 MCO:BGN:INIT NODE,CP=RSNNA--,VER=2.1.1
    3 MCO:BGN:BFR
    215 TSM:INIT
    216 TSF:WUR:MS=0
    218 TSM:INIT:TSP OK
    220 TSM:INIT:STATID=23
    222 TSF:SID:OK,ID=23
    223 TSM:FPAR
    241 TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    2248 !TSM:FPAR:NO REPLY
    2250 TSM:FPAR
    2268 TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    4276 !TSM:FPAR:NO REPLY
    4278 TSM:FPAR
    4295 TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    6303 !TSM:FPAR:NO REPLY
    6305 TSM:FPAR
    6323 TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    8331 !TSM:FPAR:FAIL
    8332 TSM:FAIL:CNT=1
    8334 TSM:FAIL:PDT
    18337 TSM:FAIL:RE-INIT
    18339 TSM:INIT
    18340 TSM:INIT:TSP OK
    18342 TSM:INIT:STATID=23
    18344 TSF:SID:OK,ID=23
    18348 TSM:FPAR
    18365 TSF:MSG:SEND,23-23-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    20373 !TSM:FPAR:NO REPLY
    


  • Hello

    I found the problem : the config is waiting for the pin number, it is obvious as it is called my-rs485-de-pin, and not the GPIO number... So GPIO 26 is pin number 37. I put 37 in the config and it is now ok 🙂

    alt text


  • Mod

    Great work @matz ! Thanks for sharing the solution.



  • @mfalkvidd i hope i will help somebody, we must admit that the page on the site is not really detailed on the rs485 transport mode for the raspberry pi gateway 🙂



  • Hi All,

    Following along this thread for RS485, I'm having a difficult time getting any communication to be received from another RS485 Node. I've tried both the Master and Development Branchs on RPI A.
    In Compiling the configuration in either case, I see alot of Compiler Warning during the make process.
    Has there been any more movement regarding this repo since the last dated response in this thread. AS of June 6th 2017 - Like 5 Years AGO???


Log in to reply
 

Suggested Topics

  • 87
  • 7
  • 5
  • 10
  • 2
  • 3

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts