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. Development
  3. RS485/RS232/Serial transport class for mysensors.org

RS485/RS232/Serial transport class for mysensors.org

Scheduled Pinned Locked Moved Development
rs485 serialrs485
143 Posts 27 Posters 102.9k Views 27 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.
  • A andriej

    Hi!

    Glad to see 'wired' version of MySensor protocol coming.
    One question - how long wires and how many sensors on one pair/multiple pairs will be supported?

    I'm thinking about cabling for new home, which means many meters of cable to every sensor/door/actuator/ligth/meter etc.

    In best scenario - one cat5e - one termination (sensor/node/etc.)
    Currently I'm looking for a cabled version of protocol to support it and be 101% stable (no hiccups and freezes over the protocol), so I can rely on my home.

    MySensors seems to be great to implement, but I'm worried about the signal... I was thinking about letting something around 12-24-30V thru one pair of Cat5 to power all nodes from one power-source (with backup batteries).

    Or - are there any better alternatives for RS485, that doesn't need resistors, have no limitations of 32 devices etc?

    L Offline
    L Offline
    LeoDesigner
    wrote on last edited by LeoDesigner
    #38

    @andriej
    According to: https://en.wikipedia.org/wiki/RS-485
    "It offers data transmission speeds of 35 Mbit/s up to 10 m and 100 kbit/s at 1200 m. "
    also check this: https://www.maximintegrated.com/en/app-notes/index.mvp/id/367
    You may design a bus with up to 256 nodes.
    CAT5 is the best choice anyway for any type of communication (I mean you can run regular Ethernet on them too).
    Check the video at the beginning of the post. It's a working example of two remote nodes connected only with one CAT5 cable over 50m. They are working at 115200 - however speed might be up to 1 Mbit/s.

    A 1 Reply Last reply
    0
    • L LeoDesigner

      @andriej
      According to: https://en.wikipedia.org/wiki/RS-485
      "It offers data transmission speeds of 35 Mbit/s up to 10 m and 100 kbit/s at 1200 m. "
      also check this: https://www.maximintegrated.com/en/app-notes/index.mvp/id/367
      You may design a bus with up to 256 nodes.
      CAT5 is the best choice anyway for any type of communication (I mean you can run regular Ethernet on them too).
      Check the video at the beginning of the post. It's a working example of two remote nodes connected only with one CAT5 cable over 50m. They are working at 115200 - however speed might be up to 1 Mbit/s.

      A Offline
      A Offline
      andriej
      wrote on last edited by
      #39

      @LeoDesigner but how would I connect all sensors in house and relays too?
      SOme resistors needed? Star topology? Few gateways?

      :-)

      L 1 Reply Last reply
      0
      • A andriej

        @LeoDesigner but how would I connect all sensors in house and relays too?
        SOme resistors needed? Star topology? Few gateways?

        L Offline
        L Offline
        LeoDesigner
        wrote on last edited by
        #40

        @andriej
        The star topology could be a problem. However for low speed nodes this may work anyway.
        You may need something like RS485 hub :) or a GW with many RS485 bus ports.
        Or just a separate MAX485 board for each node. You need to test it.

        1 Reply Last reply
        0
        • antiA Offline
          antiA Offline
          anti
          wrote on last edited by
          #41

          @TimO Well... it turns out that the garbage seen on the wire was not garbage, just the binary serial protocol. And the node was desperately attempting to find a parent, with no success.

          FYI this is how I workaround it. But I did not feel like I could fix it for 100% sure.

          The gateway ignored the broadcasts from the node. The following code in MyTransportRS485 triggered for probably wrong reasons (sender=0; nodeid=0;station=broadcast) :

                         if ((_recSender == _nodeId) ||
                            (_recStation != _nodeId &&
                             _recStation != BROADCAST_ADDRESS)) {
                                    _dev.print(" wrongid: ");
          

          Since the gateway was not responding correctly to the node broadcasts, I solved the serial communication problem between node and gateway by defining a fixed node Id :

          #define MY_NODE_ID 10
          

          (ps: the MySensors version used was cloned from git today)

          1 Reply Last reply
          0
          • antiA Offline
            antiA Offline
            anti
            wrote on last edited by
            #42

            Replying to myself... Of course the "Controller" MUST be properly connected
            for dynamic nodes IDs to function properly, since it's the controller's job to affect the node ids.

            This explains a part of my original problem.

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

              I think, that CAN transceiver chip is better then RS485 transceiver chip.
              Then we dont need direction setting pin and bus state is better determined, becose CAn bus is prepered for bus collisions, RS485 not.
              I mean only CAN bus transceiver, not CAN controller ! For example MCP2551 or MCP2562.
              And we can use normal serial library.

              A L 3 Replies Last reply
              1
              • K kimot

                I think, that CAN transceiver chip is better then RS485 transceiver chip.
                Then we dont need direction setting pin and bus state is better determined, becose CAn bus is prepered for bus collisions, RS485 not.
                I mean only CAN bus transceiver, not CAN controller ! For example MCP2551 or MCP2562.
                And we can use normal serial library.

                A Offline
                A Offline
                andriej
                wrote on last edited by
                #44

                @kimot what would be the CAN topology needed?
                Does it support star topology? Im looking for a in-home bus over cat5e in walls...

                Regards

                :-)

                K 1 Reply Last reply
                0
                • K kimot

                  I think, that CAN transceiver chip is better then RS485 transceiver chip.
                  Then we dont need direction setting pin and bus state is better determined, becose CAn bus is prepered for bus collisions, RS485 not.
                  I mean only CAN bus transceiver, not CAN controller ! For example MCP2551 or MCP2562.
                  And we can use normal serial library.

                  L Offline
                  L Offline
                  LeoDesigner
                  wrote on last edited by
                  #45

                  @kimot
                  Just a quick look
                  http://www.aliexpress.com/item/MCP2551-High-Speed-CAN-Communicate-Protocol-Controller-Bus-Interface-Module/32472004400.html?spm=2114.031010208.3.27.bEv7Im&ws_ab_test=searchweb201556_1,searchweb201644_3_79_78_77_82_80_62_81,searchweb201560_1,searchweb1451318400_6148
                  They are five times more expensive.
                  But it might be another option for wired network too.
                  @andrej it is still a line not a star topology.

                  1 Reply Last reply
                  1
                  • A Offline
                    A Offline
                    andriej
                    wrote on last edited by
                    #46

                    Ok so if it's line-wire, then maybe I could wire all cat5e's to one patch-panel, terminate them there and from the patchpanel I could daisy-chain them on one magistral connection and also feed the 12/24V on one pair (i.e. orange/white orange) and data (i.e. blue/white blue).

                    How do you guys think it would work for cables in-home in-wall?
                    I guess the power feed would work ok (even including the voltage drop) but what about the RS485/CAN length?
                    I plan to run cat5 to every switch.

                    Still can't decide if I should connect on-wall switches straight to Arduino (to control relays further) or to use small arduinos inside every wall switch to better control sensors there (temperature on wall) and possibility to program every switch differently. The idea is to get every wire to basement anyway.

                    :-)

                    1 Reply Last reply
                    0
                    • A andriej

                      @kimot what would be the CAN topology needed?
                      Does it support star topology? Im looking for a in-home bus over cat5e in walls...

                      Regards

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

                      @andriej
                      RS485 was not designet for multimaster communication, where 2 devices can communicate on the bus at same time. RS485 bus state at this time is not defined. For example if node on RS485 on one end of bus sends message end perform "control" lisening on bus if recieve the same message( what is with correct circuit of RS485 transsiever immposible ), then this received message can be the same. But if in the same time another node on oposite end of bus sends different message, then node on the middle of bus recieves something random.
                      But CAN bus has allways defined state. It has dominate state and recesive state, so node witch send dominate bit cannot be pushed yb node witch at the same time sends recesive bit. I now, thet this feature we cannot use with normal serial communication, but still we can controll correct sending of datagram by lisening bus by sender. If we recieve the same message what we send, there is 100% shure, that the same message lisens every node on CAN bus. On RS485 this is not garanted. Bus topology is the same end we dont need "dePin". So we can use normal serial library. And CAN transciever is not so expensive as wrote LeoDesigner. Look here:

                      http://www.ebay.com/itm/10PCS-MCP2551-I-SN-IC-TRANSCEIVER-CAN-HI-SPD-8-SOIC-NEW-/171541737564?hash=item27f0af305c:g:nbQAAOSwIBBUZU~k

                      And sorry for my english

                      A 1 Reply Last reply
                      1
                      • K kimot

                        @andriej
                        RS485 was not designet for multimaster communication, where 2 devices can communicate on the bus at same time. RS485 bus state at this time is not defined. For example if node on RS485 on one end of bus sends message end perform "control" lisening on bus if recieve the same message( what is with correct circuit of RS485 transsiever immposible ), then this received message can be the same. But if in the same time another node on oposite end of bus sends different message, then node on the middle of bus recieves something random.
                        But CAN bus has allways defined state. It has dominate state and recesive state, so node witch send dominate bit cannot be pushed yb node witch at the same time sends recesive bit. I now, thet this feature we cannot use with normal serial communication, but still we can controll correct sending of datagram by lisening bus by sender. If we recieve the same message what we send, there is 100% shure, that the same message lisens every node on CAN bus. On RS485 this is not garanted. Bus topology is the same end we dont need "dePin". So we can use normal serial library. And CAN transciever is not so expensive as wrote LeoDesigner. Look here:

                        http://www.ebay.com/itm/10PCS-MCP2551-I-SN-IC-TRANSCEIVER-CAN-HI-SPD-8-SOIC-NEW-/171541737564?hash=item27f0af305c:g:nbQAAOSwIBBUZU~k

                        And sorry for my english

                        A Offline
                        A Offline
                        andriej
                        wrote on last edited by
                        #48

                        @kimot Thank you for the information - your english is good enough to understand. :-)

                        I'm just looking for more simple protocol than ethernet to send data from various places - wired.
                        And it seems that, for longer distance and cat5e cable in-wall, ethernet is the only choice :-(

                        :-)

                        L 1 Reply Last reply
                        0
                        • A andriej

                          @kimot Thank you for the information - your english is good enough to understand. :-)

                          I'm just looking for more simple protocol than ethernet to send data from various places - wired.
                          And it seems that, for longer distance and cat5e cable in-wall, ethernet is the only choice :-(

                          L Offline
                          L Offline
                          LeoDesigner
                          wrote on last edited by LeoDesigner
                          #49

                          @andriej
                          Just put CAT5e to every place (or even two CAT5e to each TV, room - as I done myself). Later you will decide what kind of signals will travel over CAT5e wire. It can be Ethernet or RS485, CANbus, or something else. Regular twisted pair Ethernet is also has a star topology with central hub/switch. (You may also remember an old Ethernet system with one base cable and terminating resistors on the both ends). For a really long distance - RS485 is the winner anyway - up to 1200m on slow speed.

                          A 1 Reply Last reply
                          0
                          • L LeoDesigner

                            @andriej
                            Just put CAT5e to every place (or even two CAT5e to each TV, room - as I done myself). Later you will decide what kind of signals will travel over CAT5e wire. It can be Ethernet or RS485, CANbus, or something else. Regular twisted pair Ethernet is also has a star topology with central hub/switch. (You may also remember an old Ethernet system with one base cable and terminating resistors on the both ends). For a really long distance - RS485 is the winner anyway - up to 1200m on slow speed.

                            A Offline
                            A Offline
                            andriej
                            wrote on last edited by
                            #50

                            @LeoDesigner I will put cat5e for 'LAN' purposes to proper socket, but I also want to control my lights not via connecting/disconnecting 230V in-wall, but in central control panel.
                            I was planning to use doorbell push buttons on walls just to give signal to automation and then MCU will set proper relays/dimmers on/off etc.

                            That's why I was thinking about putting cat5e also to on-wall switches, then on 1 pair make the +/-12V signal, another pair for data bus etc. And now I'm looking for most efficient way to connect it everything together.
                            Each room will have temperature sensor for sure (in the switch), some may have dimmers etc. Last idea was to put mini arduinos inside the hole in wall, but I'm afraid of resetting them every once in a while, just because arduino likes to hang itself...

                            :-)

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

                              @andriej remember to calculate how much current you can take thru cat5e and how much load there can be with one pair.
                              From wikipedia: "Maximum current per conductor 0.577A". So this would make P=UxI -> 12Vx0.577A=6.92W. There is calculations where one nano can take max 1.4Watts. You could use more wires of the car5e for power or lift voltage upper. 48Vx0.577A=27.70W ;)

                              A 1 Reply Last reply
                              0
                              • P pjr

                                @andriej remember to calculate how much current you can take thru cat5e and how much load there can be with one pair.
                                From wikipedia: "Maximum current per conductor 0.577A". So this would make P=UxI -> 12Vx0.577A=6.92W. There is calculations where one nano can take max 1.4Watts. You could use more wires of the car5e for power or lift voltage upper. 48Vx0.577A=27.70W ;)

                                A Offline
                                A Offline
                                andriej
                                wrote on last edited by
                                #52

                                @pjr I'm aware of that :-)
                                Still struggling with decision either to use the CAT5e just as a loooong cable to (doorbell) switch or use it to PoE small nanos all over the place and run i.e. MQTT on each wall-switch separate.
                                In second option the RS485 protocol would be the best, because of small form factor (smaller than ethernet port inside switch) and possibility to use MySensors too ;-)

                                :-)

                                1 Reply Last reply
                                0
                                • K kimot

                                  I think, that CAN transceiver chip is better then RS485 transceiver chip.
                                  Then we dont need direction setting pin and bus state is better determined, becose CAn bus is prepered for bus collisions, RS485 not.
                                  I mean only CAN bus transceiver, not CAN controller ! For example MCP2551 or MCP2562.
                                  And we can use normal serial library.

                                  A Offline
                                  A Offline
                                  andriej
                                  wrote on last edited by
                                  #53

                                  @kimot what has to be done to prepare MySensors to use CAN?
                                  I'm thinking about ordering some modules for tests. :-)

                                  :-)

                                  K 2 Replies Last reply
                                  0
                                  • T Offline
                                    T Offline
                                    TimO
                                    Hero Member
                                    wrote on last edited by
                                    #54

                                    @andriej said:

                                    use it to PoE small nanos all over the place

                                    Which components do you have in mind? I 'm thinking in that direction too.

                                    A 1 Reply Last reply
                                    0
                                    • T TimO

                                      @andriej said:

                                      use it to PoE small nanos all over the place

                                      Which components do you have in mind? I 'm thinking in that direction too.

                                      A Offline
                                      A Offline
                                      andriej
                                      wrote on last edited by
                                      #55

                                      @TimO this small W5100 module: http://www.aliexpress.com/item/TOP-Mini-W5100-LAN-Ethernet-Shield-Network-Module-board-Best/32457200047.html with step-down dc converter. :-)
                                      Cheaper than the PoE standard version.

                                      :-)

                                      1 Reply Last reply
                                      0
                                      • A andriej

                                        @kimot what has to be done to prepare MySensors to use CAN?
                                        I'm thinking about ordering some modules for tests. :-)

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

                                        @andriej
                                        It is a pity that not paying more attention mysensors.org for nodes interconnected by wires. But it is very difficult to find peer-to-peer protocol for RS485. Mainly because of solving collisions on the bus when multiple sensors. But it is very difficult to find peer-to-peer protocol for RS485. Mainly because of solving collisions on the bus when multiple sensors. I think that used ICSC library does not address this matter satisfactorily and with a larger number of sensor problems arise. ICSC library uses a Serial Software library by heavyweight each node on the bus, because all must be checke every bit transmitted on the bus. Look at different implementation:

                                        www.mrbus.org

                                        I think, thet using hardware UART is absolutely necessary.
                                        Or why when we use a separate module for radio transmission, we use the special module for robust message transfer over the wired bus? CAN controllers are not so expensive in this days:

                                        http://www.ebay.com/itm/MCP2515-CAN-Bus-Module-Board-TJA1050-receiver-SPI-For-51-MCU-ARM-controller-M2-/381500570180?hash=item58d334ba44:g:OhcAAOSw3KFWfANk

                                        After correct CAN controller configuration, we simply write a message to the CAN controller and forgot about it. No check or bus arbitration. And through interrupt pin from the controller just pick up the incoming message with our ID or broadcast.

                                        I know it's not as simple as using only RS485 transmitter itself, but we are guaranteed connecting maximum of 110 nodes and various libraries for Arduino for this CAN controller exist.

                                        L 1 Reply Last reply
                                        1
                                        • A andriej

                                          @kimot what has to be done to prepare MySensors to use CAN?
                                          I'm thinking about ordering some modules for tests. :-)

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

                                          @andriej
                                          But on the other side, with simply CANbus, we have got only 8 byte payload for our data.

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


                                          17

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