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.1k 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.
  • wimdW wimd

    @MICK HI, please check this topic : https://forum.mysensors.org/topic/5495/rs485-on-nano

    mickM Offline
    mickM Offline
    mick
    wrote on last edited by
    #21

    @wimd Thanks mate! That topic was just what I was looking for. Works perfectly with defining a node ID!

    Just added this to my sensor node:

    #define MY_NODE_ID <X>
    

    and everything came together. Thank you for your quick reply.

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

      Yes. It is very bad for beginners, that examples in MySensors library are wrong.
      Example "MotionSensorRS485" will never work and I think, that author not tested it.
      MY_NODE_ID must be always defined for node in RS485 network, because is used for RS485 network addressing.
      Obtaining NODE_ID from controller with currentRS485 network implementation is impossible and I think it should be clearly mentioned in the examples and documentation.

      1 Reply Last reply
      1
      • hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #23

        Would be better if someone with a RS485 setup could analyse and fix the root cause of why automatic id assignment doesn't work than just change the example to use static ids.

        Did the id request reach your controller or gateway? Did the id response get to your gateway?

        K 1 Reply Last reply
        1
        • hekH hek

          Would be better if someone with a RS485 setup could analyse and fix the root cause of why automatic id assignment doesn't work than just change the example to use static ids.

          Did the id request reach your controller or gateway? Did the id response get to your gateway?

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

          @hek
          I think it is simply. In radio network, each node has its unique "radio ID" , witch is used for delivering messages between nodes in radio network. So node can send message " Give me NODE_ID" and gateway or controller knows to witch radio ID send message with assigned NODE_ID in it.
          But in RS485 network we had not unique network ID by default - we use directly NODE_ID for addressing messages between nodes.

          1 Reply Last reply
          0
          • hekH Offline
            hekH Offline
            hek
            Admin
            wrote on last edited by
            #25

            No, it follow exactly the same flow as in a radio network. The gateway (and nodes) should listen to "channel" 255 which is used for broadcast messages (picked up by anyone interested; I.e. repeaters and nodes waiting for new id).

            When a id request is sent out from a node, the gateway will forward it to the controller.. the controller sends out the new id on 255 (which is forwarded by the gateway) and (hopefully) picked up by the new node.

            So somewhere in stil flow the message is not sent along for some reason. Which controller do you use @kimot?

            K 1 Reply Last reply
            0
            • hekH hek

              No, it follow exactly the same flow as in a radio network. The gateway (and nodes) should listen to "channel" 255 which is used for broadcast messages (picked up by anyone interested; I.e. repeaters and nodes waiting for new id).

              When a id request is sent out from a node, the gateway will forward it to the controller.. the controller sends out the new id on 255 (which is forwarded by the gateway) and (hopefully) picked up by the new node.

              So somewhere in stil flow the message is not sent along for some reason. Which controller do you use @kimot?

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

              @hek
              I am using Domoticz, but not using RS485, instead I am working on CAN protocol layer for MySensors or using only MySensors serial gateway protocol in my CAN-to-Domoticz gateway. For that reason I am studying source code of MYSensors a lot of. Its only useful documentation source, unfortunately.
              Imagine, if you "switch on" entire your network with 10 nodes. Each node send request for NODE_ID to the gateway and gateway send broadcast with assigned NODE_ID. How RS485 nodes recognizes, that this NODE_ID is exactly for specific node?
              Why in radio network is something like MY_RF24_NODE_ADDRESS?
              ( five bytes long, 4 are constant, fifth is radio ID )
              I seems, that entire this "MySensors network DHCP" stuff is made in different level then MyTransportXXXXX.cpp level. Maybe radio drivers ?
              If you know, how it works, pleas write here or send link, please.
              I can imagine only mechanism, when only one new node is connected at time, or some random generated number in each node or unique serial number etc. Then gateway can send NODE_ID with this "mark" end receiving node knows, that this is for it.

              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by hek
                #27

                @kimot said:

                Imagine, if you "switch on" entire your network with 10 nodes. Each node send request for NODE_ID to the gateway and gateway send broadcast with assigned NODE_ID. How RS485 nodes recognizes, that this NODE_ID is exactly for specific node?

                This will not work (and the same applies for a radio network). All nodes will then pick the broadcasted id.

                This is known limitation and has its technical background in how the radios work and that the new have problem generating a good unique random number when it starts blank.

                I know we had some ideas of adding a payload (random number) on the id-request payload identifying the requesting node. The node then also check that this number is the same in the id-response. But would break backward compatibility with the serial protocol so it would only happen in a bigger (3.0?) release.

                Edit: Added issue so we won't forget it.
                https://github.com/mysensors/MySensors/issues/732

                K 1 Reply Last reply
                0
                • hekH hek

                  @kimot said:

                  Imagine, if you "switch on" entire your network with 10 nodes. Each node send request for NODE_ID to the gateway and gateway send broadcast with assigned NODE_ID. How RS485 nodes recognizes, that this NODE_ID is exactly for specific node?

                  This will not work (and the same applies for a radio network). All nodes will then pick the broadcasted id.

                  This is known limitation and has its technical background in how the radios work and that the new have problem generating a good unique random number when it starts blank.

                  I know we had some ideas of adding a payload (random number) on the id-request payload identifying the requesting node. The node then also check that this number is the same in the id-response. But would break backward compatibility with the serial protocol so it would only happen in a bigger (3.0?) release.

                  Edit: Added issue so we won't forget it.
                  https://github.com/mysensors/MySensors/issues/732

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

                  @hek
                  Thanks for your explanation.
                  Last question for you. I cannot find information about internal message strukture.
                  Only this discussion:
                  https://forum.mysensors.org/topic/305/mysensors-protocol-format
                  or
                  "hacking" libraries

                  Witch version is actual?

                  I need myself write translation between my network message format and MySensors message format to use
                  something like MyTransportRS485.cpp. But I have limited number of bytes for payload, so I need modify and test "data" array too.
                  Thanks.

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

                    is domoticz support this gateway ?

                    wimdW 1 Reply Last reply
                    0
                    • R Reza

                      is domoticz support this gateway ?

                      wimdW Offline
                      wimdW Offline
                      wimd
                      wrote on last edited by
                      #30

                      @Reza yes, select MySensors Gateway USB for type if you add hardware.

                      R 1 Reply Last reply
                      0
                      • wimdW wimd

                        @Reza yes, select MySensors Gateway USB for type if you add hardware.

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

                        @wimd
                        i have problem with usb port in raspberry. everytime after power off/on , usb port lost for me. so now i use a raspberry gateway . rs485 can run on gpio ? with a virtual usb port

                        wimdW 1 Reply Last reply
                        0
                        • R Reza

                          @wimd
                          i have problem with usb port in raspberry. everytime after power off/on , usb port lost for me. so now i use a raspberry gateway . rs485 can run on gpio ? with a virtual usb port

                          wimdW Offline
                          wimdW Offline
                          wimd
                          wrote on last edited by
                          #32

                          @Reza sory but I'm not able to help you with this.

                          R 2 Replies Last reply
                          0
                          • wimdW wimd

                            @Reza sory but I'm not able to help you with this.

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

                            @wimd
                            thank you :pray:

                            wimdW 1 Reply Last reply
                            0
                            • wimdW wimd

                              @Reza sory but I'm not able to help you with this.

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

                              @wimd
                              i have problem with nrf24. and this is work bad for me in distance 10 or 20 meter. i have problem in wireless connection. this protocol have not this problem ? connection is good ? with out any disconnect ?

                              wimdW 1 Reply Last reply
                              0
                              • R Reza

                                @wimd
                                thank you :pray:

                                wimdW Offline
                                wimdW Offline
                                wimd
                                wrote on last edited by
                                #35

                                @Reza Check https://www.mysensors.org/build/raspberry. There is a comment for a serialgateway.

                                R 1 Reply Last reply
                                0
                                • wimdW wimd

                                  @Reza Check https://www.mysensors.org/build/raspberry. There is a comment for a serialgateway.

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

                                  @wimd
                                  i see this, but this is not for a arduino wiring. this is for a nrf24 . perhaps @marceloaqno can setup a rs485 gateway on raspberry. thank you

                                  wimdW 1 Reply Last reply
                                  0
                                  • R Reza

                                    @wimd
                                    i have problem with nrf24. and this is work bad for me in distance 10 or 20 meter. i have problem in wireless connection. this protocol have not this problem ? connection is good ? with out any disconnect ?

                                    wimdW Offline
                                    wimdW Offline
                                    wimd
                                    wrote on last edited by
                                    #37

                                    @Reza Struggling also with the radio network if the distance is more then 5m (and I'm using the ones with the antenna) I have troubles
                                    Add #define MY_RF24_PA_LEVEL RF24_PA_HIGH to send on maximum power.
                                    Added the capacitor give a bit extra power on the 3,3V?

                                    I do not have a RS485 network installed yet but trails on a 10m ethernet cable did not give any issues. Still in program phase.

                                    R 1 Reply Last reply
                                    0
                                    • R Reza

                                      @wimd
                                      i see this, but this is not for a arduino wiring. this is for a nrf24 . perhaps @marceloaqno can setup a rs485 gateway on raspberry. thank you

                                      wimdW Offline
                                      wimdW Offline
                                      wimd
                                      wrote on last edited by
                                      #38

                                      @Reza scroll down on the page down to the serial gateway chapter on that page.

                                      1 Reply Last reply
                                      0
                                      • wimdW wimd

                                        @Reza Struggling also with the radio network if the distance is more then 5m (and I'm using the ones with the antenna) I have troubles
                                        Add #define MY_RF24_PA_LEVEL RF24_PA_HIGH to send on maximum power.
                                        Added the capacitor give a bit extra power on the 3,3V?

                                        I do not have a RS485 network installed yet but trails on a 10m ethernet cable did not give any issues. Still in program phase.

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

                                        @wimd
                                        i use capacitor 4.7 , 100 , 470 uf.
                                        i use 3 type of radio. (usual + 2chip + 2chip+pa+lna)
                                        i use radio adapter. i use regolator 5 to 3.3 module.
                                        but i have problem yet.
                                        i dont test #define MY_RF24_PA_LEVEL RF24_PA_HIGH !
                                        what is code ? and where i can add this ? for gateway or nodes?
                                        this code can solve my problem ? in other means this code can increase power of radio ?

                                        wimdW 1 Reply Last reply
                                        0
                                        • R Reza

                                          @wimd
                                          i use capacitor 4.7 , 100 , 470 uf.
                                          i use 3 type of radio. (usual + 2chip + 2chip+pa+lna)
                                          i use radio adapter. i use regolator 5 to 3.3 module.
                                          but i have problem yet.
                                          i dont test #define MY_RF24_PA_LEVEL RF24_PA_HIGH !
                                          what is code ? and where i can add this ? for gateway or nodes?
                                          this code can solve my problem ? in other means this code can increase power of radio ?

                                          wimdW Offline
                                          wimdW Offline
                                          wimd
                                          wrote on last edited by
                                          #40

                                          @Reza yes adding this code increases the power of the radio.
                                          you add this code at the begin of your sketch (both gateway and nodes)

                                          #define MY_RADIO_NRF24
                                          
                                          #define MY_RF24_PA_LEVEL RF24_PA_HIGH
                                          
                                          R 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          19

                                          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