Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Announcements
  3. 💬 Building a wired RS485 sensor network
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

💬 Building a wired RS485 sensor network

Scheduled Pinned Locked Moved Announcements
164 Posts 33 Posters 46.7k Views 35 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • wallyllamaW wallyllama

    @nofox absolutely that is one of the problems. Polling as you describe could be a fix, another is having each node listen before transmitting, there is a (not mysensors) library that does that, CAN bus( a mutli master 485 comaptible bus) is another option. I think that running a common ground to all the rs485 adapters is also wise. This is all in theory as I havent wired up my home yet....

    P Offline
    P Offline
    pjr
    wrote on last edited by
    #121

    @wallyllama

    another is having each node listen before transmitting

    How would you describe this functionality in MySensors rs485 code?
    https://github.com/mysensors/MySensors/blob/f5ed26c778c18107d1516bd86704f8c8f99ff571/hal/transport/RS485/MyTransportRS485.cpp#L246
    If I'm reading the code correctly it is exactly reading the bus and making sure no other node is sending before sending anything.
    The place where collision can happen is those 5 microseconds what the node is waiting to get driver tx enabled pin up.

    So the collision avoidance is already there. So what MyS R485 transport is missing is collision detection and recovery from collision.

    CAN bus( a mutli master 485 comaptible bus) is another option.

    Its disadvantage is small payload size.

    @nofox Its quite like how the Modbus works. By polling.
    I think there is some better ways to do that. Check these out from google:

    • RS-485 Token ring
    • uLAN
    • RS-485 RRP (Round Robin Protocol)
    • CSMA/CA
    1 Reply Last reply
    0
    • wallyllamaW Offline
      wallyllamaW Offline
      wallyllama
      wrote on last edited by
      #122

      I think you have found most everything that I have. Something akin to csmacd is what I was thinking. Listen, transmit, back off for random time if a collision still happens. Of course full duplex rs485 is another option, hard to find off the shelf modules.

      I think this is the library I had found before.
      https://github.com/MichaelJonker/HardwareSerialRS485/wiki

      1 Reply Last reply
      0
      • wallyllamaW Offline
        wallyllamaW Offline
        wallyllama
        wrote on last edited by
        #123

        https://github.com/dukelec/cdbus_doc
        This one has some is interesting, not sure if it does multi master or not. There are a few projects that seem to do multimaster/collision avoidance, the trick it to find one with low enough overhead and automatically retransmits if there is a failure, and for this project isolates this enough that my sensors doesnt need restructuring.

        Good wiring is crucial so you can use higher speeds. The common ground wire in addition to the differential signals seems almost required.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kimot
          wrote on last edited by
          #124

          https://github.com/gioblu/PJON/wiki

          Some works for MySensors done:
          https://forum.mysensors.org/topic/3977/transport-based-on-single-wire-pjon-protocol

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kimot
            wrote on last edited by
            #125

            But PJON uses completely sw bit by bit sending or HW sending with bad bus arbitration.

            My idea - combination CAN bus like arbitration and UART message sending.
            With ACK possibility.

            Time T1 ( two bytes send time for example )

            Node sends message and waits T1 time for ACK.
            Receiving node must send ACK within T1 interval.

            Node, witch needs send message listens bus.
            BUT not by HW UART or SoftwareSerial - use directo IO operation.
            If recognize bus free time greater then T1, it start sending its own ID.
            BUT again not by HW UART or SoftwareSerial - but bit by bit by direct IO pin operation.
            And listen if bit I am sending is bit I am receiving.
            If not - it means, that other node with higher priority ( lower ID ) is sending - then immediately stop sending other bit and wait for next bus free T1 interval.
            If yes - bus is free for me end send my message normally by UART ( HW or SW, maybe with 9 bit addressing support - time less than T1 between characters allowed).
            Wait max T1 time for ACK.

            CAN bus driver usage TJA 1050 or MCP2551 - no DE RE pins.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Andreas Sieber
              wrote on last edited by
              #126

              I have the problem that I always get this error: !TSM:FPAR:NO REPLY

              Once it worked briefly yesterday.

              What have I tried everything?
              All hardware exchanged - without success.

              Now I have just written two small scripts that send RS485 back and forth. without problems. So wiring has to fit. I spent then in the serial montior the data which the node sends me, there comes some. Then I once tried to display the data that sends the GW, because nothing comes.

              Does anyone have an idea why my GW does not answer?

              mfalkviddM 1 Reply Last reply
              0
              • A Andreas Sieber

                I have the problem that I always get this error: !TSM:FPAR:NO REPLY

                Once it worked briefly yesterday.

                What have I tried everything?
                All hardware exchanged - without success.

                Now I have just written two small scripts that send RS485 back and forth. without problems. So wiring has to fit. I spent then in the serial montior the data which the node sends me, there comes some. Then I once tried to display the data that sends the GW, because nothing comes.

                Does anyone have an idea why my GW does not answer?

                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #127

                @andreas-sieber could you post the debug output from the node and the gateway?

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Andreas Sieber
                  wrote on last edited by
                  #128

                  | / |_ / | ___ _ __ ___ ___ _ __ ___
                  | |/| | | | _
                  \ / _ \ _ \/ __|/ _ \|
                  _/ __|
                  | | | | |
                  | || | / | | _ \ _ | | _
                  |
                  | |
                  |_
                  , |/ ___|| ||/_/|| |/
                  |
                  __/ 2.3.0-alpha

                  17 MCO:BGN:INIT NODE,CP=RSNNA---,VER=2.3.0-alpha
                  26 TSM:INIT
                  27 TSF:WUR:MS=0
                  29 TSM:INIT:TSP OK
                  30 TSM:FPAR
                  49 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                  2056 !TSM:FPAR:NO REPLY
                  2058 TSM:FPAR
                  2075 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                  4083 !TSM:FPAR:NO REPLY
                  4085 TSM:FPAR
                  4103 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                  6111 !TSM:FPAR:NO REPLY
                  6113 TSM:FPAR
                  6130 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:

                  0;255;3;0;9;0 MCO:BG
                  0;255;3;0;9;29 MCO:BGN:INIT OK,TSP=1
                  0;255;3;0;9;0 MCO:BGN:INIT GW,CP=RSNGA---,VER=2.3.0-alpha
                  0;255;3;0;9;5 TSM:INIT
                  0;255;3;0;9;7 TSF:WUR:MS=0
                  0;255;3;0;9;9 TSM:INIT:TSP OK
                  0;255;3;0;9;12 TSM:INIT:GW MODE
                  0;255;3;0;9;15 TSM:READY:ID=0,PAR=0,DIS=0
                  0;255;3;0;9;18 MCO:REG:NOT NEEDED
                  0;255;3;0;14;Gateway startup complete.
                  0;255;0;0;18;2.3.0-alpha
                  0;255;3;0;9;22 MCO:BGN:STP
                  0;255;3;0;9;29 MCO:BGN:INIT OK,TSP=1

                  1 Reply Last reply
                  0
                  • gohanG Offline
                    gohanG Offline
                    gohan
                    Mod
                    wrote on last edited by
                    #129

                    why don't you use the stable 2.2? Anyway the node is missing the my_node_id define and second it seems the gateway isn't receiving anything, so I guess there is something very wrong in communication

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Andreas Sieber
                      wrote on last edited by
                      #130

                      in the 2.2 the same problem, i have now updagradet to alpha.

                      When you have a solution on 2.2 i will downgrade. no problem!

                      Guys you are good! I had set the mynodeid. But befor i include the my sensors.. that's the mistake..

                      hour of hour to search... thx!

                      1 Reply Last reply
                      1
                      • O Offline
                        O Offline
                        Omemanti
                        wrote on last edited by
                        #131

                        Is it possible, or will it be possible to build a combination between wired and wireless nodes?

                        1 Reply Last reply
                        0
                        • gohanG Offline
                          gohanG Offline
                          gohan
                          Mod
                          wrote on last edited by
                          #132

                          one network, one gateway

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            Pavel Polititsky
                            wrote on last edited by
                            #133

                            I just trying to work with examples but my node always transmitting some piece of shit from hardware serial:

                             
                             __  __       ____
                            |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
                            | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
                            | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
                            |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
                                    |___/                      2.3.0
                            
                            16 MCO:BGN:INIT NODE,CP=RSNNA---,VER=2.3.0
                            25 TSM:INIT
                            26 TSF:WUR:MS=0
                            28 TSM:INIT:TSP OK
                            29 TSF:SID:OK,ID=5
                            31 TSM:FPAR
                            ⸮X⸮⸮w34 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            2041 !TSM:FPAR:NO REPLY
                            2043 TSM:FPAR
                            ⸮X⸮⸮w2045 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            4054 !TSM:FPAR:NO REPLY
                            4056 TSM:FPAR
                            ⸮X⸮⸮w4058 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            6066 !TSM:FPAR:NO REPLY
                            6068 TSM:FPAR
                            ⸮X⸮⸮w6070 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                            8078 !TSM:FPAR:FAIL
                            8079 TSM:FAIL:CNT=1
                            8081 TSM:FAIL:DIS
                            8083 TSF:TDI:TSL
                            

                            From software serial too

                            ⸮X⸮⸮w
                            ⸮X⸮⸮w
                            ⸮X⸮⸮w
                            ⸮X⸮⸮w
                            

                            Consequently the gateway can't find any device.
                            I have tried also with RS485 with different baudrate. Finally I just connect my USB TTL directly to ouput pins, but always same result.
                            How to fix it?

                            1 Reply Last reply
                            0
                            • rejoe2R Offline
                              rejoe2R Offline
                              rejoe2
                              wrote on last edited by
                              #134

                              @Pavel-Polititsky
                              To me this looks like you mixed between-node communication (RS485) with debug output (and maybe also serial output of the gw).
                              The corresponding serial interface for RS485 should be dedicated to RS485 exclusively.

                              Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                              1 Reply Last reply
                              1
                              • P Offline
                                P Offline
                                PepoV6
                                wrote on last edited by
                                #135

                                Hi,
                                first of I have to thank you for your effort on this project! It helped me a lot.
                                In my house I would like to build 2 networks, one with serial gateway with RF24 for ground floor and outside. Second will be in cellar and I was thinking about Ethernet gateway (W5500) but sensors will be connected via RS485. Do you have code for that? On the video it looks like that in the box on right side it is something like this.

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  GieBek
                                  wrote on last edited by
                                  #136

                                  I have exactly the same problem. Has anyone managed to run it.

                                  mfalkviddM 1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    GieBek
                                    wrote on last edited by
                                    #137

                                    | / |_ / | ___ _ __ ___ ___ _ __ ___
                                    | |/| | | | _
                                    \ / _ \ _ \/ __|/ _ \|
                                    _/ __|
                                    | | | | |
                                    | || | / | | _ \ _ | | _
                                    |
                                    | |
                                    |_
                                    , |/ ___|| ||/_/|| |/
                                    |
                                    __/ 2.3.1

                                    16 MCO:BGN:INIT NODE,CP=RSNNA---,REL=255,VER=2.3.1
                                    26 TSM:INIT
                                    27 TSF:WUR:MS=0
                                    28 TSM:INIT:TSP OK
                                    30 TSM:FPAR
                                    56 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    2063 !TSM:FPAR:NO REPLY
                                    2065 TSM:FPAR
                                    2082 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    4090 !TSM:FPAR:NO REPLY
                                    4092 TSM:FPAR
                                    4110 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    6118 !TSM:FPAR:NO REPLY
                                    6120 TSM:FPAR
                                    6137 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    8146 !TSM:FPAR:FAIL
                                    8147 TSM:FAIL:CNT=1
                                    8150 TSM:FAIL:DIS
                                    8152 TSF:TDI:TSL
                                    18154 TSM:FAIL:RE-INIT
                                    18156 TSM:INIT
                                    18157 TSM:INIT:TSP OK
                                    18159 TSM:FPAR
                                    18178 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    20186 !TSM:FPAR:NO REPLY
                                    20188 TSM:FPAR
                                    20206 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    22213 !TSM:FPAR:NO REPLY
                                    22215 TSM:FPAR
                                    22234 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    24241 !TSM:FPAR:NO REPLY
                                    24243 TSM:FPAR
                                    24261 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
                                    26268 !TSM:FPAR:FAIL
                                    26269 TSM:FAIL:CNT=2
                                    26271 TSM:FAIL:DIS
                                    26273 TSF:TDI:TSL

                                    1 Reply Last reply
                                    0
                                    • G GieBek

                                      I have exactly the same problem. Has anyone managed to run it.

                                      mfalkviddM Offline
                                      mfalkviddM Offline
                                      mfalkvidd
                                      Mod
                                      wrote on last edited by mfalkvidd
                                      #138

                                      @giebek could you describe the problem, what your setup looks like, and what you have tried so far to troubleshoot it? There are 137 posts in this thread so it is a bit hard to figure out which problem you are referring to.

                                      rejoe2R 1 Reply Last reply
                                      0
                                      • mfalkviddM mfalkvidd

                                        @giebek could you describe the problem, what your setup looks like, and what you have tried so far to troubleshoot it? There are 137 posts in this thread so it is a bit hard to figure out which problem you are referring to.

                                        rejoe2R Offline
                                        rejoe2R Offline
                                        rejoe2
                                        wrote on last edited by rejoe2
                                        #139

                                        @GieBek

                                        6137 TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:

                                        Imo this indicates your node doesn't have a NodeID yet. When using RS485 you have to assign the ID's manually in the sketch, auto doesn't work... (e.g. #define MY_NODE_ID 123)

                                        Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                                        1 Reply Last reply
                                        1
                                        • G Offline
                                          G Offline
                                          GieBek
                                          wrote on last edited by
                                          #140

                                          Thanks for the answers.
                                          And even more thanks to the rejoe2

                                          #define MY_NODE_ID 123

                                          it helped 100% the transmission went, domoticz sees children.

                                          1 Reply Last reply
                                          1
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          4

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular