Skip to content
  • MySensors
  • 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

💬 Building a wired RS485 sensor network

Scheduled Pinned Locked Moved Announcements
164 Posts 33 Posters 47.2k 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.
  • R Reza

    @wimd we can build a gateway with raspberrypi without arduino . @gohan saying true . but i have to use gpio for serial gateway because when i use a usb serial port after turn on/off or reboot raspberry can not detect my gateway... but with gpio i test and this is true, so i have to use gpio for gateway

    gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #72

    @Reza
    Maybe it is worth a try and get a W5100 network shield and make an ethernet gateway. I have one now and so far I'm happy with it.

    1 Reply Last reply
    1
    • R Offline
      R Offline
      Reza
      wrote on last edited by
      #73

      thank you friends

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Reza
        wrote on last edited by
        #74

        @kimot @gohan do you use a wired network with rs485 ? i have problem with rf24 and i want change my wireless network to a wiring network , but i want know with a rs485 all command are send? without error and NACK ? now for wireless network i have for example every 5 true commands 1 fail command(NACK)

        gohanG 1 Reply Last reply
        0
        • R Reza

          @kimot @gohan do you use a wired network with rs485 ? i have problem with rf24 and i want change my wireless network to a wiring network , but i want know with a rs485 all command are send? without error and NACK ? now for wireless network i have for example every 5 true commands 1 fail command(NACK)

          gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #75

          @Reza
          not yet, but I am getting the parts to make a wired rs485 network of 4 nodes + gateway. About the NACK error it should be handled by the library and retransmit the lost packet.

          R 1 Reply Last reply
          1
          • P Offline
            P Offline
            pjr
            wrote on last edited by
            #76

            Currently there is no "hw" ack functionlity like the radio has.
            You can check out the rs485 transmit code from here.

            But you can of course use the ack functionality between controller software and node to make sure message will get to destination.

            1 Reply Last reply
            1
            • gohanG gohan

              @Reza
              not yet, but I am getting the parts to make a wired rs485 network of 4 nodes + gateway. About the NACK error it should be handled by the library and retransmit the lost packet.

              R Offline
              R Offline
              Reza
              wrote on last edited by
              #77

              @gohan now my sensors lib how many send packet if first is lost ? how more this ?
              i want after send command Turn on light Certainly

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Reza
                wrote on last edited by Reza
                #78

                i am tired for test and trying to configure wiring network with RS485. this is strange :angry:
                i build a gateway and a relay with rs485 . for test i now use 2raspberry pi and 1orangepi and a laptop ! every time disconnect gateway from one and connect to other one ( with out other change for example sketch and wiring and etc. just change controller) some time this is very good work on laptop. some time good work on orange and some time good on raspbrrey pis !! some time same first command has sent(LED on gateway and on node just one blink. some time LEDs 2 blink and turn on later)
                i am using 15cm wire between 2nodes! when change to some meter so dont work never...
                so there is not any one that understand what is reason this issue !!!

                i am ready and i have devices and madules. so any body that think can solve this , told me so i test on my devices and feedback.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pjr
                  wrote on last edited by pjr
                  #79

                  @Reza have you tried to use terminating resistors?

                  And perhaps it could be good to try 1k pull-up and pull-downs at the gateway end. The left diagram:
                  alt text

                  With these two tricks I got my setup stable.

                  And a little tweak to transport class could help also..

                  R 2 Replies Last reply
                  1
                  • P pjr

                    @Reza have you tried to use terminating resistors?

                    And perhaps it could be good to try 1k pull-up and pull-downs at the gateway end. The left diagram:
                    alt text

                    With these two tricks I got my setup stable.

                    And a little tweak to transport class could help also..

                    R Offline
                    R Offline
                    Reza
                    wrote on last edited by
                    #80

                    @pjr
                    i use 120 ohm in terminate before. but now i use 1k for pull-up and down.but this is effectless.
                    please wait until i read this topic (rs485 stress test) and do it and feedback here . thank you

                    1 Reply Last reply
                    0
                    • P pjr

                      @Reza have you tried to use terminating resistors?

                      And perhaps it could be good to try 1k pull-up and pull-downs at the gateway end. The left diagram:
                      alt text

                      With these two tricks I got my setup stable.

                      And a little tweak to transport class could help also..

                      R Offline
                      R Offline
                      Reza
                      wrote on last edited by Reza
                      #81

                      @pjr thank you for help , i read that topic hardly :) because i am weak in english.
                      What I understand , this problem is about collision , command and ack ! and related to transport rs485 and other friends trying to solve this ! is this true ?now , a rs485 network is not complete and Ideal and stable in mysensors.
                      i think all problem is related to collision in short wire and long wire. in many short wire i have not problem(between two nodes). in short wire gateway detect node and connect but many command are failed . in long wire gateway can not detect node and can not connect never.

                      K 1 Reply Last reply
                      0
                      • R Reza

                        @pjr thank you for help , i read that topic hardly :) because i am weak in english.
                        What I understand , this problem is about collision , command and ack ! and related to transport rs485 and other friends trying to solve this ! is this true ?now , a rs485 network is not complete and Ideal and stable in mysensors.
                        i think all problem is related to collision in short wire and long wire. in many short wire i have not problem(between two nodes). in short wire gateway detect node and connect but many command are failed . in long wire gateway can not detect node and can not connect never.

                        K Offline
                        K Offline
                        kimot
                        wrote on last edited by
                        #82

                        @Reza
                        Original RS485 library was written so, that multiple SOH characters is sended on start of package.
                        In Mysensors library it is only one times and it can be problem for synchronization and arbitration.

                        Try in MyTransportRS485.cpp in function "transportSend" change line 274 from

                        for(byte w=0; w<1; w++) {

                        to

                        for(byte w=0; w<3; w++) {

                        R 3 Replies Last reply
                        1
                        • K kimot

                          @Reza
                          Original RS485 library was written so, that multiple SOH characters is sended on start of package.
                          In Mysensors library it is only one times and it can be problem for synchronization and arbitration.

                          Try in MyTransportRS485.cpp in function "transportSend" change line 274 from

                          for(byte w=0; w<1; w++) {

                          to

                          for(byte w=0; w<3; w++) {

                          R Offline
                          R Offline
                          Reza
                          wrote on last edited by
                          #83

                          @kimot said in 💬 Building a wired RS485 sensor network:

                          for(byte w=0; w<1;

                          thank you i will test this and again feedback here

                          1 Reply Last reply
                          0
                          • K kimot

                            @Reza
                            Original RS485 library was written so, that multiple SOH characters is sended on start of package.
                            In Mysensors library it is only one times and it can be problem for synchronization and arbitration.

                            Try in MyTransportRS485.cpp in function "transportSend" change line 274 from

                            for(byte w=0; w<1; w++) {

                            to

                            for(byte w=0; w<3; w++) {

                            R Offline
                            R Offline
                            Reza
                            wrote on last edited by
                            #84

                            @kimot this is good. i am testing . in the first test ((just for 2 node: gateway and one relay)) i see this is work well with 15cm wire. other test with 1meter and 5 meter work well.for 30 meter (CAT6) with 120 ohm resistor (first and end bus) dont work :) without resistor work with 15-20% error ( dont receive or send command and ack)
                            but i think this is good for 2 nodes and short distance and for more nodes and distance increase % errors. is this true ?

                            1 Reply Last reply
                            0
                            • K kimot

                              @Reza
                              Original RS485 library was written so, that multiple SOH characters is sended on start of package.
                              In Mysensors library it is only one times and it can be problem for synchronization and arbitration.

                              Try in MyTransportRS485.cpp in function "transportSend" change line 274 from

                              for(byte w=0; w<1; w++) {

                              to

                              for(byte w=0; w<3; w++) {

                              R Offline
                              R Offline
                              Reza
                              wrote on last edited by
                              #85

                              @kimot also do you have idea for improve wireless transport(nrf24)?
                              because for wireless also i have 50% error for commands.

                              K 1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                pjr
                                wrote on last edited by
                                #86

                                Will the result change if you add more sync(SOH) chars?

                                R 1 Reply Last reply
                                0
                                • P pjr

                                  Will the result change if you add more sync(SOH) chars?

                                  R Offline
                                  R Offline
                                  Reza
                                  wrote on last edited by
                                  #87

                                  @pjr i dont know what is this "for(byte w=0; w<3; w++)" because i am beginner but i see after change this , my network work better. very better. but no perfect

                                  K 1 Reply Last reply
                                  0
                                  • R Reza

                                    @pjr i dont know what is this "for(byte w=0; w<3; w++)" because i am beginner but i see after change this , my network work better. very better. but no perfect

                                    K Offline
                                    K Offline
                                    kimot
                                    wrote on last edited by kimot
                                    #88

                                    @Reza
                                    This code makes, that your node sends three SOH bytes on beginning of message instead of only one SOH.

                                    R 1 Reply Last reply
                                    0
                                    • R Reza

                                      @kimot also do you have idea for improve wireless transport(nrf24)?
                                      because for wireless also i have 50% error for commands.

                                      K Offline
                                      K Offline
                                      kimot
                                      wrote on last edited by
                                      #89

                                      @Reza
                                      Sorry, I do not know.
                                      I am not using radio now (but RS485 too not).
                                      I only look to code and try some RS485 library things,
                                      but only two nodes connected through serial lines.
                                      I am trying understand like MySensors code works to write my own library for CAN bus.

                                      https://forum.mysensors.org/topic/5327/can-bus-transport-implementation-for-mys/17

                                      1 Reply Last reply
                                      0
                                      • K kimot

                                        @Reza
                                        This code makes, that your node sends three SOH bytes on beginning of message instead of only one SOH.

                                        R Offline
                                        R Offline
                                        Reza
                                        wrote on last edited by
                                        #90

                                        @kimot thank you for help :pray:

                                        K 1 Reply Last reply
                                        0
                                        • R Reza

                                          @kimot thank you for help :pray:

                                          K Offline
                                          K Offline
                                          kimot
                                          wrote on last edited by kimot
                                          #91

                                          @Reza
                                          Like someone writes here, your module maybe includes all needed resistors for the bus on PCB.

                                          http://yourduino.com/sunshop//index.php?l=product_detail&p=323

                                          For two nodes it ok and you must not connect any terminating resistors.
                                          For three and more, you must remove this resistors from PCB exclude those nodes, which are on the ends of bus.
                                          Maybe you can divide your "big" problem to several "small" problems.
                                          RS485 is tested bus and MUST work even on long cables.
                                          It must be problem with electricity circuit or software.
                                          Maybe software switchs direction pin to receiving mode early and not all data are send on the bus.
                                          In MyTransportRS485.cpp maybe it is wrong .
                                          It is "hard coded" for crystal 20MHz and bus speed 9600 bd. Try put your values.
                                          //
                                          _dev.flush();
                                          delayMicroseconds((20000000UL/9600)+1);
                                          //

                                          Try examples from AltSoftSerial library with different lengths of cables and do not forgot handle your DE pin.
                                          https://github.com/PaulStoffregen/AltSoftSerial

                                          Or connect your two nodes only through serial wires and check functionality of your code without rs485 converters.

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


                                          9

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 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
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular