Step-by-step procedure to connect the NRF24L01+ to the GPIO pins and use the Raspberry as a Serial Gateway (MySensors 1.x)
-
@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! -
@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
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: 126Last 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 -
Has anyone used the Raspberry GW software in combination with nodes that run the new 2.0.0 MySensors code ?
-
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)
-
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)
@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. -
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)
-
@tbowmo
Is a 2.0.0 based gateway backward compatible with nodes in an older version ? -
What would be required to get the RPi gateway up and running? Having single controller/gateway is great.
@wergeld
Probably porting the Arduino lib to Raspberry and compiling again ? -
@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
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. -
@wergeld
Probably porting the Arduino lib to Raspberry and compiling again ?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.
-
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.
-
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.
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.
-
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.
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.
@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.
-
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 ?)
-
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 ?)
@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. -
@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... -
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](/uploads/files/1448223387663-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 installIf 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 constantYou'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 := 3F000000VERIFY 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_LOWIf 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 wiresIf this happens, double-check your wiring and correct any problems. Press Ctrl+Z and type
sudo killall PiGatewaySerialto 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 startto start the gateway as a background process. Verify that it started correctly by running
sudo cat /dev/ttyMySensorsGatewayYou 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-gwserialEnable 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/ttyUSB20And change /etc/rc.local from this
exit 0to this
ln -s /dev/ttyMySensorsGateway /dev/ttyUSB20 exit 0OTHER 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:
- http://forum.mysensors.org/topic/1151/tutorial-raspberry-pi-nrf24l01-direct-connection
- http://forum.mysensors.org/topic/1974/domoticz-as-controller-and-a-gateway-for-mysensor-nodes-running-on-a-raspberry-pi-2
TROUBLESHOOTING
If you get this errorpi@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 foundyou 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.
@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? -