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.
  • 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
                        • K kimot

                          @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 Offline
                          R Offline
                          Reza
                          wrote on last edited by
                          #92

                          @kimot how remove resistors from PCB ? :O there is resistor onboard? so for first and end dont need connect external resistor ? in other means i must for example for 10 nodes , any change in node 1 and 10 ! and remove resistor for node 2 - 9 with soldering?
                          i test with some hardware. for 30 meter cable i dont use sheild cable. this is without sheild? may be problem for 30 meter is related to this ! is this true ?
                          i dont change any things in mytransport rs485 just W<3. also sketch is from site
                          im my transport is:
                          _dev.flush();
                          delayMicroseconds((20000000UL/9600)+1);

                          your last experience how many nodes you use ? with how much wire? and how % error for send and receive you have?

                          1 Reply Last reply
                          0
                          • scalzS Offline
                            scalzS Offline
                            scalz
                            Hardware Contributor
                            wrote on last edited by scalz
                            #93

                            @Reza

                            I agree regarding your rs485 network you may need to adjust resistors. But i've not this setup, even if i would like to try it!

                            about removing smd resistor..if you have a solder iron, a simple trick :
                            Let's assume you want to push and remove your resistor to the right..

                            1. Add a blob of solder to the right pad (take a magnifier if you're not confident or smd is too small)
                            2. Heat well this pad. Not like hell, lol, but enough so solder will still be melted, for,
                            3. Then quickly move to the left pad, heat it, and push the resistor to the right for removing it.

                            Be careful with others parts around of course ;)

                            I hope it's clear :)

                            R 1 Reply Last reply
                            1
                            • scalzS scalz

                              @Reza

                              I agree regarding your rs485 network you may need to adjust resistors. But i've not this setup, even if i would like to try it!

                              about removing smd resistor..if you have a solder iron, a simple trick :
                              Let's assume you want to push and remove your resistor to the right..

                              1. Add a blob of solder to the right pad (take a magnifier if you're not confident or smd is too small)
                              2. Heat well this pad. Not like hell, lol, but enough so solder will still be melted, for,
                              3. Then quickly move to the left pad, heat it, and push the resistor to the right for removing it.

                              Be careful with others parts around of course ;)

                              I hope it's clear :)

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

                              @scalz This is an exciting job :)
                              thank you
                              i hope it is clear too :)

                              K 1 Reply Last reply
                              0
                              • R Reza

                                @scalz This is an exciting job :)
                                thank you
                                i hope it is clear too :)

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

                                @Reza
                                I recommend nothing solder or unsolder now.
                                Simply start with two Arduinos on two ends of cable.
                                When your communication will work for these two devices, then you can go further.
                                For one Arduino write simple sketch, which will periodically send something ("Hello World/n" )
                                to the bus. Other Arduino with sketch witch will receive characters and sends then through USB serial port to serial monitor on PC. Only with AltSoftSerial library, not with MySensors.
                                When this communication will work on any length of cable ( I suppose you have not cable longer then 1km at your home ), you can go further.
                                You do not need drive DE and RE pins by software, simply on transmitting Arduino set it for transmit ( to +5V ) and on receiving Arduino to ground.

                                R 1 Reply Last reply
                                1
                                • K kimot

                                  @Reza
                                  I recommend nothing solder or unsolder now.
                                  Simply start with two Arduinos on two ends of cable.
                                  When your communication will work for these two devices, then you can go further.
                                  For one Arduino write simple sketch, which will periodically send something ("Hello World/n" )
                                  to the bus. Other Arduino with sketch witch will receive characters and sends then through USB serial port to serial monitor on PC. Only with AltSoftSerial library, not with MySensors.
                                  When this communication will work on any length of cable ( I suppose you have not cable longer then 1km at your home ), you can go further.
                                  You do not need drive DE and RE pins by software, simply on transmitting Arduino set it for transmit ( to +5V ) and on receiving Arduino to ground.

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

                                  @kimot this hard for me because i am beginner :) but thank you very thank you for help :pray: :pray: :pray:

                                  1 Reply Last reply
                                  0
                                  • ranseyerR Offline
                                    ranseyerR Offline
                                    ranseyer
                                    Hardware Contributor
                                    wrote on last edited by
                                    #97

                                    Hi, i have a Gateway running and the motion-sensor. The Sensors talks with the Gateway. (Arduino Pins: D2,D8,D9)
                                    Now i have to switch to another Hardware. On the Arduino-Pro Mini i have easy access to 0-RX, 1-TX, 2-D5, 3-D5, 4-D7, 10-13, A1-A3)
                                    Which combination of this pins would be the best, and how can i define it in the sketch ?
                                    Im happe for each hint.

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      ArduiSens
                                      wrote on last edited by
                                      #98

                                      The 510 ohm pull up and pull down resistors are usually mounted on the master side. Theoretically it
                                      would be best to install it in the middle of your bus line. The 120 ohm termination resistor must always
                                      be used on distances greater than 1 meter and/or baud rates higher than 9600. It’s best to install it as a
                                      norm as noise and reflections will cause havoc on your communication once implemented in the field.
                                      The termination resistors should be mounted at both ends of the bus line. Please note that adding bias
                                      resistors will load the driver IC output. With the indicated values the max number of units on the bus
                                      line is limited to eight 12kΩ, sixteen 24kΩ, or thirty-two 48kΩ units.
                                      For further protection transient suppressors can be installed across the differential lines, from the Vcc to
                                      D+ and from GND to D-.!
                                      0_1491314128147_upload-f4c63383-2b9a-4f3d-bd48-1e25fcf9dc76

                                      MySensors 2.3.2; contr:Domoticz; layer: RS485, nRF24; gw: Ethernet, Serial

                                      1 Reply Last reply
                                      0
                                      • A Offline
                                        A Offline
                                        ArduiSens
                                        wrote on last edited by
                                        #99

                                        Google for simple Modbus Master dcouments (arduino forum)

                                        The MAX485 is not the best RS485 chip because of it's own internal impedance.
                                        The chip in the diagram can be change by MAX485, MAX...
                                        0_1491314500978_upload-db69c9ce-43b6-430d-8807-74438ad83b96

                                        https://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf

                                        MySensors 2.3.2; contr:Domoticz; layer: RS485, nRF24; gw: Ethernet, Serial

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          ArduiSens
                                          wrote on last edited by
                                          #100

                                          FYI
                                          0_1491315316611_upload-40d28ad1-8ba3-4a11-aa7b-5bd1e84424d2

                                          MySensors 2.3.2; contr:Domoticz; layer: RS485, nRF24; gw: Ethernet, Serial

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


                                          6

                                          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