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. Porting MySensors to work with the RadioHead library

Porting MySensors to work with the RadioHead library

Scheduled Pinned Locked Moved Development
portingradiohead
288 Posts 24 Posters 187.4k Views 12 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.
  • T ToSa

    @Zeph said:

    I do not think it makes sense to move type (V_code) or command into the RH FLAGs. Typically when such space is reserved for the protocol in the header but not yet fully used, it's subject to change as the protocal evolves. If part of the goal is to take advantage of the maintenance and ongoing development of RH, we don't want to set up a conflict - because other users are not going to use those FLAGs our way anyway.

    From the RH documentation / the source code:

    • for Datagram FLAGS:
      A bitmask of flags. The most significant 4 bits are reserved for use by RadioHead. The least significant 4 bits are reserved for applications.
    • for Router/Mesh FLAGS:
      Optional flags for use by subclasses or application layer

    Not setting up a conflict with the RH code will be the biggest issue: the two benefits of RH are the multi radio support and the more advanced Mesh topology - which would be worth a couple of additional bytes in flash and ram - but the other reason for the big overhead is that several advanced features of the nRF24 chip are not used because they are not available in all supported chips.

    Two examples:

    • the multi-pipe capability of nRF24 would allow to filter traffic to only current address and broadcast and avoid that any other traffic ever reaches the MCU (only slightly less code but wondering if that helps with battery powered nodes).
    • the ReliableDiagram processing in code essentially duplicates capabilities that are build into the chipset as well (auto-acknowledge / autoresubmit)

    I know you are interested in getting RF69 supported but the question is how much negative impact for all the other users (with current nRF24 setup) is acceptable. That's like using the RF69 and implementing an AES encryption in code rather than using the build-in capabilities of the chip...

    Z Offline
    Z Offline
    Zeph
    Hero Member
    wrote on last edited by
    #143

    @ToSa said:

    the two benefits of RH are the multi radio support and the more advanced Mesh topology

    Could someone summarize the differences between the current MySensors mesh and the RadioHead mesh, and why the latter is preferable for us?

    hekH 1 Reply Last reply
    0
    • Z Zeph

      @ToSa said:

      the two benefits of RH are the multi radio support and the more advanced Mesh topology

      Could someone summarize the differences between the current MySensors mesh and the RadioHead mesh, and why the latter is preferable for us?

      hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #144

      @Zeph

      RH is a true mesh where every node can communicate with any other directly (if in range). All nodes acts as repeaters.

      MySensors forms nodes forms a star network where every node has a parent and potentially a few child sensors. The gateway node is the "center". Every node always tries to find the closest (least number of hops) route to gateway.

               GW
               / \  
              A   D
             / \
            B   C
      

      If B want to communicate with C messages has to pass A in the MySensors case. In RH C and B will communicate directly if the can hear each other.

      RH does not use the nifty features NRF24L01 offers which offloads mcu (pipes/addresses) nor auto ack (impossible in RH setup). So nodes in range has to process every message it can "hear". And this can potentially be a lot.

      Z 2 Replies Last reply
      0
      • hekH hek

        @Zeph

        RH is a true mesh where every node can communicate with any other directly (if in range). All nodes acts as repeaters.

        MySensors forms nodes forms a star network where every node has a parent and potentially a few child sensors. The gateway node is the "center". Every node always tries to find the closest (least number of hops) route to gateway.

                 GW
                 / \  
                A   D
               / \
              B   C
        

        If B want to communicate with C messages has to pass A in the MySensors case. In RH C and B will communicate directly if the can hear each other.

        RH does not use the nifty features NRF24L01 offers which offloads mcu (pipes/addresses) nor auto ack (impossible in RH setup). So nodes in range has to process every message it can "hear". And this can potentially be a lot.

        Z Offline
        Z Offline
        Zeph
        Hero Member
        wrote on last edited by Zeph
        #145

        @hek
        Thanks, that was very helpful, and a good explanation.

        That helps explain the overhead in the RH library mesh. It sounds cool for some purposes, but it also sounds like possible overkill for the wireless sensor network. Allowing B and C to communicate directly is not a primary use case. The MySensors is purpose-built for the sensor network with central gateway use case, and is pretty lean thereby. As I see it, even allowing B to send to C via A is not a primary use case, but sort of falls out "for free" given the routing approach that allows repeating nodes.

        Aside - can B send a message to itself via A?

        In my case, I'm mainly focusing on multi-sensor nodes, so RAM or Flash could be in short supply with a larger radio library. Worse still, I want to be able to incorporate MySensors functionality into nodes which also have non MySensors functions (eg: xmas light control also usng nRF24L01+), so space is even more at a premium.

        So while the RH option is interesting, and a lighter weight RH derivative may pan out, I hope the MySensor WSN radio layer will continue to provide a "lean and mean" alternative into the future.

        1 Reply Last reply
        0
        • hekH hek

          @Zeph

          RH is a true mesh where every node can communicate with any other directly (if in range). All nodes acts as repeaters.

          MySensors forms nodes forms a star network where every node has a parent and potentially a few child sensors. The gateway node is the "center". Every node always tries to find the closest (least number of hops) route to gateway.

                   GW
                   / \  
                  A   D
                 / \
                B   C
          

          If B want to communicate with C messages has to pass A in the MySensors case. In RH C and B will communicate directly if the can hear each other.

          RH does not use the nifty features NRF24L01 offers which offloads mcu (pipes/addresses) nor auto ack (impossible in RH setup). So nodes in range has to process every message it can "hear". And this can potentially be a lot.

          Z Offline
          Z Offline
          Zeph
          Hero Member
          wrote on last edited by
          #146

          @hek said:

          RH does not use the nifty features NRF24L01 offers which offloads mcu (pipes/addresses) nor auto ack (impossible in RH setup). So nodes in range has to process every message it can "hear". And this can potentially be a lot.

          So MySensors can use both individual node addresses as well a broadcast, while RH uses only broadcast (at the radio level)? I understand why RH needs to do this, and I wonder if the receive FIFO ever overruns with unneeded packets.

          I wonder if MySensors gets much savings from using the auto-ack of ESB. If you already have network ack code anyway, how much code & ram is saved by sometimes using ESB (one hop away) and sometimes not? (I do get that a star network with no repeater nodes could use only ESB autoack and save some code).

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

            @Zeph said:

            So MySensors can use both individual node addresses as well a broadcast, while RH uses only broadcast (at the radio level)?

            Yes.

            I think end-to-end ack is very important. The inter-node ack is only used as a trigger re-routing today (if communication fails 3 times to parent node .. the node tries to find another parent).

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kolaf
              Hero Member
              wrote on last edited by
              #148

              Could someone please explain to me how the direct messaging of the NRF24 works? In my mind every radio network is a broadcast network on the physical layer, and it is up to the receiving radio to determine whether the packet is relevant or not. How is this different from your radios? Is it perhaps that your radios have a hardware address so that the filtering is done on the hardware level, while Radiohead uses a software address, so each packet has to be explicitly processed? I have no idea, I'm just guessing here...

              hekH 1 Reply Last reply
              0
              • K kolaf

                Could someone please explain to me how the direct messaging of the NRF24 works? In my mind every radio network is a broadcast network on the physical layer, and it is up to the receiving radio to determine whether the packet is relevant or not. How is this different from your radios? Is it perhaps that your radios have a hardware address so that the filtering is done on the hardware level, while Radiohead uses a software address, so each packet has to be explicitly processed? I have no idea, I'm just guessing here...

                hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #149

                @kolaf

                Yes,

                NRF chip offer 6 reading "pipes". In practice it acts as a hw filter for addresses between 0-255.

                I use this to have one broadcast address (255) which all repeating nodes and gateway listens to and each sensor also listen to its own address.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kolaf
                  Hero Member
                  wrote on last edited by
                  #150

                  Looking at the documentation for the RF69 (page 41) it talks about sync word recognition. This is a programmable word that apparently can be used as the node's hardware address, similarly to the NRF24. Perhaps it is possible to expand the Radiohead drivers to utilise this functionality where it is available for filtering incoming packets?

                  As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications. We have horses, and it would be really fun to place a radio module with a accelerometer, and maybe GPS receiver, on each horse to track their movements. This could also be combined with a breakable wire in the harness which would let us know if the radio had been ripped off of the horse. Having a dynamic mesh will greatly increase the range of flexibility of such a monitoring network. I know that this is somewhat outside of the normal use case, but how fun wouldn't it be to build this? :-).

                  Personally I'm also a bit interested in direct sensor to sensor configurations to allow for tightly coupled control systems without the need for a central controller in the loop (all the time). I know, we have resource limits so that I can probably not have everything, but one can dream...

                  hekH Z 2 Replies Last reply
                  0
                  • K Offline
                    K Offline
                    kolaf
                    Hero Member
                    wrote on last edited by
                    #151

                    Nevermind the sink word recognition, this appears to function as some kind of network ID has to be the same for both the sender and receiver. However, there is also an optional address byte which is considered by the radio before the packet enters the FIFO queue. Page 55 of http://www.hoperf.com/upload/rfchip/RF69-V1.2.pdf

                    YveauxY 1 Reply Last reply
                    0
                    • K kolaf

                      Nevermind the sink word recognition, this appears to function as some kind of network ID has to be the same for both the sender and receiver. However, there is also an optional address byte which is considered by the radio before the packet enters the FIFO queue. Page 55 of http://www.hoperf.com/upload/rfchip/RF69-V1.2.pdf

                      YveauxY Offline
                      YveauxY Offline
                      Yveaux
                      Mod
                      wrote on last edited by
                      #152

                      @kolaf said:

                      an optional address byte

                      The trouble is you have to distinguish between broadcasts and direct messages, so you need to listen at 2 addresses at a time, so to say.

                      http://yveaux.blogspot.nl

                      K 1 Reply Last reply
                      0
                      • K kolaf

                        Looking at the documentation for the RF69 (page 41) it talks about sync word recognition. This is a programmable word that apparently can be used as the node's hardware address, similarly to the NRF24. Perhaps it is possible to expand the Radiohead drivers to utilise this functionality where it is available for filtering incoming packets?

                        As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications. We have horses, and it would be really fun to place a radio module with a accelerometer, and maybe GPS receiver, on each horse to track their movements. This could also be combined with a breakable wire in the harness which would let us know if the radio had been ripped off of the horse. Having a dynamic mesh will greatly increase the range of flexibility of such a monitoring network. I know that this is somewhat outside of the normal use case, but how fun wouldn't it be to build this? :-).

                        Personally I'm also a bit interested in direct sensor to sensor configurations to allow for tightly coupled control systems without the need for a central controller in the loop (all the time). I know, we have resource limits so that I can probably not have everything, but one can dream...

                        hekH Offline
                        hekH Offline
                        hek
                        Admin
                        wrote on last edited by
                        #153

                        @kolaf said:

                        As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications.

                        Yep, both pros and cons. :)

                        A nice feature you can do with MySensors is to set a static parent (when calling gw.begin()). This could be useful for a presence sensor e.g. mounted on a car set statically to contact a repeater node mounted near the garage. The car sensor won't try to find or contact any other node than the garage one.

                        K 1 Reply Last reply
                        0
                        • K kolaf

                          Looking at the documentation for the RF69 (page 41) it talks about sync word recognition. This is a programmable word that apparently can be used as the node's hardware address, similarly to the NRF24. Perhaps it is possible to expand the Radiohead drivers to utilise this functionality where it is available for filtering incoming packets?

                          As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications. We have horses, and it would be really fun to place a radio module with a accelerometer, and maybe GPS receiver, on each horse to track their movements. This could also be combined with a breakable wire in the harness which would let us know if the radio had been ripped off of the horse. Having a dynamic mesh will greatly increase the range of flexibility of such a monitoring network. I know that this is somewhat outside of the normal use case, but how fun wouldn't it be to build this? :-).

                          Personally I'm also a bit interested in direct sensor to sensor configurations to allow for tightly coupled control systems without the need for a central controller in the loop (all the time). I know, we have resource limits so that I can probably not have everything, but one can dream...

                          Z Offline
                          Z Offline
                          Zeph
                          Hero Member
                          wrote on last edited by Zeph
                          #154

                          @kolaf said:

                          As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications. We have horses, and it would be really fun to place a radio module with a accelerometer, and maybe GPS receiver, on each horse to track their movements. This could also be combined with a breakable wire in the harness which would let us know if the radio had been ripped off of the horse. Having a dynamic mesh will greatly increase the range of flexibility of such a monitoring network.

                          Just brainstorming, but what if we consider adding the concept of a roving node to the MySensors network, without the overhead of a full mesh? Your use case doesn't require that all nodes be meshed with each other, just that a class of leaf nodes be able to move around.

                          If I understand, a gateway or repeater node will forward a packet from anybody, if it recognizes the destination (as a node id in its routing table). Suppose you had coverage of your corral (or whatever) via gateway and various repeaters. In theory (perhaps naive theory) the roving node could report to the gateway by broadcasting a message picked up by whatever repeater is nearest; being addressed to node 0, the repeater knows what to do with it.

                          There would be no network ack and no way for the gateway to send to the roving node as described so far. That is, unless this special "rover packet" caused each relay to rewrite that entry of its routing table as it was passed to the gateway, to enable an updated path back to the roving node. If your horses run around among many nodes often, EEPROM wear could be a concern, unless there was a small "routing override table" in RAM to handle roving nodes.

                          One part I'm not clear about is how to avoid two or more nearby repeaters both forwarding this broadcast packet from the roving node. That might be tricky if it often causes OTA collisions. It could also complicate the back route logic, IF that was implemented. If we could avoid or gracefully recover from collisions, the gateway and controller may be able to deal with multiple copies of the same packet (not unlike the MQTT level 1 "deliver at least once").

                          And - it might be technically infeasible to enhance MySensors networking to support roving nodes. But in that case I'm sure I'll learn something from the manner in which it's shot down :-)

                          hekH 1 Reply Last reply
                          0
                          • YveauxY Yveaux

                            @kolaf said:

                            an optional address byte

                            The trouble is you have to distinguish between broadcasts and direct messages, so you need to listen at 2 addresses at a time, so to say.

                            K Offline
                            K Offline
                            kolaf
                            Hero Member
                            wrote on last edited by
                            #155

                            @Yveaux said:

                            @kolaf said:

                            an optional address byte

                            The trouble is you have to distinguish between broadcasts and direct messages, so you need to listen at 2 addresses at a time, so to say.

                            There is a separate optional broadcast address byte. I'm not sure how this is used, but I'm guessing that the radio checks against both addresses before deciding what to do with the message. That should solve the broadcast problem.

                            hekH Z 2 Replies Last reply
                            0
                            • Z Zeph

                              @kolaf said:

                              As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications. We have horses, and it would be really fun to place a radio module with a accelerometer, and maybe GPS receiver, on each horse to track their movements. This could also be combined with a breakable wire in the harness which would let us know if the radio had been ripped off of the horse. Having a dynamic mesh will greatly increase the range of flexibility of such a monitoring network.

                              Just brainstorming, but what if we consider adding the concept of a roving node to the MySensors network, without the overhead of a full mesh? Your use case doesn't require that all nodes be meshed with each other, just that a class of leaf nodes be able to move around.

                              If I understand, a gateway or repeater node will forward a packet from anybody, if it recognizes the destination (as a node id in its routing table). Suppose you had coverage of your corral (or whatever) via gateway and various repeaters. In theory (perhaps naive theory) the roving node could report to the gateway by broadcasting a message picked up by whatever repeater is nearest; being addressed to node 0, the repeater knows what to do with it.

                              There would be no network ack and no way for the gateway to send to the roving node as described so far. That is, unless this special "rover packet" caused each relay to rewrite that entry of its routing table as it was passed to the gateway, to enable an updated path back to the roving node. If your horses run around among many nodes often, EEPROM wear could be a concern, unless there was a small "routing override table" in RAM to handle roving nodes.

                              One part I'm not clear about is how to avoid two or more nearby repeaters both forwarding this broadcast packet from the roving node. That might be tricky if it often causes OTA collisions. It could also complicate the back route logic, IF that was implemented. If we could avoid or gracefully recover from collisions, the gateway and controller may be able to deal with multiple copies of the same packet (not unlike the MQTT level 1 "deliver at least once").

                              And - it might be technically infeasible to enhance MySensors networking to support roving nodes. But in that case I'm sure I'll learn something from the manner in which it's shot down :-)

                              hekH Offline
                              hekH Offline
                              hek
                              Admin
                              wrote on last edited by
                              #156

                              @Zeph @kolaf

                              The rovering node will be able to send its message (after a few failed attempts) in the current solution.
                              If even faster parent-search is required you can change the #define SEARCH_FAILURES in MySensor.h.

                              1 Reply Last reply
                              0
                              • hekH hek

                                @kolaf said:

                                As for the dynamic mesh, this is a feature I find especially useful for one of my dream applications.

                                Yep, both pros and cons. :)

                                A nice feature you can do with MySensors is to set a static parent (when calling gw.begin()). This could be useful for a presence sensor e.g. mounted on a car set statically to contact a repeater node mounted near the garage. The car sensor won't try to find or contact any other node than the garage one.

                                K Offline
                                K Offline
                                kolaf
                                Hero Member
                                wrote on last edited by
                                #157

                                @hek Just to be clear, I'm not dependent on the mesh functionality. I think I could be very happy with the current MySensors functionality with the added part of supporting my radio :-)

                                1 Reply Last reply
                                0
                                • K kolaf

                                  @Yveaux said:

                                  @kolaf said:

                                  an optional address byte

                                  The trouble is you have to distinguish between broadcasts and direct messages, so you need to listen at 2 addresses at a time, so to say.

                                  There is a separate optional broadcast address byte. I'm not sure how this is used, but I'm guessing that the radio checks against both addresses before deciding what to do with the message. That should solve the broadcast problem.

                                  hekH Offline
                                  hekH Offline
                                  hek
                                  Admin
                                  wrote on last edited by
                                  #158

                                  @kolaf said:

                                  There is a separate optional broadcast address byte. I'm not sure how this is used, but I'm guessing that the radio checks against both addresses before deciding what to do with the message. That should solve the broadcast problem.

                                  That's good!

                                  1 Reply Last reply
                                  0
                                  • K kolaf

                                    @Yveaux said:

                                    @kolaf said:

                                    an optional address byte

                                    The trouble is you have to distinguish between broadcasts and direct messages, so you need to listen at 2 addresses at a time, so to say.

                                    There is a separate optional broadcast address byte. I'm not sure how this is used, but I'm guessing that the radio checks against both addresses before deciding what to do with the message. That should solve the broadcast problem.

                                    Z Offline
                                    Z Offline
                                    Zeph
                                    Hero Member
                                    wrote on last edited by Zeph
                                    #159

                                    @kolaf said:

                                    There is a separate optional broadcast address byte.

                                    Aha, I see that on page 57 now.

                                    I think that would handle it! (I see no need for 6 address-filtered pipes, two addresses will do).

                                    Yes, it would be nice if the RH library could take advantage of address filtering for those radios which support it. I'm not so sure auto-ack is important tho.

                                    1 Reply Last reply
                                    0
                                    • YveauxY Offline
                                      YveauxY Offline
                                      Yveaux
                                      Mod
                                      wrote on last edited by
                                      #160

                                      So, anyone still developing on RadioHead integration, or did all of you just give up? ;-)

                                      I spend some time on writing Wireshark dissectors for RadioHead and integration of MySensors, to be used with the sniffer (http://forum.mysensors.org/topic/242/wireless-nrf24l01-sniffer-for-mysensors)
                                      Code is almost final (still have to test dessection of routing tables).

                                      Just as a preview, here's a screenshot to hopefully get you enthusiastic again!

                                      upload-2e15da80-1b44-4113-a6ac-e0077160d77b

                                      http://yveaux.blogspot.nl

                                      hekH T 2 Replies Last reply
                                      1
                                      • YveauxY Yveaux

                                        So, anyone still developing on RadioHead integration, or did all of you just give up? ;-)

                                        I spend some time on writing Wireshark dissectors for RadioHead and integration of MySensors, to be used with the sniffer (http://forum.mysensors.org/topic/242/wireless-nrf24l01-sniffer-for-mysensors)
                                        Code is almost final (still have to test dessection of routing tables).

                                        Just as a preview, here's a screenshot to hopefully get you enthusiastic again!

                                        upload-2e15da80-1b44-4113-a6ac-e0077160d77b

                                        hekH Offline
                                        hekH Offline
                                        hek
                                        Admin
                                        wrote on last edited by
                                        #161

                                        @Yveaux

                                        Looks good @Yveaux!

                                        1 Reply Last reply
                                        0
                                        • YveauxY Offline
                                          YveauxY Offline
                                          Yveaux
                                          Mod
                                          wrote on last edited by
                                          #162

                                          I'm still a bit in doubt how sleeping nodes fit in when using RadioHead.
                                          It has no notion of sleeping nodes and just expects all nodes to be available anytime.
                                          When a route is e.g. discovered which uses a node that is about to go to sleep, routing will fail, but probably the route will then be rediscovered and finally settle using a node that is continuously powered.
                                          How long this will take and the likelyhood of such scenarios (depends ofcourse on the amount of nodes and how often/when they are awake) is still unclear to me.
                                          Hopefully I can analyze some real-world behavior using the sniffer.

                                          http://yveaux.blogspot.nl

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


                                          10

                                          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