[Tutorial] Raspberry Pi NRF24l01 direct connection



  • 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 ?



  • ? 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.




  • @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.



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



  • @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...)



  • 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...



  • @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 ?



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

    Ok?



  • @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 !



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



  • 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!



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



  • @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



  • 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"



  • @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



  • Hi,

    I think the problem with the PiGatewaySerial showing as consuming 100% is not a real problem. I also see the CPU consuming 100% using the top utility, however as soon as you run another process, for example a user python script, on the Pi, you will notice that top will suddenly report that PiGatewaySerial is using only a few percent of the CPU.

    Cheers
    Richard



  • Hi! I want to use RPi as a controller, with direct radio connection and pimatic. I've followed both posts but not sure how to make it work together. I know @Vladut-Grecu is using the same configuration, could you please point me to the right direction?



  • Ok. It seems the gateway is working as i get the same final screen when I run it. But... does it has a verbose mode? How can I know If it is working? I tried with a test node, unfortunately it seems not working ... or simply it does'nt give any feedback...



  • I used this gateway on a wheezy debian (RPI2) for several months and everything was ok. I upgraded my raspbian to jessie, and then the CPU load was always 100%. So I try to revert to wheezy, but i have now the same problem : CPU stays at 100 % .

    So there must be a system configuration somewhere to improve this gateway and prevent it to use all the CPU.

    Do you have an idea ?

    Thanks

    **Solved **: see this post



  • Hi,
    I'm trying to setup a direct connection between domoticz and /dev/ttyMySensorsGateway
    Waiting for my hardware (no NRF24l01 attached yet), I'm actually playing around with the software part.
    I did install Domoticz and MySensorsGateway on the Pi and I'm getting a /dev/ttyMySensorsGateway symlink at boot time.

    The problem is that I can't see it on domoticz interface when trying to choose a serial port on "Mysensors gateway USB" device : only /dev/ttyAMA0 ....

    Is that because no NRF24 is connected or there is a specific configuration to make /dev/ttyMySensorsGateway appearing as a serial port (chown, udev ....)

    Thanks for your help



  • Hi everybody,
    I'm new in mysensors world and I would like to use my pi2 with direct connection to nrf24l01.
    There is a new release of the arduino library but I can't find the raspberry one.
    Somebody knows if it exists and where to find it ?

    I also tried to find an example of using raspberry as mqtt gateway without success, any ideabut was not able to find an example


  • Admin

    You could probably run the old one.

    Ideally I would like to have the same code-base for RPi but someone needs to help implement the HW-implementation-class.



  • Thanks hek, i'll try to use old code but I didn't find anything about raspberry as mqtt client gateway.
    If I succeed, and if not too late, i'll try to implement the new library


  • Admin

    If you do want to help out, have a look at the gateway-refactoring-branch. Opening up for different protocols over there (where MQTT should be one of them).

    https://github.com/mysensors/Arduino/tree/gateway-refactoring



  • hi everybody
    @hek are you going to support Rpi + rf24 direct connection? I were playing with https://github.com/mysensors/Raspberry a bit and works (I opened a pair of tickets) but needs to be updated.
    I also think that PiGateway should support MQTT I have created PiGatewayMQTT (It's just a prototype).
    What will be the future of https://github.com/mysensors/Raspberry repo? abandoned in favor of any kind of gateway-refactoring-branch ?

    thanks



  • (solved)
    Hi. Thanks a lot for this implentation and the helpful posts here!

    I've got the gateway working with a tmp75 temperature sensor on an arduino. The nrf24 is sitting on the raspberry directly (CE pin 22), as a controller i'm using PiMatic. It works very nicely!

    There is one small problem however. The PiGatewaySerial will only work if i have called PiGateway before (and closed it again). With working I mean picking up radio transmissions from my sensor node. Everything else seems normal (/dev/ttyPiGatewaySerial and radio details printout).

    The details of both configurations might give a clue:

    pi@raspberrypi ~/mysensors_rpi $ sudo ./PiGateway
    Starting Gateway...
    ================ 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     = 0xa8a8e1fc00 0xa8a8e1fc00
    RX_ADDR_P2-5     = 0xff 0xc4 0xc5 0xc6
    TX_ADDR          = 0xe7e7e7e7e7
    RX_PW_P0-6       = 0x20 0x20 0x20 0x00 0x00 0x00
    EN_AA            = 0x3b
    EN_RXADDR        = 0x06
    RF_CH            = 0x4c
    RF_SETUP         = 0x23
    CONFIG           = 0x0e
    DYNPD/FEATURE    = 0x3f 0x06
    Data Rate        = 250KBPS
    Model            = nRF24L01+
    CRC Length       = 16 bits
    PA Power         = PA_LOW
    [CALLBACK]0;0;3;0;14;Gateway startup complete.
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    [CALLBACK]4;0;1;0;0;22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    

    after closing PiGateway and opening PiGatewaySerial i get this:

    pi@raspberrypi ~/mysensors_rpi $ sudo ./PiGatewaySerial
    Starting PiGatewaySerial...
    Protocol version - 1.4
    Created PTY '/dev/pts/3'
    Gateway tty: /dev/ttyMySensorsGateway
    ================ SPI Configuration ================
    CSN Pin          = CE0 (PI Hardware Driven)
    CE Pin           = Custom GPIO22
    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     = 0xa8a8e1fc00 0xa8a8e1fc00
    RX_ADDR_P2-5     = 0xff 0xc4 0xc5 0xc6
    TX_ADDR          = 0xe7e7e7e7e7
    RX_PW_P0-6       = 0x20 0x20 0x20 0x00 0x00 0x00
    EN_AA            = 0x3b
    EN_RXADDR        = 0x06
    RF_CH            = 0x4c
    RF_SETUP         = 0x23
    CONFIG           = 0x0e
    DYNPD/FEATURE    = 0x3f 0x06
    Data Rate        = 250KBPS
    Model            = nRF24L01+
    CRC Length       = 16 bits
    PA Power         = PA_LOW
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.9
    read: 4-4-0 s=0,c=1,t=0,pt=7,l=5:22.8
    

    Notice how the CE pins of both SPI configurations are different!

    I'm at the point that i want to daemonize the gateway. Which in fact i did, but the same problem persists. Before i hack the startup script to first run and close PiGateway before PiGatewaySerial, i was hoping that someone has an idea what i'm doing wrong.

    Thanks in advance!

    solved!
    I have two RPIs (a Pi 2 B and a Pi B+), which both worked with the pyRF24 lib of TMRh20, so when i had a look in the source of the radio initialization of PiGatewaySerial and found this:

    #ifdef __PI_BPLUS
    	gw = new MyGateway(RPI_BPLUS_GPIO_J8_15, RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ, 1);
    #else
    	gw = new MyGateway(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ, 1);
    #endif	
    

    When i changed it to:

    #ifdef __PI_BPLUS
    	gw = new MyGateway(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ, 1);
    #else
    	gw = new MyGateway(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ, 1);
    #endif	
    

    and recompiled the gateways,it all started to work. After powerup everything runs :).

    The Rpi that is connected now is the Pi 2 B. So i guess either i have my nrf25 wired differently then defined in this lib, or the precompiler was thinking i have a B+ connected. Or both.
    I will find out when i get this also working on my B+.



  • Hi all,

    I just followed the guide in the 1ste post, but i'm not able to compile this correctly.
    Here's the output:

    g++ -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -mtune=arm1176jzf-s -march=arm                                                                  v6zk -D BCM2835_PERI_BASE=0x -c RF24.cpp
    gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -mtune=arm1176jzf-s -march=arm                                                                  v6zk -D BCM2835_PERI_BASE=0x -c bcm2835.c
    bcm2835.c: In function ‘bcm2835_init’:
    bcm2835.c:1207:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1208:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1209:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1210:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1211:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1212:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1213:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1214:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1228:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1232:81: error: invalid suffix "x" on integer constant
    bcm2835.c:1236:81: error: invalid suffix "x" on integer constant
    bcm2835.c:1239:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1242:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1246:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1249:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1253:79: error: invalid suffix "x" on integer constant
    Makefile:52: recept voor doel 'bcm2835.o' is mislukt
    make: *** [bcm2835.o] Fout 1
    g++ -c -o MyGateway.o MyGateway.cpp -Wall -Ofast -mfpu=vfp -lpthread -g -D__Raspberry_Pi -mfloat-abi=hard -mtune=arm1176jzf-s -D_TTY_NAME=\"/dev/ttyMySensorsGateway\" -D_TTY_GROUPNAME=\"tty\" -march=armv6zk -I. -Ilibrf24-bcm/
    g++ -c -o MySensor.o MySensor.cpp -Wall -Ofast -mfpu=vfp -lpthread -g -D__Raspberry_Pi -mfloat-abi=hard -mtune=arm1176jzf-s -D_TTY_NAME=\"/dev/ttyMySensorsGateway\" -D_TTY_GROUPNAME=\"tty\" -march=armv6zk -I. -Ilibrf24-bcm/
    g++ -c -o MyMessage.o MyMessage.cpp -Wall -Ofast -mfpu=vfp -lpthread -g -D__Raspberry_Pi -mfloat-abi=hard -mtune=arm1176jzf-s -D_TTY_NAME=\"/dev/ttyMySensorsGateway\" -D_TTY_GROUPNAME=\"tty\" -march=armv6zk -I. -Ilibrf24-bcm/
    g++ -c -o PiEEPROM.o PiEEPROM.cpp -Wall -Ofast -mfpu=vfp -lpthread -g -D__Raspberry_Pi -mfloat-abi=hard -mtune=arm1176jzf-s -D_TTY_NAME=\"/dev/ttyMySensorsGateway\" -D_TTY_GROUPNAME=\"tty\" -march=armv6zk -I. -Ilibrf24-bcm/
    g++ -c -o PiGateway.o PiGateway.cpp -Wall -Ofast -mfpu=vfp -lpthread -g -D__Raspberry_Pi -mfloat-abi=hard -mtune=arm1176jzf-s -D_TTY_NAME=\"/dev/ttyMySensorsGateway\" -D_TTY_GROUPNAME=\"tty\" -march=armv6zk -I. -Ilibrf24-bcm/
    g++ -o PiGateway MyGateway.o MySensor.o MyMessage.o PiEEPROM.o PiGateway.o -Wall -Ofast -mfpu=vfp -lpthread -g -D__Raspberry_Pi -mfloat-abi=hard -mtune=arm1176jzf-s -D_TTY_NAME=\"/dev/ttyMySensorsGateway\" -D_TTY_GROUPNAME=\"tty\" -march=ar                                                                  mv6zk -I. -Ilibrf24-bcm/ -lrf24-bcm
    /usr/bin/ld: cannot find -lrf24-bcm
    collect2: ld returned 1 exit status
    Makefile:60: recept voor doel 'PiGateway' is mislukt
    make: *** [PiGateway] Fout 1
    
    Done!
    

    I'm using the 2015-05-05-raspbian-wheezy version complete with:

    rpi-update
    apt-get update
    apt-get upgrade
    

    Can anyone tell me what is going wrong.

    Thx in advance.



  • I got it working, and by adding ser2net in the mix, you have a MySensors raspberry pi ethernet gateway.
    The trick is not to update the RPi, just use the latest image.

    Does anyone know if it is possible to connect the status LEDs to the RPi?



  • Hi @ericvdb ,
    could you please post your config for ser2net? I also tried to use my NRF24L01 connected to my RPi as ethernet gateway for MYSController, but all I got was an 'unable to bind port'.



  • in /etc/ser2net.conf i used:

    9003:raw:600:/dev/ttyMySensorsGateway
    

    where 9003 is the tcp port your controller needs to connect to.

    Remember, this allows only 1 connection, so if you want to play with multiple controllers, you can, however 1 at a time.



  • Don't see any difference to my old entry... but pasted yours and now it works. Thank you very much @ericvdb



  • you're welcome 😉



  • @Vladut-Grecu - Thanks very much for the tutorial!! After a bit of trial and error I was able to get the Pi reading my two nodes with very good reliability.

    I'm now trying to merge this RPi Direct Connection with the openHab With Serial Gateway that TimO was kind enough to post (http://forum.mysensors.org/topic/1194/tutorial-openhab-with-serial-gateway). I had openHab working well on the RPi using an Arduino nano serial gateway using that tutorial.

    Running PiGatewaySerial in a terminal window yields the proper readings from the Arduino nodes but when I try to have openHab recognize the serial port "/dev/ttyMySensorsGateway" instead of the "/dev/ttyUSB99@115200" used in the openHab tutorial I get messages from openHab saying it could not open serial port '/dev/ttyMySensorsGateway'...

    Just wondering if anyone else has tried to marry the two projects or has any suggestions. (Perhaps I should also post this in TimO's openHab thread...)



  • upload-3f496795-4ae3-4ed2-b533-3f5e9fd6283e

    Hi I am a beginner
    If I have something that's ok , I plugged in humidity and temperature sensor , and for what I have in front of ./PiGatewaySerial enter sudo ? ,
    how to make the data visible in Domoticz please help



  • whether in the / dev file must be named ttyMySensorsGeteway ? if so how it developed and what it should contain



  • Hi @hek

    I know that a lot if going on regarding the MySensors 1.6 but I would like to know the plans for the repo mysensors/Raspberry?

    Is there any plans to keep developing it of merging it with the main libraries?

    I would like to be able to run the latest version on my Pi and I'm more than willing to help making it possible 🙂

    Cheers


  • Admin

    Hi @Daniel-Oliveira,

    I've talked with @Anticimex and @thozza about it... We think it would be best to move the RPi build file and any eventual support libs into the main MySensors repo to keep it in sync with the rest .

    Not sure if @thozza has begun working on some autoconf script or not (did you?). But I imagine he'd appreciate any help you can contribute with.



  • @jelluz
    I have got he sme configuration between Arduiono et a PIGATEWAYSERIAL ?
    How do you declare it into a controler like Pimatic (you says that it works fine)
    Tkd for your advice



  • I'am trying to get this working on my Raspberry Pi 2 B with Raspbian but when using the setup.sh command I get this error:

    bcm2835.c: In function ‘bcm2835_init’:
    bcm2835.c:1207:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1208:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1209:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1210:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1211:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1212:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1213:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1214:28: error: invalid suffix "x" on integer constant
    bcm2835.c:1228:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1232:81: error: invalid suffix "x" on integer constant
    bcm2835.c:1236:81: error: invalid suffix "x" on integer constant
    bcm2835.c:1239:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1242:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1246:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1249:83: error: invalid suffix "x" on integer constant
    bcm2835.c:1253:79: error: invalid suffix "x" on integer constant
    Makefile:52: recipe for target 'bcm2835.o' failed
    make: *** [bcm2835.o] Error 1

    Any idea what is going wrong? Thanks in advance!



  • @Mediacj I too had this error. The only way I was ever to solve this was to take a fresh image of Wheezy and start from scratch there. No sudo apt-get updated/upgrade until after I built the lib.



  • Thanks for your answer, I am going to try that this weekend.



  • Hello everyone! Great work here! I see this is still running the 1.4 protocol, is that right? I was able to get this working but only my temp sensors would respond. Anything where I had to send data wouldn't work.

    Any chance of moving to 1.5 in the near future?

    Thanks!



  • It might be a stupid question, but I've been staring at my screen for hours now, and can't find the solution.
    How do i install/ connect this gatewatay in domoticz?

    I have a Raberry Pi (2) with domoticz installed, followd this tutorial and connected the NRF24l01 directly to the gpio, and according to the printout everything works.

    So took a Arduino Uno, connected a magnetic doorsensor and a NRF24l01 and uploaded the right sketch, all ok and it even seems that the Raspberry is receiveing the data
    pigateway.png

    But what kind of gateway do I select in Domoticz?
    When I select Mysensors USB gateway I can't choose a serial port (seem legit since there is no usb connected), what hardware do I select??


  • Mod

    @ArieKanarie Mysensors USB gateway is correct. I think you need to perform the steps mentioned in section "Enable the gateway for use with Domoticz" at http://forum.mysensors.org/topic/2437/step-by-step-procedure-to-connect-the-nrf24l01-to-the-gpio-pins-and-use-the-raspberry-as-a-serial-gateway?page=1



  • @mfalkvidd said in Step-by-step procedure to connect the NRF24L01 to the GPIO pins and use the Raspberry as a Serial Gateway.:

    @Eawo Yes, it should work. I ran Domoticz and MySensors Gateway on my Raspberry Pi 1 when I first tried MySensors. If I remember correctly I had to connect CE to pin 15 instead of 22 but I am not sure why. Try using the same connections as on your Raspberry Pi 2 first, and switch CE pin if you get "check wires". Please report back here how it goes, so I can add the necessary information to the original post.

    For what it's worth, this is correct. I'm currently running on a Pi 1 and put CE on 15.

    I followed these instructions and it worked perfectly with no fuss: http://forum.mysensors.org/topic/1151/tutorial-raspberry-pi-nrf24l01-direct-connection



  • @mfalkvidd Thanks you very much sir!



  • make file has changes and there is no more librf24-bcm. Refer to the readme on the git and follow them



  • Hello all,
    I hope someone can help with this.

    Is there any way to run the generated ./PiGatewaySerial application in the background? I've got mine to work perfectly but only if I SSH into my Pi and execute the app using "sudo ./PiGatewaySerial". I'm looking to run this as a background service/application. Whichever is easier.

    Thanks in advance



  • Hi

    the easiest way is to run directly in background:

    nohup sudo python script.py &
    

    or - run script as a service and use it as other services, but above is the easiest.

    Adam



  • This is working with latest mysensors library ?


  • Admin

    @Fat-Fly
    MySensors is now natively supported to run on Raspberry. See here for instruction on how to build:
    https://www.mysensors.org/build/raspberry


Log in to reply
 

Suggested Topics

54
Online

11.4k
Users

11.1k
Topics

112.6k
Posts