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


  • Hardware Contributor

    @mfalkvidd
    Actually ... I started with an official Domoticz build, and then I indicated in the settings that I wanted to update with the beta version. Since then I'm always on the latest beta (v5143 at the moment).


  • Mod

    @GertSanders cool. How often is the beta updated? Every build?



  • Just set this up on my existing Raspberry pi B+ Domoticz server and it is working perfectly so i have managed to get rid of the uno Gateway.
    Thank you so much,I can now try and squeeze it all in the Raspi case and the job is finished.



  • This is the cpu usage,the spike is me compiling the software as above.
    0_1463683081123_chart(2).jpeg


  • Hardware Contributor

    @mfalkvidd
    Well, that seems to be the case. Sometimes I see daily updates, sometimes a week passes by without any changes. I selected the BETA channel for updates and since then I have seen new functionality come in on a regular basis. Not all of it is relevant to Mysensors of course, but none the less it's fun to see Domoticz is developed actively.



  • @GertSanders I have seen no issues in Domoticz stable with CPU usage. Thing just purrs along. Will have to check when I get home but i believe my system uptime is approaching 1 year. It "just works" as they say.

    I would like to upgrade to mysensors 2.0 library by it looks like the Pi repo has not being updated as often (last I checked, anyway).


  • Hardware Contributor

    @wergeld
    Correct, the PI repo is basically unchanged. But it still is compatible with the 2.0-beta Mysensors library.



  • @GertSanders What? I was under the impression that some features (like sending messages to nodes from domitcz wouldn't work).


  • Hardware Contributor

    @wergeld
    Did not notice that, I can send values and "switch on" messages to nodes. The only thing I miss is the signing via ATSHA204. Even V_TEXT sending to and from nodes works.



  • I have some trouble with the gateway not storing the network map, if i restart the gateway my non-sensor nodes need to send some kind of heartbeat to reconnect to the gateway.

    Is this a known problem or is it something wrong with my setup?


  • Admin

    Yes, known problem.

    I had some hopes on @marceloaqno and @aaron832 providing a PR into development branch (so we can scrap the old RPI code). But there hasn't been any activity in a while.
    https://forum.mysensors.org/topic/2759/mysensors-raspberry-port-suggestions/12



  • @hek But insted of including heartbeats from every non sensor node (trying to keep 2.4 ghz traffic to a minimum), can i solve this by using an arduino repeater node? So the repeater knows the network map and sends heartbeat to the gateway.


  • Admin

    @Tore-André-Rosander

    No, not possible. The repeater won't propagate it's knowledge about all sub-nodes.



  • @Sander-Stolk hi
    how do you achieve to have a nice 'logon' screen ou your PI: Domotics Logo, @ip,memory,date... etc etc..
    Im' newbee on raspberry from france
    HAve a nice day
    JP
    i really want to have the same or any available sample like yours


    | _ \ | | ()
    | | | |
    __ _ __ ___ ___ | |_ _ ___ ____
    | | | / _ | '_ ` _ \ / _ | | |/ | /
    | |/ / (
    ) | | | | | | (
    ) | |
    | | (__ / /
    |/ _/|| || ||_/ _||_/_|

    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



  • @jpbabou That is the Message of the day (motd) and you can edit it to fit your needs.
    This guide should work on debian weezy and jessie
    https://oitibs.com/debian-wheezy-dynamic-motd/



  • @Tore-André-Rosander
    Tks a lot for your answer.. It seems to look like what i want at logon..Iwill test it.
    I keep you in touch!



  • @Tore-André-Rosander
    Tks a lot
    It works's fine!!
    pi@JpPi2 ~ $ ssh JpPi3
    _ ____ _ _____
    | |_ __ | _ ()__ /
    _ | | '_ | |) | | |
    | || | |) | /| |) |
    _
    /| ./|| ||__/
    |
    |

    Welcome to Raspbian GNU/Linux 8.0 (jessie) (4.4.7-v7+).

    System information as of: Wed Jun 1 09:10:09 CEST 2016

    System load: 0.01 IP Address:
    Memory usage: 17.9% System uptime: 1 day
    Usage on /: 27% Swap usage: 0.0%
    Local Users: 1 Processes: 126

    Last login: Wed Jun 1 09:03:53 2016 from raspberryjp



  • I have been struggeling with this for some time now. It seems my compiler is not the standard for raspberry pi? (I have a pi 2). I have used the domoticz sdcard as ground for my system and it works (a bit sketchy with random freezes and I cannot access the domotics webserver from chrome) but still. Anyway, I get stuck on making the RF24 package. Any ideas?

    pi@raspberrypi ~/RF24 $ make all && sudo make install
    arm-linux-gnueabihf-g++ -fPIC -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -Ofast -Wall -pthread  -c RF24.cpp
    cc1plus: error: bad value (cortex-a7) for -mtune switch
    Makefile:40: recipe for target 'RF24.o' failed
    make: *** [RF24.o] Error 1
    


  • Did anyone setup rfm69 successfully on the raspberry pi


  • Hardware Contributor

    Has anyone used the Raspberry GW software in combination with nodes that run the new 2.0.0 MySensors code ?


  • Admin

    @GertSanders

    It's not supported, 2.0.0 nodes require a 2.0.0 GW. And the raspberry pi port is not updated to 2.0.0 (and unfortunately there is currently no one in the core group that uses the rpi gw.. We all use serial / ethernet gw's of some sort)


  • Hardware Contributor

    @tbowmo
    I was afraid of that. In my enthusiasm I updated to 2.0.0, but now my new nodes play dead.
    At least I know why.
    Time to make that old ethernet gateway functional again.
    Since Breda meetup is this weekend, I will have no more time to figure this out (if I could ever, this is UNIX). Maybe after I can try something.



  • @tbowmo

    What would be required to get the RPi gateway up and running? Having single controller/gateway is great.


  • Hardware Contributor

    @tbowmo
    Is a 2.0.0 based gateway backward compatible with nodes in an older version ?


  • Hardware Contributor

    @wergeld
    Probably porting the Arduino lib to Raspberry and compiling again ?


  • Hardware Contributor

    @tbowmo
    Is the last 2.0.0-dev version (before the new 2.0.0 official release) still available somewhere ?
    That DEV version seemed to still work with my Raspi GW.



  • @GertSanders

    Time to start reading up on converting the lib! Might have a go at it in week or so. Work is holding me hostage at the moment.


  • Hardware Contributor

    Praise Apple for making TimeMachine. I was able to set back the last version of MySensors lib I know was working with my gateway in a bout 1 minute.

    Back in business now. Upgrading the gateway and nodes to full 2.0.0 is for later.


  • Admin

    @wergeld

    you need to port the mysensors core library.. It is however filled with arduino specifics at the moment (we have had some talks about removing arduino dependencies, but it's not made yet).

    Ideally someone should make a raspberry pi port, that we can merge into the main repository, so the same codebase can be build for both raspberryPi and arduino based hardware.

    @GertSanders

    A 2.0.0 GW should be compatible with 1.5.x nodes, but 2.0.0 nodes require a 2.0.0 GW.. (I can't remember the specifics in what the changes are, @tekka is the brain behind that stuff). That said, we do recommend that both nodes and GW will be updated to same mysensors versions, as to avoid any problems.


  • Mod

    @tbowmo @wergeld @GertSanders a port is already available, see https://forum.mysensors.org/topic/2759/mysensors-raspberry-port-suggestions/11 (and github)

    It would be awesome if someone could merge that great work with the MySensors repo.


  • Admin

    @mfalkvidd

    Ok, didn't know that it was updated to 2.0.0 "final", thanks for the hint 👍



  • Would it be safe to say a RPI gateway 2.0 is not available yet for beginners ? (like the instructions @mfalkvidd made are not usable for this ?)


  • Hardware Contributor

    @Sander-Teunissen
    At the moment I would advise beginners to use a separate GW for the official 2.0.0 (ethernet or serial based). I found the ethernet based gateway the easiest to use in various setups, espcially since Domoticz (my controller of choice) supported this.



  • @GertSanders Thanks Gert !
    I did a quick build of the serial gateway using an arduino which I connect to my RPI. Pretty easy. I'll be watching this when I can switch back to the RPI built gateway...



  • @mfalkvidd said:

    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.

    Nice guide thanks.
    when using external power supply i think it is best to connect Ground from Rpi and ext power supply. Maybe write that in the guide?



  • @flopp the best would be to use Raspberry's 5V rail and reduce it to 3.3V via the LDO like @GertSanders did in his board.

    There is one member using 3.3V rail for powering PA+LNA Tranceiver without any issues - check out the latest open hardware. I have not tried it personally


  • Mod

    @alexsh1 I wouldn't want a guide to recommend a solution that is way outside the specifications even if users might not experience problems. Strange problems usually happen outside specs, they are a pain to troubleshoot and in this case might lead to frying someone's Raspberry Pi.

    @flopp thanks for your suggestion, I've amended to guide.



  • @mfalkvidd I"m confused. I noticed the instructions below is for 1.5X or below and will not work with 2.0. The link for 2.0 that is posted doesn't make any sense to me at all. It also takes me to a thread where I start reading the information from the middle of a thread. I'm coming to the conclusion that it doesn't work yet..... Am I right?
    SUPER New here. sorry


  • Mod

    @SeanMarsh I don't know anything more than what's stated in that thread, sorry. That's also why it is the last option of the alternatives. Go with a serial, wifi or ethernet gateway if you can.



  • I also have a serial gateway next to my raspberry (3 in this case) with Domoticz on it.
    If there is an issue than at least a part is still running without breaking everything.
    I am using zwave at most and mysensors now for playing.
    I cannot break the current zwave implementation so for me a serial gateway is the best solution.
    For playing around you might just try as i imaging it could be fun to do it.



  • How can we update the gateway to v1.5? I just tried to rebuild from github today and I am getting really odd errors now that I did not get before:
    cc1: error: bad value (cortex-a7)

    What I could find online states I need to update the gcc compiler on my rPi - it is currently version 4 and latest is 5...but apt-get update gcc says I am already at latest version.

    I am trying to get my slimNodes up and running using v1.5 of mysensors.



  • How can I use "PA power HIGH" with this setup?



  • i can not add device to domoticz controller with serial gateway(1.4)

    MySensors Gateway USB
    Version: 1.4 Setup



  • is this true ?

    
    pi@raspberrypi:~$ sudo make enable-gwserial
    make: *** No rule to make target 'enable-gwserial'.  Stop.
    


  • @Reza try:
    cd Raspberry
    sudo make enable-gwserial



  • @Toyman
    thank you



  • in domoticz i have this problem :

    
    pi@raspberrypi:~$ sudo cat /dev/ttyMySensorsGateway
    cat: /dev/ttyMySensorsGateway: No such file or directory
    


  • How do I remove all that I have installed at the top of this thread so I can revert back to an arduino serial gateway?


  • Mod

    @rmtucker run "sudo make uninstall" when standing in the Raspberry folder



  • @mfalkvidd do you mean the root directory?
    I have had this running for a number of months but I want to go back to the arduino serial setup without losing my domoticz controller or data.


  • Mod

    @rmtucker I mean the folder containing the files from the git repo.



  • Is there a way to manually type messages to the nodes?



  • Hi,
    maybe someone could give me a hint. I installed everything and it looks like it is working, but no sensors are displayed in Domoticz. Any idea what's wrong?

    I used this sensor before with a ESP Wifi gateway and it was working fine. The DallasTemp Sensors got visible in Domoticz right after the gateway was added in the Hardware section.

    After installing the NRF24l01 on the Rasperry Pi 3 and follwing the instructions above, I added MySensorsGateway USB with /dev/ttyUSB20, but nothing happend.

    Would be nice, if I could get this smart thing working. Else I would need to go back to the ESP Wifi gateway.

    Domoticz log:
    2016-12-30 00:31:01.610 Domoticz V3.5877 (c)2012-2016 GizMoCuz
    2016-12-30 00:31:01.611 Build Hash: 15b013c, Date: 2016-11-10 16:44:33
    2016-12-30 00:31:01.611 System: Raspberry Pi
    2016-12-30 00:31:01.611 Startup Path: /home/pi/domoticz/
    2016-12-30 00:31:02.327 Sunrise: 08:18:00 SunSet:15:59:00
    2016-12-30 00:31:02.327 EventSystem: reset all events...
    2016-12-30 00:31:02.411 Active notification subsystems: (0/12)
    2016-12-30 00:31:02.448 WebServer(HTTP) started on address: :: with port 8080
    2016-12-30 00:31:02.479 WebServer(SSL) started on address: :: with port 443
    2016-12-30 00:31:02.481 Proxymanager started.
    2016-12-30 00:31:02.516 Starting shared server on: :::6144
    2016-12-30 00:31:02.516 TCPServer: shared server started...
    2016-12-30 00:31:02.517 RxQueue: queue worker started...
    2016-12-30 00:31:04.520 EventSystem: reset all events...
    2016-12-30 00:31:04.520 EventSystem: reset all device statuses...
    2016-12-30 00:31:04.521 EventSystem: Started
    2016-12-30 00:31:05.519 MySensors: Using serial port: /dev/ttyUSB20
    2016-12-30 00:33:06.145 Incoming connection from: 127.0.0.1


    pi@raspberrypi:~ $ 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 = 0xa8a8e1fc02 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
    read: 2-2-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 2-2-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-2-2 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 2-2-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-2-2 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 2-2-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-2-2 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 2-2-0 s=255,c=3,t=24,pt=1,l=1:1
    read: 2-2-255 s=255,c=3,t=7,pt=0,l=0:
    send: 0-0-2-2 s=255,c=3,t=8,pt=1,l=1,st=ok:0
    read: 2-2-0 s=255,c=3,t=24,pt=1,l=1:1
    ...


    pi@raspberrypi:~ $ sudo cat /dev/ttyMySensorsGateway
    0;0;3;0;14;Gateway startup complete.
    2;255;3;0;24;1
    2;255;3;0;24;1
    2;255;3;0;24;1
    2;255;3;0;24;1
    2;255;3;0;24;1
    1;255;3;0;24;1
    2;255;3;0;24;1
    1;255;3;0;24;1
    2;255;3;0;24;1
    1;255;3;0;24;1
    2;255;3;0;24;1
    1;255;3;0;24;1
    2;255;3;0;24;1
    2;255;3;0;24;1
    2;255;3;0;24;1
    ...


    Traces from sensor node:
    Starting sensor (RNNNA-, 2.0.0)
    TSM:INIT
    TSM:RADIO:OK
    TSP:ASSIGNID:OK (ID=2)
    TSM:FPAR
    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=2)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSM:FPAR
    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=2)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=2)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    TSM:FPAR
    TSP:MSG:SEND 2-2-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
    TSP:MSG:READ 0-0-2 s=255,c=3,t=8,pt=1,l=1,sg=0:0
    TSP:MSG:FPAR RES (ID=0, dist=0)
    TSP:MSG:PAR OK (ID=0, dist=1)
    TSM:FPAR:OK
    TSM:ID
    TSM:CHKID:OK (ID=2)
    TSM:UPL
    TSP:PING:SEND (dest=0)
    TSP:MSG:SEND 2-2-0-0 s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=ok:1
    TSP:CHKUPL:FAIL (hops=255)
    !TSM:UPL:FAIL
    ....


  • Mod

    @_Rooky_ congratulations on your first post in the forum, welcome!

    The gateway uses MySensors 1.4 and the node uses version 2. These versions are not compatible.

    You probably want to use version 2 for the gateway as well. https://www.mysensors.org/build/raspberry describes how to create a gateway for version 2 (the gateway was completely rewritten for version 2)



  • @mfalkvidd many thanks for the very quick and polite reply.
    It is working now and this solution is much better way, than using an additional ESP as gateway.
    Even though I got on the wrong lane, I learned more details from your excellent guide, than from the "make", "make install" from the MySensors page ... and still got a lot to learn



  • Thanks for this thorough guide, it works perfect 🙂



  • @Scala I have the same error as you. Worked perfectly first time, and after reboot the "/dev/ttyMySensorsGateway: No such file or directory" error message appear. Did you solve this?



  • @MrRikkie Did you solve this issue? I got the same error as you..



  • hi
    when that run this code
    :

    sudo /etc/init.d/PiGatewaySerial start
    

    error:

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

    can you help me??


  • Hardware Contributor

    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 🙂

    In my case I did need simply to restart. I did "make install" but I did need to restart 😉 😉



  • I know this thread is ancient, but why it was needed to add

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

    into rc.local if you could just change a line in makefile from

    TTY_NAME := /dev/ttyMySensorsGateway
    

    to

    TTY_NAME := /dev/ttyUSB20
    

    and create "proper" name from the start



  • Hi,
    I plan using a gateway with Mydomoticz and this solution seems great. However, I might want to use later signing or the high Amplifier NRF24 or even the version 2 which seem not suitable for this project.
    How easy is it to start with this gateway, then migrate to an external ethernet gateway ?
    I saw this gateway can be uninstalled, but should I then modify anything on sensors to move them to new gateway ? will I lose log datas in Domoticz ?

    br,
    Ricorico94


  • Mod

    @ricorico94 welcome to the MySensors commu ity! All you need to do when switching from raspberry pi gateway to ethernet gateway is change the "hardware" configuration in Domoticz.

    However, if you are just starting out, don't use this gateway. It works for MySensors 1.x only. Use the new raspberry pi gateway instead.



225
Online

8.5k
Users

9.3k
Topics

98.5k
Posts