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


  • Mod

    Note: This guide is only applicable to MySensors 1.x. For MySensors 2, use this guide.

    I noticed that a step-by-step procedure to connect the NRF24L01 to the GPIO pins and use the Raspberry as a Serial Gateway was listed in the document for MySensors 1.6.

    Since I have three gateways configured this way, and I need to set up 3 more for covering different offices around the world, and I had already written the instructions in Swedish for Datormagazin, I thought I'd help out.

    This is the first draft. Any feedback is welcome.


    INTRODUCTION
    The radio module NRF24L01+ is cheap and power efficient, but it is unable to communicate with regular wifi. The bridge between NRF24L01+ nodes and the "computer world" is called a Gateway. You can use other types of gateways, but connecting the NRF24L01+ module directly to the Raspberry Pi is a simple and cheap alternative.

    Wiring Things Up
    Connect the NRF20L01+ radio module to the Raspberry Pi like this:
    raspi_mysensors[1].png

    Raspberry Pi NRF24L01+ Color
    6 / GND GND Black
    1 / 3.3V DC VCC Red
    22 / GPIO25 CE Orange
    24 / GPIO 8 CSN/CS Yellow
    23 / GPIO11 / SPI_CLK SCK Green
    19 / GPIO10 / SPI_MOSI MOSI Blue
    21 / GPIO9 / SPI_MISO MISO Violet

    The IRQ pin on NRF24L01 is not currently used.

    For a comprehensive view of the Raspberry Pi pins, see http://pinout.xyz/

    You should also connect a decoupling capacitor to the radio. See this guide.

    COMPILING THE GATEWAY
    Login to your Raspberry Pi (using SSH or open a terminal on the graphical console) and run these commands:

    git clone https://github.com/TMRh20/RF24.git
    cd RF24
    make all && sudo make install
    cd ..
    
    git clone https://github.com/mysensors/Raspberry.git
    cd Raspberry
    make all && sudo make install
    

    If you get the following error:

    pi@raspberrypi ~/RF24 $ make all && sudo make install
    g++ -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -mtune=arm1176jzf-s -march=armv7-a -D BCM2835_PERI_BASE=0x -c RF24.cpp
    gcc -Wall -fPIC -Ofast -mfpu=vfp -mfloat-abi=hard -mtune=arm1176jzf-s -march=armv7-a -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
    
    

    You've probably run into the problem discussed in this thread. People have had luck with different solutions. The simplest is to make the following change to ~/Raspberry/librf24-bcm/Makefile

    #IOBASE := $(shell cat /proc/iomem | grep bcm2708_vcio | cut -f 1 -d "-")
    IOBASE := 3F000000
    

    VERIFY THE GATEWAY
    Run sudo /usr/local/sbin/PiGatewaySerial. The output should look like this:

    pi@raspberrypi ~/Raspberry $ sudo /usr/local/sbin/PiGatewaySerial
    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            = 0x4c
    RF_SETUP         = 0x23
    CONFIG           = 0x0e
    DYNPD/FEATURE    = 0x3f 0x06
    Data Rate        = 250KBPS
    Model            = nRF24L01+
    CRC Length       = 16 bits
    PA Power         = PA_LOW
    

    If the NRF24L01+ isn't correctly wired, the following error will be shown

    pi@raspberrypi ~ $ sudo /usr/local/sbin/PiGatewaySerial
    Starting PiGatewaySerial...
    Protocol version - 1.4
    Created PTY '/dev/pts/2'
    Gateway tty: /dev/ttyMySensorsGateway
    check wires
    

    If this happens, double-check your wiring and correct any problems. Press Ctrl+Z and type

    sudo killall PiGatewaySerial
    

    to get rid of the non-functioning Gateway. Then run sudo /usr/local/sbin/PiGatewaySerial again

    If all is well, exit PiGatewaySerial by pressing Ctrl+C. Then run

    sudo /etc/init.d/PiGatewaySerial start
    

    to start the gateway as a background process. Verify that it started correctly by running

    sudo cat /dev/ttyMySensorsGateway
    

    You should see the message "Gateway startup complete". Exit by typing Ctrl+C.

    MAKE THE GATEWAY AUTOSTART
    To make sure the Gateway is started when your Raspberry Pi boots up, run the following command:

    sudo make enable-gwserial
    

    Enable the gateway for use with Domoticz
    Domoticz (and maybe other home automation systems) has trouble reading from the default path created by PiGatewaySerial. You might need to run the following command:

    sudo ln -s /dev/ttyMySensorsGateway /dev/ttyUSB20
    

    And change /etc/rc.local from this

    exit 0
    
    

    to this

    ln -s /dev/ttyMySensorsGateway /dev/ttyUSB20
    exit 0
    
    

    OTHER NOTES

    • The 3.3V power on the Raspberry Pi is rated for a maximum of 50mA. A regular NRF24L01+ only needs 15mA, but if you are using a power amplified version you might exceed what the Raspberry Pi can output. In that case, an external power supply might be required. If you use an external power source gnd must be connected to the Raspberry Pi's gnd.

    • Connecting the NRF24L01+ directly to your Raspberry Pi will prevent you from using the Raspberry Pi's gpio ports for other things, like a Z-wave board.

    • A user experienced slow data transfer compared to USB-to-Serial(ttl)<-->MySensors Gateway connection, especially on OTA firmware update. If you think this will cause a problem for you, an ethernet gateway might be a better alternative.

    As always, I stand on the shoulders of giants. Related posts:

    TROUBLESHOOTING
    If you get this error

    pi@Domoticz3:~/Raspberry$ sudo /etc/init.d/PiGatewaySerial start
    [....] Starting PiGatewaySerial (via systemctl): PiGatewaySerial.serviceFailed to start PiGatewaySerial.service: Unit PiGatewaySerial.service failed to load: No such file or directory.
     failed!
    

    or this error

    pi@raspberrypi ~ $ sudo /usr/local/sbin/PiGatewaySerial
    sudo: /usr/local/sbin/PiGatewaySerial: command not found
    

    you have probably forgotten to run sudo make install. Read the instructions again, and follow them this time πŸ™‚ User @sineverba reported that a reboot of the Pi after running make install helped.



  • Great and simple.
    Is connecting the nrf directly to the pi causes any problems and u need to restart it ?
    Thanks.



  • @ahmedadelhosni said:

    Is connecting the nrf directly to the pi causes any problems and u need to restart it ?

    No, I have not had any big problems. The problem may only be the nrf24l01+ - I had to have a few changed plus fix the con to make it work. Wiring could be an issue. Also pay attention to CE pin.
    CE Pin = Custom GPIO25 (I have Custom GPIO22) - this can be changed by the constructor

    Excellent write-up


  • Plugin Developer

    Very nice writeup.

    One thing that comes to mind is, the latest rasbian Jessie uses systemd instead of init. It would be good if we could add a systemd unit file to the library and a description here how to use it.


  • Admin

    Thanks for the writeup @mfalkvidd. I'll add it to the main site when updating for the 1.6 release.

    If someone feel comfortable merging the RPi specific code to the MySensors library in the development branch, let me know. Would've been nice to have one codebase as the RPi code has diverged from Arduino quite a bit since it was created.

    A configure/autoconf is also something I'd need help with.



  • Great write-up! Should we consider instructions on how to create an init.d start/stop script so it can run as a daemon? I've done this, however, I'm having a hard time getting the output to log to syslog. (would be nice for monitoring/diagnostics purposes) The logging doesn't happen until I stop/kill the service.

    pi@homeauto01 ~ $ cat /etc/init.d/PiGatewaySerial
    #! /bin/sh
    # /etc/init.d/PiGatewaySerial
    
    ### BEGIN INIT INFO
    # Provides: PiGatewaySerial
    # Required-Start: $all
    # Required-Stop:
    # Should-Start:
    # Should-Stop:
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start and stop PiGatewaySerial
    # Description: PiGatewaySerial
    ### END INIT INFO
    
    
    # The following part carries out specific functions depending on arguments.
    case "$1" in
      start)
        echo "Starting PiGatewaySerial"
        /root/Raspberry/PiGatewaySerial 2>&1 | logger &
        ;;
      stop)
        echo "Stopping PiGatewaySerial"
        killall PiGatewaySerial
        ;;
      *)
        echo "Usage: /etc/init.d/PiGatewaySerial {start|stop}"
        exit 1
        ;;
    esac
    
    exit 0
    

  • Plugin Developer

    Doesn't the provided init script in the library already have logging? I didn't get around to testing this setup after my initial attempt failed, so I might be wrong.

    https://github.com/mysensors/Raspberry/blob/master/initscripts/PiGatewaySerial


  • Hardware Contributor

    Excellent writeup, double plus plus good !!!




  • Plugin Developer

    @mfalkvidd I used direct NRF24l01+ with RPI long ago and I felt slow data transfer compare to USB-to-Serial(ttl)<-->MySensors Gateway connection. especially on OTA firmware update.


  • Mod

    @jkandasa said:

    @mfalkvidd I used direct NRF24l01+ with RPI long ago and I felt slow data transfer compare to USB-to-Serial(ttl)<-->MySensors Gateway connection. especially on OTA firmware update.

    Thanks. Let's add that under the other notes section.



  • This is a very good work !

    Is there anything in place for RFM69 ? Would it be difficult to port the code from arduino to rpi ? (I have never coded on RPI).

    Also, do you think any performance difference is involved in managing the radio directly from the RPI, compared to having a dedicated atmega/arduino ? Especially if a controller solution is already running on it?


  • Hardware Contributor

    My experience: the Raspberry 2 indicates usually less then 1% processor, with very occasional maximum peaks to 15%. So I would say, Raspberry 2: no worries. My setup is Domoticz + NRF24based gateway on the same Raspi.


  • Mod

    My experience is on the same level as @GertSanders's - very low cpu usage.

    I don't use RFM69 so unfortunately I have no knowledge about the feasibility to connect it directly to the Raspberry Pi.



  • @martinhjelmare said:

    Doesn't the provided init script in the library already have logging? I didn't get around to testing this setup after my initial attempt failed, so I might be wrong.

    https://github.com/mysensors/Raspberry/blob/master/initscripts/PiGatewaySerial

    Ugh! Correct. Also, @mfalkvidd did cover this with his "MAKE THE GATEWAY AUTOSTART" section.....If I only could read! I will test this soon to see how the logging works.

    Finally, by enabling ser2net and adding something like this to /etc/ser2net.conf:

    5003:raw:600/dev/ttyMySensorsGateway
    

    ....you have yourself an Ethernet Gateway! Great stuff! Thanks again!


  • Plugin Developer

    @Myna said:

    This is a very good work !

    Is there anything in place for RFM69 ? Would it be difficult to port the code from arduino to rpi ? (I have never coded on RPI).

    Also, do you think any performance difference is involved in managing the radio directly from the RPI, compared to having a dedicated atmega/arduino ? Especially if a controller solution is already running on it?

    I've got no experience myself with rfm69 yet, but I've been thinking about it and searching the web says it should work, connecting the rfm69 to the raspberry pi, for example here:
    https://github.com/abouillot/HomeAutomation/tree/master/piGateway

    There are also custom pcbs for simplicity, don't know if it's tested though:
    https://oshpark.com/profiles/thinkpeace



  • Perhaps re-word the last note from:

    A user experienced data transfer compare to USB-to-Serial(ttl)<-->MySensors Gateway connection. especially on OTA firmware update. If you think this will cause a problem for you, an ethernet gateway might be a better alternative.

    to:

    A user notes that data transfer speeds are comparable to that of a USB-to-Serial(ttl)<-->MySensors Gateway connections. If you think this may be an issue for your application (e.g. OTA firmware updates), an ethernet gateway might be a better alternative.

    thanx,
    JpS


  • Mod

    @soward that wasn't quite the feedback I got, but what I wrote didn't make much sense either so I have corrected it now. Thanks!



  • I have a trouble with CPU utilization when I start the gateway : 100% all the time. I use Jessie and not Wheezy on a RPI 2. Does someone can help me to troubleshoot this problem ? I have not add a decoupling capacitor , can it be the reason ?

    Solved : see this post



  • @minscof said:

    I have a trouble with CPU utilization when I start the gateway : 100% all the time. I use Jessie and not Wheezy on a RPI 2. Does someone can help me to troubleshoot this problem ? I have not add a decoupling capacitor , can it be the reason ?

    This happened to me as well, I mixed up the boards I had at home and discover later it was a B+ and not a RPI2 πŸ™‚ Maybe you've made the same mistake?


  • Mod

    @minscof got an answer in this thread: http://forum.mysensors.org/topic/2367/pigatewayserial-using-interrupts/3
    The high cpu usage will go away as soon as you start your controller (or something else that reads from the tty the gateway creates).



  • Is it possible to use NRF24L01+PA+LNA Antenna version or is it to power hungry? Do i have to change something in the code?



  • @Eawo If you look at the excellent original post from @mfalkvidd above:

    The 3.3V power on the Raspberry Pi is rated for a maximum of 50mA. A regular NRF24L01+ only needs 15mA, but if you are using a power amplified version you might exceed what the Raspberry Pi can output. In that case, an external power supply might be required.

    I don't believe that you will need to make any changes to code.



  • My friend also started with mysensors and i gave him my old raspberry with the 26 pin gpio. Can he also use this guide? Also if it possible how do u wire it? Im just a beginner so i ask stupid questions. maybe serial gateway is the way to go but we are waiting for arduino's


  • Mod

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



  • I get stuff like

    read: 2-2-0 s=255,c=0,t=17,pt=0,l=3:1.5
    send: 2-194-1-0 s=255,c=0,t=17,pt=0,l=3,st=fail:1.5
    read: 2-2-0 s=255,c=3,t=6,pt=1,l=1:0
    send: 2-194-1-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
    read: 2-2-0 s=1,c=1,t=2,pt=2,l=2:1
    send: 2-194-1-0 s=1,c=1,t=2,pt=2,l=2,st=fail:1
    

    from 'PiGatewaySerial' but no results on the Serial Port. Any idea what i'm doing wrong?



  • Somehow the node thought it is node id 194 and a repeater...
    I hacked in node id 0 and it worked. But it even works slower then the arduino serial gateway.


  • Mod

    In http://forum.mysensors.org/topic/2305/nrf24l01-rpi2-direct-connection-problem/1 an user also got node id 194. Maybe the discussion there can help?



  • Hi
    something is missing..

    Is there a problem with the repository
    Tks a lot for your job!

    pi@domoticjp ~ $ sudo git clone https://github.com/mysensors/Raspberry.git
    Cloning into 'Raspberry'...
    remote: Counting objects: 273, done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 273 (delta 0), reused 0 (delta 0), pack-reused 270
    Receiving objects: 100% (273/273), 215.00 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (114/114), done.
    Checking connectivity... done.
    pi@domoticjp ~ $ cd Raspberry/librf24-bcm
    -bash: cd: Raspberry/librf24-bcm: No such file or directory

  • Mod

    Ah yes, the guide became invalid yesterday when a PR was merged. I'll update the guide, thanks for noticing.

    Information about how to get the rf library is available in the readme in the Raspberry folder if you want to get going.



  • I got it working on my rb2 but i got 100% of cpu ussage.

    I read a lot of post about this but i cant found a solution.

    Some one know how to fix this?



  • @jpbabou said:

    Hi
    something is missing..

    Is there a problem with the repository
    Tks a lot for your job!

    pi@domoticjp ~ $ sudo git clone https://github.com/mysensors/Raspberry.git
    Cloning into 'Raspberry'...
    remote: Counting objects: 273, done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 273 (delta 0), reused 0 (delta 0), pack-reused 270
    Receiving objects: 100% (273/273), 215.00 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (114/114), done.
    Checking connectivity... done.
    pi@domoticjp ~ $ cd Raspberry/librf24-bcm
    -bash: cd: Raspberry/librf24-bcm: No such file or directory
    

    Please go ahead and install the rf24 library from https://github.com/TMRh20/RF24
    The rest should be the same



  • @msantang said:

    I got it working on my rb2 but i got 100% of cpu ussage.

    I read a lot of post about this but i cant found a solution.

    Some one know how to fix this?

    The 100% cpu usage is probably due to the style of receiving new messages from rf24/serial port.
    The current state is that the PiSerialGateway tries to poll data in a endless loop from rf24/serial.
    This could maybe fixed with using the interrupt of the nrf24l01+ to signal new data and reading data from the serial in blocking mode.
    I want to solve this but using interrupts on the RPi isn't that trivial.


  • Mod

    http://forum.mysensors.org/topic/2367/pigatewayserial-using-interrupts/2 has information on how to use interrupts. I haven't tried it myself though.



  • @mfalkvidd said:

    http://forum.mysensors.org/topic/2367/pigatewayserial-using-interrupts/2 has information on how to use interrupts. I haven't tried it myself though.

    Oh yeah, thanks for the hint @Bens got the exact same problem and seem to solved the rf24 part already. I hope he gets back online and shares his results. πŸ™‚



  • Hi all,
    I'm following this thread and have upgraded to MySensors v1.5 and get the following error. Version mismatch.

    It looks like the Protocol version is 1.4.

    Does the Raspberry MySensors Gateway support v1.5 or only v1.4? Any ideas on how to fix?

    upload-27647566-60ff-4341-97aa-4d1186e5e670



  • @den2k said:

    Hi all,
    I'm following this thread and have upgraded to MySensors v1.5 and get the following error. Version mismatch.

    It looks like the Protocol version is 1.4.

    Does the Raspberry MySensors Gateway support v1.5 or only v1.4? Any ideas on how to fix?

    Up until now, MySensors v1.4 only for nrf24l01+ direct connection.
    Did you upgrade the GW or the sensors or both ?


  • Admin

    Protocol version hasn't changed since 1.4
    https://github.com/mysensors/Raspberry/blob/master/MyMessage.h#L41

    So you must have some other problem.. As you can see you only get zeroes in the log...


  • Hardware Contributor

    You can "fake" a later version (e.g, 1.5) on the Raspberry by changing the version code in the version.h file and recompiling the Gateway software.

    As far as I understand, the gateway will still pass the messages to the controller, even is there is a version mismatch message on the console.



  • @alexsh1 I know the sensors are on v1.5. As for the Raspberry Gateway, it looks like based on the info here, that is running v1.4.



  • @hek I'm running a custom 1Mhz build bootloader on a Pro Mini for the Sensor side. This was paired with the standard Serial Gateway running on another Pro Mini with v1.5 on both gateway and sensor. That setup was working. But I moved over to using the Pi gatway+nRF24+ radio and have this issue. I don't believe the hookup is the problem. I've seen the 0 readings before, and that usually meant node side issue or uninitiated Gateway. I have not changed the Node, so it must be the Pi gateway that is the problem. Any thoughts on what to test?



  • Noob question. Any one have an idea on solving the "Permission denied" error.

    upload-a7ed9c85-5b6b-4198-af00-909e1861374e



  • Solved my own problem. Using the following command did the trick.

    sudo chown -h pi:pi ttyUSB20



  • weird. Permission Denied problem again.

    What is the USER : GROUP that is needed for this to work?


  • Mod

    @den2k I think your best chance is to post in the Home Assistant category. I don't have any experience with Home Assistant unfortunately.


  • Mod

    @jpbabou said:

    Hi
    something is missing..

    Is there a problem with the repository
    Tks a lot for your job!

    pi@domoticjp ~ $ sudo git clone https://github.com/mysensors/Raspberry.git
    Cloning into 'Raspberry'...
    remote: Counting objects: 273, done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 273 (delta 0), reused 0 (delta 0), pack-reused 270
    Receiving objects: 100% (273/273), 215.00 KiB | 0 bytes/s, done.
    Resolving deltas: 100% (114/114), done.
    Checking connectivity... done.
    pi@domoticjp ~ $ cd Raspberry/librf24-bcm
    -bash: cd: Raspberry/librf24-bcm: No such file or directory
    

    The guide has been updated to reflect the updated in the MySensors Raspberry repository now. Thanks @jpbabou !


  • Plugin Developer

    @den2k

    Hi!

    Have you added the user that runs homeassistant to the dialout group? This group is usually owner of serial ports.

    Check default group of serial port (change for your port below) after connecting it:

    pi@martin-pi:~ $ ls -l /dev/ttyUSB0 
    crw-rw---- 1 root dialout 188, 0 dec 18 03:21 /dev/ttyUSB0
    

    Check groups that user pi is in:

    pi@martin-pi:~ $ groups pi
    pi : pi adm dialout cdrom sudo audio video plugdev games users input netdev spi i2c gpio
    

    If pi runs homeassistant, which should be the case, and is not in dialout, add pi to dialout:

    sudo adduser pi dialout
    

    Changing owner of a port will only work until you disconnect it. Default owner will be restored upon reconnect, if you haven't written a special udev rule.

    Edit:
    According to the readme in the mysensors raspberry repo (https://github.com/mysensors/Raspberry), the group of the device is tty. So you should probably use that, and not dialout. But you will know, when you check with ls -l.



  • @mfalkvidd Hi there and thanks for a great and super detailed step-by-step tutorial.

    I've got mine running in no time with your instructions, but after a couple of minutes I've got the following error:

    2015-12-30 20:51:30.356 Error: MySensors: Unhandled sensor (sub-type=32), please report with log!
    2015-12-30 20:52:01.390 Error: Serial Port closed!... Error: End of file
    2015-12-30 20:52:02.315 MySensors: retrying in 30 seconds...
    2015-12-30 20:52:31.319 MySensors: Using serial port: /dev/ttyUSB20
    2015-12-30 20:52:31.320 Error: MySensors: Error opening serial port!
    2015-12-30 20:52:32.321 MySensors: retrying in 30 seconds...
    2015-12-30 20:53:01.324 MySensors: Using serial port: /dev/ttyUSB20

    I also attached a partial screen capture showing that it was working before 8-)

    2015-12-30 21_18_13-Domoticz - Opera.png

    Any idea on why is this happening and how to solve it?

    Southern regards and happy new year to all!


  • Mod

    You are using a sensor type that your version of Domoticz doesn't support. What type os sensor is it? Which version of Domoticz are you using? Upgrading Domoticz might solve the problem (if the newer version supports this sub-type).



  • When I try to run the init.d script:

    sudo /etc/init.d/PiGatewaySerial start
    

    I get the following error:

    [....] Starting PiGatewaySerial (via systemctl): PiGatewaySerial.serviceFailed to start PiGatewaySerial.service: Unit PiGatewaySerial.service failed to load: No such file or directory.
     failed!
    

    No such file or directory.... Obviously a missing folder or file, but I am not savvy enough to debug this.... Any help appreciated..


  • Mod

    @Sander-Teunissen my guess is that you forgot the sudo make install part of the installation instructions.



  • @mfalkvidd Yesterday I stopped trying and shutdown the Pi. This morning I tried the same again and it works !!
    Pretty sure I haven't done anything else.
    Thanks anyway.

    Sander



  • Hello, If followed the instruction and everything seemed to work without any problem.
    However when I enter the command : sudo cat /dev/ttyMySensorsGateway
    I get the message : cat: /dev/ttyMySensorsGateway: No such file or directory
    Does anybody have any idea how to solve this ?


  • Mod

    @MrRikkie what output did you get when you ran sudo /etc/init.d/PiGatewaySerial start ?



  • @mfalkvidd said:

    sudo /etc/init.d/PiGatewaySerial start

    No output and no error message. Just a new command line.
    pi@raspberrypi ~ $ sudo /etc/init.d/PiGatewaySerial start
    pi@raspberrypi ~ $



  • When I

    ls -l ttyMySensorsGateway
    

    I get

    lrwxrwxrwx 1 root root 10 Jan  3 20:21 ttyMySensorsGateway -> /dev/pts/0
    

    It's all root. This results in all kinds of acessability issues. I followed all instructions exactly. Anyone any ideas how to change this ?

    Sander.


  • Plugin Developer

    @Sander-Teunissen

    Try writing a udev rule to set owner of the device (ttyMysensorsGateway) at boot. If you don't need to use the link you could write a rule that names the pts device to the same name every boot, I think. At least for usb devices this works. Haven't tried it in this particular case.


  • Mod

    @Sander-Teunissen said:

    When I

    ls -l ttyMySensorsGateway
    

    I get

    lrwxrwxrwx 1 root root 10 Jan  3 20:21 ttyMySensorsGateway -> /dev/pts/0
    

    It's all root. This results in all kinds of acessability issues. I followed all instructions exactly. Anyone any ideas how to change this ?

    The permissions for a soft link are not used (and if they were, any user would be allowed to do anything since everything is rwx). The permissions for the target is used instead. So it is the result of

    ls -l /dev/pts/0
    

    you need to worry about.



  • Hello @mfalkvidd , I read the topic again but I am a bit confused. Normally we have a sketch on the Arduino board to enable signing for example or implement our desired code. I don't understand how to edit this before compiling ?


  • Mod

    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.


  • Contest Winner

    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.


  • Contest Winner

    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 πŸ™‚



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


  • Mod

    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?



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



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



  • This post is deleted!


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


  • Mod

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



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



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


  • Plugin Developer

    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.


  • Hardware Contributor

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



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


  • Mod



  • Thanks @mfalkvidd - will check it out.



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



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



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



  • Hello, im just starting to set up some mysensors nodes and have already set up a gateway with nodemcu (esp).
    But to eliminate the number of devices i am thinking about moving the gateway directly to the Raspberry pi as mentioned in this thread. Is there any downsides (or upsides) by connecting the nrf24 chip directly to the RPI?

    And btw:
    "The radio module NRF24L01+ is cheap and power efficient, but it is unable to communicate with regular wifi."
    That is not entirely correct, the nrf24 can connecct to wifi and send TCP/IP packets with an arduino.



  • @alexsh1 No actually. I didn't want to go around and reprogram all my nodes, and I forgot to turn off my other gateway. That is what I was going to do next, but I've just been running it for a few hours with no problems (with a heap of nodes and another gateway a few metres away, all on the same channel).

    I then Home Assistant and tested out a few nodes, and now it sometimes breaks, but mostly works fine.

    All that being said, I've realised I need signing (I have a few electronic locks), so I'm going back to a hardware serial gateway. If anyone has got signing working I'd love to hear how - I had a look but couldn't figure it out and don't have much time to spare on it.



  • pi@Domoticz3:~/Raspberry$ sudo ./PiGatewaySerial
    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     = 0xa8--------------------------------
    RX_ADDR_P2-5     = 0xff 0xc-----------------
    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: 1-1-0 s=0,c=1,t=0,pt=7,l=5:16.1
    read: 1-1-0 s=0,c=1,t=23,pt=2,l=2:1022
    read: 1-1-0 s=1,c=1,t=23,pt=2,l=2:1023
    read: 1-1-0 s=2,c=1,t=23,pt=2,l=2:1021
    Received SIGINT^C
    Exiting...
    pi@Domoticz3:~/Raspberry$ sudo cat /dev/ttyMySensorsGateway
    cat: /dev/ttyMySensorsGateway: No such file or directory
    pi@Domoticz3:~/Raspberry$ sudo /etc/init.d/PiGatewaySerial start
    [....] Starting PiGatewaySerial (via systemctl): PiGatewaySerial.serviceFailed to start PiGatewaySerial.service: Unit PiGatewaySerial.service failed to load: No such file or directory.
     failed!
    pi@Domoticz3:~/Raspberry$
    

    Playing with a RPI 3 B and a NRF24+ radio I got this error message above.
    Running Jessie but with no luck...

    Anybody else got this problem?


  • Mod

    @Sander-Stolk did you run

    sudo make install
    

    ?
    What happens if you run

    sudo /usr/local/sbin/PiGatewaySerial
    

    ?



  • @mfalkvidd
    Tnx that worked but this is not in the tutorial I'm I right?

    If this happens, double-check your wiring and correct any problems. Press Ctrl+Z and type
    
    sudo killall PiGatewaySerial
    to get rid of the non-functioning Gateway. Then run sudo /usr/local/sbin/PiGatewaySerial again
    
    If all is well, exit PiGatewaySerial by pressing Ctrl+C. Then run
    
    sudo /etc/init.d/PiGatewaySerial start
    to start the gateway as a background process. Verify that it started correctly by running```

  • Mod

    Yes it is. See the section under
    COMPILING THE GATEWAY

    also, you ran sudo ./PiGatewaySerial instead of sudo /usr/local/sbin/PiGatewaySerial described in the instructions.


  • Mod

    I have added a
    TROUBLESHOOTING
    section in the original post to cover for this error. Hopefully it can help if someone else makes the same mistake.



  • Any thoughts on making a version for the 2.0 dev branch?

    I recently switched my in-progress builds to 2.0 and am in the process of "trying" to get my Raspberry Pi2 setup with OpenHab and Mosquito. And the idea of not having to have an ethernet gateway arduino in the mix is appealing to me.

    I would do it myself but I probably only have 3.275% of the required knowledge at this point


  • Mod

    I'm unfortunately at about the same level as you. I can compile stuff and do basic troubleshooting, but merging the dev branch with the gateway code is way out of my league.



  • @mfalkvidd said:

    I'm unfortunately at about the same level as you. I can compile stuff and do basic troubleshooting, but merging the dev branch with the gateway code is way out of my league.

    There is no way you are at 3.275% knowledge like me... I've seen many of your posts on here and you are at least a 4.532%... lol.... no honestly I've liked your posts and you seem very knowledgeable. You've got to be at least a 84.5% πŸ˜‰



  • Can somebody tell me how to change the channel after compiling and using the Gateway for a couple of days?
    Changing the channel in MyConfig.h in the dir Raspberry doesnt bother even after a reboot.
    Still 0x4c channel / 76 when I run the PiSerialGateway program.



  • @Sander-Stolk said:

    Can somebody tell me how to change the channel after compiling and using the Gateway for a couple of days?
    Changing the channel in MyConfig.h in the dir Raspberry doesnt bother even after a reboot.
    Still 0x4c channel / 76 when I run the PiSerialGateway program.

    Did you recompile the code after changing the channel?



  • @alexsh1 I did this after changeing the channel in MyConfig.h: make all && sudo make install
    Rebooted after that but no luck


  • Mod

    That should be sufficient but you could see if running make clean before make all helps.



  • @mfalkvidd I did the make clean and the make install and rebooted.
    Still 0x4c eq. 76

    Using username "pi".
    Server refused our key
    pi@192.168.1.14's password:
    ______                      _   _
    |  _  \                    | | (_)
    | | | |___  _ __ ___   ___ | |_ _  ___ ____
    | | | / _ \| '_ ` _ \ / _ \| __| |/ __|_  /
    | |/ / (_) | | | | | | (_) | |_| | (__ / /
    |___/ \___/|_| |_| |_|\___/ \__|_|\___/___|
    
    
    Last login: Sat Apr  9 18:41:17 2016 from 192.168.1.34
    
    Monday, 11 April 2016, 12:10:24 pm CEST
    Linux 4.1.18-v7+ armv7l GNU/Linux
    Uptime.............: 1 days, 17h29m13s
    Memory.............: 520336kB (Free) / 948056kB (Total)
    Load Averages......: 0.00, 0.01, 0.05 (1, 5, 15 min)
    Running Processes..: 97
    IP Addresses.......: 192.168.1.14
    
    pi@Domoticz3:~$ cd Raspberry/
    pi@Domoticz3:~/Raspberry$ cat MyConfig.h
    /*
     The MySensors library adds a new layer on top of the RF24 library.
     It handles radio network routing, relaying and ids.
    
     Created by Henrik Ekblad <henrik.ekblad@gmail.com>
     12/10/14 - Ported to Raspberry Pi by OUJABER Mohamed <m.oujaber@gmail.com>
    
     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
     version 2 as published by the Free Software Foundation.
    */
    
    #ifndef MyConfig_h
    #define MyConfig_h
    
    /***
     * Configure Sensor Network
     */
    #define RF24_CHANNEL       111             //RF channel for the sensor net, 0-127
    #define RF24_DATARATE      RF24_250KBPS   //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
    #define RF24_PA_LEVEL      RF24_PA_MAX    //Sensor PA Level == RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBM, and RF24_PA_MAX=0dBm
    #define RF24_PA_LEVEL_GW   RF24_PA_MAX  //Gateway PA Level, defaults to Sensor net PA Level.  Tune here if using an amplified nRF2401+ in your gateway.
    #define BASE_RADIO_ID      ((uint64_t)0xA8A8E1FC00LL) // This is also act as base value for sensor nodeId addresses. Change this (or channel) if you have more than one sensor network.
    
    // MySensors online examples defaults
    #define DEFAULT_CE_PIN 9
    #define DEFAULT_CS_PIN 10
    
    
    /***
     * Enable/Disable debug logging
     */
    #define DEBUG
    
    
    #ifdef __Raspberry_Pi
            #define vsnprintf_P vsnprintf
            #define snprintf_P snprintf
            #define PSTR(x) (x)
            #define printf_P printf
            #define strlen_P strlen
    #endif
    
    #endif
    pi@Domoticz3:~/Raspberry$ make clean
    rm -rf MyGateway MySensor MyMessage PiEEPROM PiGateway PiGatewaySerial MyGateway.o MySensor.o MyMessage.o PiEEPROM.o PiGateway.o PiGatewaySerial.o
    pi@Domoticz3:~/Raspberry$ make all
    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. -I/usr/local/include/RF24
    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. -I/usr/local/include/RF24
    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. -I/usr/local/include/RF24
    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. -I/usr/local/include/RF24
    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. -I/usr/local/include/RF24
    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=armv6zk -I. -I/usr/local/include/RF24 -lrf24-bcm
    g++ -c -o PiGatewaySerial.o PiGatewaySerial.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. -I/usr/local/include/RF24
    g++ -o PiGatewaySerial MyGateway.o MySensor.o MyMessage.o PiEEPROM.o PiGatewaySerial.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=armv6zk -I. -I/usr/local/include/RF24 -lrf24-bcm -lutil
    pi@Domoticz3:~/Raspberry$ sudo reboot
    
    Broadcast message from pi@Domoticz3 on pts/1 (Mon 2016-04-11 12:12:17 CEST):
    
    The system is going down for reboot NOW!
    
    pi@Domoticz3:~/Raspberry$
    Using username "pi".
    Server refused our key
    pi@192.168.1.14's password:
    ______                      _   _
    |  _  \                    | | (_)
    | | | |___  _ __ ___   ___ | |_ _  ___ ____
    | | | / _ \| '_ ` _ \ / _ \| __| |/ __|_  /
    | |/ / (_) | | | | | | (_) | |_| | (__ / /
    |___/ \___/|_| |_| |_|\___/ \__|_|\___/___|
    
    
    Last login: Mon Apr 11 12:10:24 2016 from 192.168.1.34
    
    Monday, 11 April 2016, 12:12:45 pm CEST
    Linux 4.1.18-v7+ armv7l GNU/Linux
    Uptime.............: 0 days, 00h00m25s
    Memory.............: 770952kB (Free) / 948056kB (Total)
    Load Averages......: 0.59, 0.16, 0.05 (1, 5, 15 min)
    Running Processes..: 100
    IP Addresses.......: 192.168.1.14
    
    pi@Domoticz3:~$ ls
    bash_scripts  domoticz  Dropbox-Uploader  Raspberry  RF24
    pi@Domoticz3:~$ sudo /etc/init.d/PiGatewaySerial start
    [ ok ] Starting PiGatewaySerial (via systemctl): PiGatewaySerial.service.
    pi@Domoticz3:~$ sudo /etc/init.d/PiGatewaySerial start
    [ ok ] Starting PiGatewaySerial (via systemctl): PiGatewaySerial.service.
    pi@Domoticz3:~$ sudo ln -s /dev/ttyMySensorsGateway /dev/ttyUSB20
    ln: failed to create symbolic link β€˜/dev/ttyUSB20’: File exists
    pi@Domoticz3:~$ sudo /usr/local/sbin/PiGatewaySerial
    Starting PiGatewaySerial...
    Protocol version - 1.4
    Created PTY '/dev/pts/2'
    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     = 0xa8a8e
    RX_ADDR_P2-5     = 0xff 0xc4 
    TX_ADDR          = 0xa8a8e1fc07
    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: 5-5-5 s=5,c=5,t=5,pt=0,l=0:
    version mismatch
    ^CReceived SIGINT
    Exiting...
    pi@Domoticz3:~$
    

  • Mod

    @Sander-Stolk I don't see a new make install in your output. Did you miss that or is the output just not included?

    make all compiles the code. The result is a binary file in the Raspberry folder
    make install copies the binary (and some scripts I think) from the Raspberry folder to the system folders.



  • Ok here's the deal to change the channel or other settings:

    cd Raspberry
    make clean
    make all
    sudo make install
    Done!



  • Does anyone know what this error is about?
    RPi2, NRF24l01, OSMC (Debian jessie), Domoticz v3.5051.

    osmc@osmc:~/Raspberry$ sudo make install
    Installing PiGatewaySerial to /usr/local/sbin
    Installing PiGateway to /usr/local/sbin
    Installing initscripts to /etc/init.d
    Installing syslog config to /etc/rsyslog.d
    Failed to restart rsyslog.service: Unit rsyslog.service failed to load: No such file or directory.
    Makefile:79: recipe for target 'install-initscripts' failed
    make: *** [install-initscripts] Error 6
    

    I can run the gateway even with the error, i can also add it to Domoticz and send/receive data.
    But after a few minutes i get a massive error in domoticz saying "(24) Too many files open" on every logentry and my domoticz loose connection to the Logitech mediaserver, remote Kodi hardware, mqtt server etc.

    osmc@osmc:~/Raspberry$ sudo ./PiGatewaySerial
    Starting PiGatewaySerial...
    Protocol version - 1.4
    Created PTY '/dev/pts/2'
    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     = 0xa8a8e1fc00 0xa8a8e1fc00
    RX_ADDR_P2-5     = 0xff 0xc4 0xc5 0xc6
    TX_ADDR          = 0xa8a8e1fc02
    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
    


  • Hi, is signing supported using this library? thanks.


  • Mod

    @cingolanifede the Raspberry Pi gateway does not support signing.



  • I'm looking for some help in getting "PiGatewaySerial" running properly. I am having no issue running "PiGateway" and receiving all data from a counter node I'm using for testing. When I try to run "PiGatewaySerial", only intermittent data appears. For this example, I have my counter sending increasing integers at 1 second intervals, and receives fewer than 1 in 25 through the "PiGatewaySerial" script. I previously had this working reliably on a RPi2, reading in the tty output and logging it to a file. Now, I cannot repeat that on either that device, nor the current RPi B+ I'm working with. I'm sure there's some basic setting that I'm missing, but I can't seem to figure it out. Thanks!

    An example of "PiGateway" correctly receiving all messages:

    pi@raspberrypi:/dev/pts $ sudo /usr/local/sbin/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: 0-0-0 s=33,c=1,t=38,pt=2,l=2:906
    [CALLBACK]0;33;1;0;38;906
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:907
    [CALLBACK]0;33;1;0;38;907
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:908
    [CALLBACK]0;33;1;0;38;908
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:909
    [CALLBACK]0;33;1;0;38;909
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:910
    [CALLBACK]0;33;1;0;38;910
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:911
    [CALLBACK]0;33;1;0;38;911
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:912
    [CALLBACK]0;33;1;0;38;912
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:913
    [CALLBACK]0;33;1;0;38;913
    

    an example of "PiGatewaySerial" missing most messages:

    pi@raspberrypi:/dev/pts $ sudo /usr/local/sbin/PiGatewaySerial
    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	 = 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: 0-0-0 s=33,c=1,t=38,pt=2,l=2:301
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:302
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:303
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:328
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:353
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:378
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:403
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:428
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:454
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:479
    read: 0-0-0 s=33,c=1,t=38,pt=2,l=2:504
    

    I'm running a RPi B+, NRF24l01+, on a clean install of Jessie, and using only a few percent of the CPU power.



Suggested Topics

20
Online

11.4k
Users

11.1k
Topics

112.7k
Posts