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. Hardware
  3. Step-by-step procedure to connect the NRF24L01+ to the GPIO pins and use the Raspberry as a Serial Gateway (MySensors 1.x)

Step-by-step procedure to connect the NRF24L01+ to the GPIO pins and use the Raspberry as a Serial Gateway (MySensors 1.x)

Scheduled Pinned Locked Moved Hardware
nrf24raspberry piraspberryraspberry nrf24l01 gpiogateway
168 Posts 47 Posters 175.0k Views 36 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.
  • mfalkviddM Offline
    mfalkviddM Offline
    mfalkvidd
    Mod
    wrote on last edited by
    #60

    Sorry @ahmedadelhosni, I haven't tried to compile the Raspberry gateway for signing. @Anticimex will probably chide me for that, and rightly so :)
    It should just be a matter of modifying MyConfig.h to enable signing, as per the instructions in http://forum.mysensors.org/topic/1021/security-introducing-signing-support-to-mysensors but maybe the MySensor files in the Raspberry repo haven't been updated with the signing features.

    1 Reply Last reply
    0
    • AnticimexA Offline
      AnticimexA Offline
      Anticimex
      Contest Winner
      wrote on last edited by
      #61

      The signing backends are updated for multi arch support thanks to @tbowmo and his SAMD gateway project, but they still assume Arduino compatible api:s for io, so if the raspberry repo/port provide that, it should work. If not, it should just be a matter of adding support for the raspberry spi:s for setting pin direction and states and (if sw backend is to be used) provide a random number generator. The code is C/C++ and hw independent in other aspects.

      Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

      1 Reply Last reply
      0
      • AnticimexA Offline
        AnticimexA Offline
        Anticimex
        Contest Winner
        wrote on last edited by
        #62

        If anyone would like to add support for rPi to the signing backends, I suggest using a Linux generic approach using sysfs to handle io. Same for rng (using an appropriate device node, rpi has a hw rng that should be used).
        If the design is Linux generic and uses proper design to abstract raspberry board specifics, it opens up for reuse by any hw that uses a Linux kernel :)

        Do you feel secure today? No? Start requiring some signatures and feel better tomorrow ;)

        1 Reply Last reply
        0
        • haydukeH Offline
          haydukeH Offline
          hayduke
          wrote on last edited by
          #63

          I've been struggling with this setup for a few weeks now. I've resisted posting to try and figure it out, but I'm not making any progress. When I first setup the rpi with the nrf24 directly connected, everything worked great. I was running a node with temp and motion pretty reliably. I had some difficulty getting the relay node to work, but I got that working eventually as well, but not reliably. While trying to resolve this, I started getting these errors (log from Domoticz):
          2016-02-19 10:43:36.007 MySensors: Using serial port: /dev/ttyUSB20
          2016-02-19 10:43:36.008 Error: MySensors: Error opening serial port!
          2016-02-19 10:43:37.008 MySensors: retrying in 30 seconds...

          I see the post above about this being related to using sensors not supported. Since it started with the relay node, I took that out of the setup, but I'm still getting the error.

          I've rebuilt the entire rpi, mysensors, and domoticz, but I can't get it to work reliably. If I start the gateway manually via a putty session, it will work for a few minutes, but then it stops and goes back to the command prompt in putty and I can see the log in Domoticz start showing the above errors.

          I have setup the gateway to start automatically, but it doesn't seem to restart correctly after a reboot.

          I suspect I have a version mismatch in my code somewhere, but I can't seem to find it. My last effort was to remove all code from my computer and start over, ie reinstall Arduino and a fresh download of MySensors code (v1.5).

          I've also tried changing the permissions on the tty devices, but that didn't seem to help either.

          I was real excited about this project when I first read about it. When I finally got some parts in, I had some quick success that kept me motivated, but my enthusiasm is waning a bit with my total lack of progress on this issue. :(

          Thanks in advance for any help.

          1 Reply Last reply
          0
          • mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by mfalkvidd
            #64

            Which capacitor(s) are you using?
            Do you use a power amplified version of the nrf24l01+ or the regular version?
            What is the output of /usr/local/sbin/PiGatewaySerial until the gateway stops working?

            haydukeH 1 Reply Last reply
            0
            • mfalkviddM mfalkvidd

              Which capacitor(s) are you using?
              Do you use a power amplified version of the nrf24l01+ or the regular version?
              What is the output of /usr/local/sbin/PiGatewaySerial until the gateway stops working?

              haydukeH Offline
              haydukeH Offline
              hayduke
              wrote on last edited by
              #65

              @mfalkvidd
              I have a 4.7uf electrolytic cap soldered directly to the pins on the radio module.
              Radio is standard, ie antenna via board traces.

              I just did another batch of testing to try and answer your last question.
              I started the gateway manually, ie sudo /usr/local/sbin/PiGatewaySerial
              I plugged in a temp sensor (dallas 18b20, 3.3v apm, via 3.3v FTDI) into the computer so I could monitor the serial port.

              The first time I turned on the temp sensor, the gateway closed after 5 "read:"'s. I tried it again and the gateway stopped (meaning I was back at the prompt in putty) after 2 reads.
              I decided to reboot the rpi. When it came back up, I had the Domoticz log open and I could see the gateway start before I could reopen a putty session. It appears the auto start worked correctly, and so far, it's still up.
              I've been sending temp data successfully for ~10 minutes now.

              ...time passes...
              I typed out the above, but didn't hit submit as I wanted to go put the relay node back together and test it.

              After gathering up those parts, I check the Domoticz log and it's still reading temp. While it IS working, the temps are displaying wrong in Domoticz. My sensor is sending F, but domoticz thinks it's C and it converts.

              I'm mentioning this because, when I open the serial monitor to confirm the node was sending F values, it of course resets the node. This killed the gateway. I got the following in my domoticz log:
              2016-02-19 15:00:30.362 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:00:38.371 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:00:46.380 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:00:50.384 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:00:54.389 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:00:58.393 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:01:02.398 (MySensorsSerial) Temp (Temp)
              2016-02-19 15:01:06.403 Error: Serial Port closed!... Error: End of file
              2016-02-19 15:01:06.864 MySensors: retrying in 30 seconds...
              2016-02-19 15:01:35.867 MySensors: Using serial port: /dev/ttyUSB20
              2016-02-19 15:01:35.868 Error: MySensors: Error opening serial port!
              2016-02-19 15:01:36.869 MySensors: retrying in 30 seconds...
              2016-02-19 15:02:05.871 MySensors: Using serial port: /dev/ttyUSB20
              2016-02-19 15:02:05.872 Error: MySensors: Error opening serial port!
              2016-02-19 15:02:06.872 MySensors: retrying in 30 seconds...
              2016-02-19 15:02:20.010 Active notification subsystems: (0/10)
              2016-02-19 15:02:35.875 MySensors: Using serial port: /dev/ttyUSB20
              2016-02-19 15:02:35.875 Error: MySensors: Error opening serial port!
              2016-02-19 15:02:36.875 MySensors: retrying in 30 seconds...

              I ran sudo cat /dev/ttyMySensorsGateway and get 'No such file' message. I interpret this to mean the gateway has stopped running, right?

              Next I manually started the gateway again. It immediately starts reading the temp sensor again. After the next 30 second timer expires, Domoticz picks it right back up too.

              I think I figured something out... If I restart a node with the gateway running, it kills the gateway and my above symptoms start. I'm able to repeat this without failure.

              I'm going to do some more testing, but it seems that when the node sends the s=255 message, the gateway is dieing.
              I want to see what happens if I turn on another node while the first is alraedy running. Perhaps I have to have all my nodes on before I start the gateway?

              I am very encouraged as I at least finally feel like I'm moving forward. Was getting frustrated for awhile there. :)
              Thanks again for the write to help me get started.

              1 Reply Last reply
              0
              • haydukeH Offline
                haydukeH Offline
                hayduke
                wrote on last edited by
                #66

                Did some more testing. Now I know why it seemed related to the relay node.
                The relay node needs the gateway to be listening when it wakes up. If it fails when it presents, ie the gateway is down, it doesn't try again.

                I did have the relay sketch working at some point, so I don't think it's that sketch. I'm thinking I have a problem with the gateway. I work as a developer, so I've been trying to acquaint myself with the code. I mostly use SQL and VB.net in my day job. I loved C++ in college, but it's been almost that long since I used it. :)

                Does anyone have any ideas what might be causing this? I'm going to go reread the section on the mysensors protocol and see I can spot anything wrong in those presentation messages.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tommyken
                  wrote on last edited by tommyken
                  #67
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • JustinianJ Offline
                    JustinianJ Offline
                    Justinian
                    wrote on last edited by
                    #68

                    Hi there
                    I did everything according to the instructions. Installing went without complications. However, when trying to verify the gateway problems arise.

                    After typing

                    sudo /usr/local/sbin/PiGatewaySerial
                    

                    I receive the message: command not found.
                    Also, no /dev/ttyMySensorsGateway file has been created.

                    When I am entering

                    sudo /etc/init.d/PiGatewaySerial start
                    

                    nothing happens. I only get a new command line.

                    I can start the gateway, however, when I am entering

                    sudo ./PiGatewaySerial
                    

                    in the Raspberry folder.

                    I already tried to uninstall and re-install everything, without success. Has anybody any suggestions how to solve this issue?

                    mfalkviddM 1 Reply Last reply
                    0
                    • JustinianJ Justinian

                      Hi there
                      I did everything according to the instructions. Installing went without complications. However, when trying to verify the gateway problems arise.

                      After typing

                      sudo /usr/local/sbin/PiGatewaySerial
                      

                      I receive the message: command not found.
                      Also, no /dev/ttyMySensorsGateway file has been created.

                      When I am entering

                      sudo /etc/init.d/PiGatewaySerial start
                      

                      nothing happens. I only get a new command line.

                      I can start the gateway, however, when I am entering

                      sudo ./PiGatewaySerial
                      

                      in the Raspberry folder.

                      I already tried to uninstall and re-install everything, without success. Has anybody any suggestions how to solve this issue?

                      mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by
                      #69

                      @Justinian looks like you forgot to run "sudo make install" after "make all"

                      haydukeH JustinianJ 2 Replies Last reply
                      0
                      • mfalkviddM mfalkvidd

                        @Justinian looks like you forgot to run "sudo make install" after "make all"

                        haydukeH Offline
                        haydukeH Offline
                        hayduke
                        wrote on last edited by
                        #70

                        @mfalkvidd said:

                        @Justinian looks like you forgot to run "sudo make install" after "make all"

                        I took a little break from this project, but I worked on it again this weekend. I decided to start from scratch and rebuild the gateway completely. I put a fresh Domoticz image onto the SD card, updated and upgraded, cloned, compiled, and installed the RF24 and Raspberry code.

                        Now I have the exact same symptom as Justinian :(

                        Since this used to work for me at some point, next I will try using an older Dmoticz image. I read somewhere that people had better success by NOT using apt-get update. Perhaps it's a problem with Jessie vs Wheezy? Domoticz switched kernels during on of the version upgrades.

                        Winter is over, so I can live without getting my furnace controls working right now. I know relays have an issue, but now I'm just needing to monitor the temperature in an egg incubator.

                        I'm surprised that using a rpi with this radio module directly attached is not a more popular platform. Is it just not a reliable platform? With the rpi3 out now, there shouldn't be a CPU load issue trying to act as an HA controller even with a large installation. I've got lots of ideas I want to implement if I can ever get a stable backend.

                        strangerS 1 Reply Last reply
                        0
                        • mfalkviddM mfalkvidd

                          @Justinian looks like you forgot to run "sudo make install" after "make all"

                          JustinianJ Offline
                          JustinianJ Offline
                          Justinian
                          wrote on last edited by
                          #71

                          @mfalkvidd thanks for your help. Unfortunately, this didn't resolve the issue. I repeated the installation, this time deliberately executing sudo make install, but the problem remained.
                          @hayduke Maybe this indeed is an issue with Raspbian Jessie as I am on Jessie.

                          1 Reply Last reply
                          0
                          • martinhjelmareM Offline
                            martinhjelmareM Offline
                            martinhjelmare
                            Plugin Developer
                            wrote on last edited by martinhjelmare
                            #72

                            Jessie uses a different init system than Wheezy. Systemd should be able to handle most old init scripts, but this case might be an exception.

                            Has anyone successfully installed this on Jessie?

                            A unit file for systemd would be a good addition, in any case, in my opinion.

                            GertSandersG 1 Reply Last reply
                            0
                            • martinhjelmareM martinhjelmare

                              Jessie uses a different init system than Wheezy. Systemd should be able to handle most old init scripts, but this case might be an exception.

                              Has anyone successfully installed this on Jessie?

                              A unit file for systemd would be a good addition, in any case, in my opinion.

                              GertSandersG Offline
                              GertSandersG Offline
                              GertSanders
                              Hardware Contributor
                              wrote on last edited by
                              #73

                              @martinhjelmare

                              I'm on the latest Jessie version. Prior to that I also used DietPi as a platform for Domoticz and Mysensors. I have not done an apt-get update or apt-upgrade since the install (I used the Jessie image from the Raspberry Org site).

                              As for load, here is the image of Domoticz CPU load of the last year:

                              0_1458749110546_upload-1e3bf645-1595-4d9d-9635-52cf04407556

                              As you can see, combining the Gateway function with the Controller function on the Raspberry 2 gives virtually no load. I could probably add the Plex Media Player software to this and still have room for some more cron jobs.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                shabba
                                wrote on last edited by
                                #74

                                Hi - I saw enquires months ago about getting RF69 working - has anyone done so? thanks!

                                mfalkviddM 1 Reply Last reply
                                0
                                • S shabba

                                  Hi - I saw enquires months ago about getting RF69 working - has anyone done so? thanks!

                                  mfalkviddM Offline
                                  mfalkviddM Offline
                                  mfalkvidd
                                  Mod
                                  wrote on last edited by
                                  #75

                                  @shabba the best discussion I've seen so far is http://forum.mysensors.org/topic/1918/what-radio-to-use-nrf24l01-rfm69-rfm73/

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    shabba
                                    wrote on last edited by
                                    #76

                                    Thanks @mfalkvidd - will check it out.

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      shabba
                                      wrote on last edited by
                                      #77

                                      Ps. I followed https://github.com/abouillot/HomeAutomation/tree/master/piGateway and now have a MQTT service running. But I do not know how to connect this to domoticz or even debug that it can actually see my test sensor etc.

                                      1 Reply Last reply
                                      0
                                      • haydukeH hayduke

                                        @mfalkvidd said:

                                        @Justinian looks like you forgot to run "sudo make install" after "make all"

                                        I took a little break from this project, but I worked on it again this weekend. I decided to start from scratch and rebuild the gateway completely. I put a fresh Domoticz image onto the SD card, updated and upgraded, cloned, compiled, and installed the RF24 and Raspberry code.

                                        Now I have the exact same symptom as Justinian :(

                                        Since this used to work for me at some point, next I will try using an older Dmoticz image. I read somewhere that people had better success by NOT using apt-get update. Perhaps it's a problem with Jessie vs Wheezy? Domoticz switched kernels during on of the version upgrades.

                                        Winter is over, so I can live without getting my furnace controls working right now. I know relays have an issue, but now I'm just needing to monitor the temperature in an egg incubator.

                                        I'm surprised that using a rpi with this radio module directly attached is not a more popular platform. Is it just not a reliable platform? With the rpi3 out now, there shouldn't be a CPU load issue trying to act as an HA controller even with a large installation. I've got lots of ideas I want to implement if I can ever get a stable backend.

                                        strangerS Offline
                                        strangerS Offline
                                        stranger
                                        wrote on last edited by
                                        #78

                                        This thread has been great - thanks @mfalkvidd!

                                        @hayduke I had a similar problem earlier. I haven't fixed it yet, but here's where I'm at:

                                        Clean install (Jessie, RF24, Raspberry) March 25th 2016 has the problem where it works for a few minutes, then stops (/dev/pts/0 dissapears, which breaks the symbolic links - ttyMySensorsGateway and ttyUSB20). This is at home where I have a bunch of nodes around and a Vera with serial gateway, so there are lots of different signals coming in.

                                        But when I move to another location with just one node (that just sends a light status update regularly), it works fine - at least, I've been sitting here with it running for 30 minutes so far.

                                        I know this might not help much, I'm new to all this and still getting my head around everything. I would probably agree with what you suggested earlier: something in one of the messages that causes a problem with the gateway (possibly to do with already having another serial gateway nearby).

                                        I'll try to do some more testing by changing this gateway to a different channel to my other one, and gradually bringing nodes across to see when it breaks.

                                        1 Reply Last reply
                                        1
                                        • alexsh1A Offline
                                          alexsh1A Offline
                                          alexsh1
                                          wrote on last edited by
                                          #79

                                          @stranger just to make sure - you said you have two gateways at home. Did you change the channel so that they do not interfere with each other?

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


                                          7

                                          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