RF24Gateway - TCP/IP over RF24Network v2.1.1
TMRh20 - Pushing the practical limits of RF24 modules
|
This tutorial is trying to use NRF24L01
to create a TCP/IP link between two Raspberry Pi boards. Due to long range of NRFs, some of those have 1800 meter wireless range, it would be good to have a TCPIP link between two RPi via NRFs so it would be possible to have a TCPIP connection between two RPi in longer range. The onboard wifi of RPi cannot do long ranges like 50 meter even in clear sight.
raspi-config
. Select "Interface Options" -> "SPI" -> "Yes" -> "Ok", then exit and reboot the RPi (sudo reboot
). Installer will promp which modules you want to install. I did installed all modules: "RF24", "RF24Network" "RF24Mesh" "RF24Gateway". Also please select SPIDEV
driver during installation.
after installation done, and if there are no errors in the process, there will be these directories inside the RPi:
Next we need to choose a master/primary node (as discussed here). so one RPi will be primary, and another one will be secondary. we'll use the official example named ncurses
in RF24 repo to establish the network. this code is already cloned to local device in process of installation. so we need to have some edits on the code. On the Master/Primary machine no need to do edits, but on the secondary machine we need to edit ~/rf24libs/RF24Gateway/examples/ncurses/RF24Gateway_ncurses.cpp
file, first lines of method main()
Before edit (first lines)
after edit:
Again, the above edit is only done in the secondary machine, the primary machine needs no edits.
Next, we need to recompile the ncurses example and run it in the terminal:
Done. The primary machine IP is 10.11.2.2
, and the secondary machine IP is 10.11.2.3
. One could ping machines from each other.
The resulting latency when pinging primary machine from secondary is about a few milliseconds (or even less than a millisecond), and the speed is about 10kB/s
(equal to 100K bits per second).