Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. [Tutorial] Raspberry Pi NRF24l01 direct connection
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

[Tutorial] Raspberry Pi NRF24l01 direct connection

Scheduled Pinned Locked Moved Controllers
raspberry pinrf24l01
56 Posts 32 Posters 85.9k Views 24 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.
  • Vladut GrecuV Offline
    Vladut GrecuV Offline
    Vladut Grecu
    wrote on last edited by Vladut Grecu
    #1

    [EDIT] - I uploaded a script in the next post that does everything I explained below

    I have installed MINImal raspBIAN which is a raspBIAN without a gui. So this should work for you guys.

    First of all you have to
    1. Undo your Overclock. If you have any. (SPI does not like Overclocked pi's)

    2. Enable SPI

    Details:

    On a normal raspbian image this can be done either on a fresh install (when you config your pi) or you can type in terminal sudo raspi-config
    From there you go into ADVANCED OPTIONS -> SPI

    On a minimal image you don't have the luxury of raspi-config. You have to manually activate it.
    (I already had it enabled but you can check)
    (If you don't have sudo installed on your image just run apt-get install sudo)

    sudo nano /etc/modprobe.d/raspi-blacklist.conf

    Make sure there IS a # before blacklist spi-bcm2708, so it looks like this…
    #blacklist spi-bcm2708

    If there is no line like that, you can add it. It won't do any harm.
    CTRL+O - Save
    ENTER - Confirm
    CTRL+X - Exit

    or

    CTRL+X - Exit
    y - I want to save the file
    ENTER - Confirm

    We have to edit now the config.txt.
    sudo nano /boot/config.txt

    add this to the end of the line
    dtparam=spi=on

    Save and exit.

    Reboot your pi.
    sudo reboot

    Enjoy using SPI. (Source)

    3.Downloading the files

    Details:

    You have 2 options. wget and git-clone. I'll start with:

    a. git-clone

    If you don't have git-clone you need to install the git tools. (Yes, git is related to github)
    sudo apt-get install git

    After you installed git you simply navigate to the folder that you wish to install the program and type:
    sudo git-clone https://github.com/mysensors/Raspberry.git

    This will download a zip, unarchive it and.. It does all the jobs for you.

    b. wget

    Some ppl are old-school and go the hard way or they just enjoy it done this way.

    Navigate to the folder that you wish to install the program and type:
    wget https://github.com/mysensors/Raspberry/archive/master.zip (this will download you the zip)

    Unzip the file

    If you don't have unzip installed just type
    sudo apt-get install unzip

    unzip master.zip -d /home/pi/Raspberry (you can specify any directory that you want instead of the /home/pi/Raspberry)

    4.Edit and compile what you downloaded

    In the Raspberry folder you have some files and some folders.
    The majority of ppl (including me) forget to complile the libs for the NRF24l01.
    This is the library provided by [TMRH20]{http://tmrh20.github.io} (He has some interesting stuff there including an audio library for NRF24l01.)
    Back to our stuff.
    Go to the Raspberry folder then into librf24-bcm.
    cd Raspberry/librf24-bcm/

    Type
    make

    Go back to the Raspberry folder
    cd ..

    Type
    make
    5.Connecting the NRF

    Mister TMRH20 tells us that we need to connect the NRF24l01 this way

    PIN		NRF24L01	RPI				RPi -P1 Connector
    1		GND			rpi-gnd			(25)
    2		VCC			rpi-3v3			(17)
    3		CE			rpi-gpio22		(15)
    4		CSN			rpi-gpio8		(24)
    5		SCK			rpi-sckl		(23)
    6		MOSI		rpi-mosi		(19)
    7		MISO		rpi-miso		(21)
    8		IRQ			Not Connected
    

    Connect everything like that except for the CE pin

    Run the PiGatewaySerial
    ./PiGatewaySerial

    It shoud prin something like this:

    Starting PiGatewaySerial...
    Protocol version - 1.4
    Created PTY '/dev/pts/1'
    Gateway tty: /dev/ttyMySensorsGateway
    ================ SPI Configuration ================
    CSN Pin          = CE0 (PI Hardware Driven)
    CE Pin           = Custom GPIO25
    Clock Speed      = 8 Mhz
    ================ NRF Configuration ================
    STATUS           = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
    RX_ADDR_P0-1     = 0xe7e7e7e7e7 0xc2c2c2c2c2
    RX_ADDR_P2-5     = 0xff 0xc4 0xc5 0xc6
    TX_ADDR          = 0xe7e7e7e7e7
    RX_PW_P0-6       = 0x00 0x00 0x20 0x00 0x00 0x00
    EN_AA            = 0x3b
    EN_RXADDR        = 0x07
    RF_CH            = 0x10
    RF_SETUP         = 0x23
    CONFIG           = 0x0e
    DYNPD/FEATURE    = 0x3f 0x06
    Data Rate        = 250KBPS
    Model            = nRF24L01+
    CRC Length       = 16 bits
    PA Power         = PA_LOW
    

    Look at line 7 CE Pin = Custom GPIO25
    Connect the CE pin where it says you should.

    Here are some pictures with the GPIO connector on the rPi.
    https://www.google.ro/search?q=raspberry+pi+gpio&tbm=isch

    G 1 Reply Last reply
    4
    • Vladut GrecuV Offline
      Vladut GrecuV Offline
      Vladut Grecu
      wrote on last edited by Vladut Grecu
      #2

      Here is a script I made that does all the things above
      RasNRF-GPIO.sh
      Tell me how it went. Did it helped you? Did you found a bug? Any input, bad or good is appreciated.

      B 1 Reply Last reply
      1
      • Vladut GrecuV Vladut Grecu

        Here is a script I made that does all the things above
        RasNRF-GPIO.sh
        Tell me how it went. Did it helped you? Did you found a bug? Any input, bad or good is appreciated.

        B Offline
        B Offline
        blksun813
        wrote on last edited by blksun813
        #3

        @Vladut-Grecu

        The instructions didn't work for me until I did a sudo make install in the librf24-bcm folder. After the libraries were installed, I was able to make the PiGateway and PiGatewaySerial executables.
        Also, PiGatewaySerial will only run as root (or sudo).

        Thanks for the instructions, it was a great starting point! Now to install a controller....

        1 Reply Last reply
        0
        • n3roN Offline
          n3roN Offline
          n3ro
          wrote on last edited by n3ro
          #4

          Hey folks,

          big THX for the tut.

          But i have some problems after starting the GW.

          My output is only:

          ./PiGatewaySerial
          Starting PiGatewaySerial...
          Protocol version - 1.4
          Created PTY '/dev/pts/1'
          Gateway tty: /dev/ttyMySensorsGateway
          check wires

          and a 100% CPU Load.

          regards,
          n3ro

          issue in GIT:
          https://github.com/mysensors/Raspberry/issues/11

          pimatic + MySensors + Homeduino + z-way
          https://github.com/n3roGit/MySensors_n3ro

          1 Reply Last reply
          0
          • n3roN Offline
            n3roN Offline
            n3ro
            wrote on last edited by
            #5

            No ideas?

            pimatic + MySensors + Homeduino + z-way
            https://github.com/n3roGit/MySensors_n3ro

            1 Reply Last reply
            0
            • Sander TeunissenS Offline
              Sander TeunissenS Offline
              Sander Teunissen
              wrote on last edited by
              #6

              the ttyMysensorsGateway can only be accessed as root (user root, group root).
              Other serialports seem to have the group "dialout" attached.

              I am running node-red which is unable the gateway and I guess this has to do with it. Anyone a solution ?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Andreas Maurer
                wrote on last edited by
                #7

                ? Are you using the code that is available on github now?

                This behavior was Change by Holger a month ago. You can configure the Groups in the makefile:


                The standard configuration will build the Serial Gateway with a tty name of
                '/dev/ttyMySensorsGateway' and PTS group ownership of 'tty' the PTS will be group read
                and write. The default install location will be /usr/local/sbin. If you want to change
                that edit the variables in the head of the Makefile.


                Sander TeunissenS 2 Replies Last reply
                0
                • A Andreas Maurer

                  ? Are you using the code that is available on github now?

                  This behavior was Change by Holger a month ago. You can configure the Groups in the makefile:


                  The standard configuration will build the Serial Gateway with a tty name of
                  '/dev/ttyMySensorsGateway' and PTS group ownership of 'tty' the PTS will be group read
                  and write. The default install location will be /usr/local/sbin. If you want to change
                  that edit the variables in the head of the Makefile.


                  Sander TeunissenS Offline
                  Sander TeunissenS Offline
                  Sander Teunissen
                  wrote on last edited by
                  #8

                  @Andreas-Maurer Thanks for the quick answer. I used the code from github. I am going to check your suggestions tonight. (right now I am at work ;-)

                  Sander.

                  1 Reply Last reply
                  0
                  • Roberto BrunialtiR Offline
                    Roberto BrunialtiR Offline
                    Roberto Brunialti
                    wrote on last edited by
                    #9

                    Sorry for my naive question: does it means I ca use a raspi as a nrd24l01 based gateway?

                    Sander TeunissenS 1 Reply Last reply
                    0
                    • Roberto BrunialtiR Roberto Brunialti

                      Sorry for my naive question: does it means I ca use a raspi as a nrd24l01 based gateway?

                      Sander TeunissenS Offline
                      Sander TeunissenS Offline
                      Sander Teunissen
                      wrote on last edited by Sander Teunissen
                      #10

                      @Roberto-Brunialti Yes. Works perfectly ! (apart from the root access ;-)
                      As stated by blksun813 you need to "sudo make install in the librf24-bcm folder". (add the sudo...)

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

                        I'm currently at work, but there's a question: will it run on orangepi? (bananapi-like clone of RPi)
                        I'll take a look at the code and try to manage... GPIOs are working almost the same (it's compatible).

                        Maybe if I make a diff-file of things changed, you will be able to merge it and do some 'ifs' so code will be clone-compatible?

                        Oh well... The library has -bcm in name so I guess it will be rather hard to get it to work...

                        :-)

                        1 Reply Last reply
                        0
                        • A Andreas Maurer

                          ? Are you using the code that is available on github now?

                          This behavior was Change by Holger a month ago. You can configure the Groups in the makefile:


                          The standard configuration will build the Serial Gateway with a tty name of
                          '/dev/ttyMySensorsGateway' and PTS group ownership of 'tty' the PTS will be group read
                          and write. The default install location will be /usr/local/sbin. If you want to change
                          that edit the variables in the head of the Makefile.


                          Sander TeunissenS Offline
                          Sander TeunissenS Offline
                          Sander Teunissen
                          wrote on last edited by
                          #12

                          @Andreas-Maurer

                          to run the gateway:
                          sudo ./PiGatewaySerial (without sudo I get the error below)

                          Could not create a symlink '/dev/ttyMySensorsGateway' to PTY! (13) Permission denied
                          

                          running:
                          ls -l ttyMySensorsGateway

                          gives the following:

                          lrwxrwxrwx 1 root root 10 May  7 17:27 ttyMySensorsGateway -> /dev/pts/2
                          

                          I checked the makefile and it says

                          TTY_GROUPNAME := tty

                          But it doesn't seem to do anything...Any ideas ?

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            Andreas Maurer
                            wrote on last edited by
                            #13

                            The symlink alwayshas 777. Everyone can use it.
                            Please have a look at /dev/pts/2 This device should have the configured groups.

                            Ok?

                            Sander TeunissenS 1 Reply Last reply
                            0
                            • A Andreas Maurer

                              The symlink alwayshas 777. Everyone can use it.
                              Please have a look at /dev/pts/2 This device should have the configured groups.

                              Ok?

                              Sander TeunissenS Offline
                              Sander TeunissenS Offline
                              Sander Teunissen
                              wrote on last edited by
                              #14

                              @Andreas-Maurer said:

                              The symlink alwayshas 777. Everyone can use it.
                              Please have a look at /dev/pts/2 This device should have the configured groups.

                              Ok?

                              Yes. Ok!
                              It works.
                              Thanks !

                              1 Reply Last reply
                              0
                              • SweebeeS Offline
                                SweebeeS Offline
                                Sweebee
                                wrote on last edited by
                                #15

                                I tested it on my Rpi B+ its working fine, but the cpu load is always 100%. Is this normal?

                                joaoabsJ 1 Reply Last reply
                                0
                                • Roberto BrunialtiR Offline
                                  Roberto BrunialtiR Offline
                                  Roberto Brunialti
                                  wrote on last edited by
                                  #16

                                  An other silly question: can I install a controller into the same raspberry pi (the one with this gateway and nrf )? Are all controllers suitable for such a configuration ?
                                  Thanks!

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    Andreas Maurer
                                    wrote on last edited by
                                    #17

                                    For my Point of view, every Controller which is able to use the Serial Gateway.

                                    1 Reply Last reply
                                    0
                                    • SweebeeS Sweebee

                                      I tested it on my Rpi B+ its working fine, but the cpu load is always 100%. Is this normal?

                                      joaoabsJ Offline
                                      joaoabsJ Offline
                                      joaoabs
                                      wrote on last edited by
                                      #18

                                      @Sweebee

                                      Same here. I'm afraid that with the PI at 100% there is no much use of this code becasue we can't do anything else...

                                      Strange that the PI that is much powerfull than an arduino gets so high CPU for something that an arduino nano can do...

                                      Could it be something that could be improved?

                                      Cheers,
                                      Joaoabs

                                      1 Reply Last reply
                                      0
                                      • A Offline
                                        A Offline
                                        Andreas Maurer
                                        wrote on last edited by
                                        #19

                                        I have no problem with it. fhem as controler and mysql as DB is running on the same PI.
                                        The Gateway is not even listed in "top"

                                        joaoabsJ 1 Reply Last reply
                                        0
                                        • A Andreas Maurer

                                          I have no problem with it. fhem as controler and mysql as DB is running on the same PI.
                                          The Gateway is not even listed in "top"

                                          joaoabsJ Offline
                                          joaoabsJ Offline
                                          joaoabs
                                          wrote on last edited by
                                          #20

                                          @Andreas-Maurer

                                          Do you mean you don't have any problems with the fact the CPU is at 100% or you simply don't have the same sympthom?

                                          Thanks for replying,
                                          Joaoabs

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


                                          6

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular