Module rf24js wants to be a simple wrapper of RF24C++ library by TMRH20. No logic added, just existing methods wrapped.
How to use
The only one dependency is the library it wants to wrapper: RF24. Use the following instructions to compile and install it from sources:
git clone https://github.com/nRF24/RF24.gitcd RF24makesudo make install
Import in node js
After RF24 is installed, simple run:
npm install --save rf24js
Use in your project
var rf24js = ;var radio = rf24jsradio;var PALevel = rf24jsPALevel;var CRCLength = rf24jsCRCLength;var Datarate = rf24jsDatarate;
Configure and setup your radio using create(ce, cs) method.
Parameter ce is the mini-pc pin number in with is connected radio chip enable pin.
Parameter cs is a number (byte) to select SPI device in with is connected the radio. In general this parameter is an integer that represent the id, without dot, of the spi devices you find using command
ls /dev. Example: for
spidev0.0 CS is 0, for
spidev0.1 CS is 1, for
spidev1.0 CS is 10, ecc
radio; // OrangePi-Zeroradio; // RaspberryPi 1/2/3radio;radio; // Optionally: is used to show radio configuration
Declare and open read and write pipes
var pipe1 = "1Node\0";var pipe2 = "2Node\0";radio;radio;
var buffer = null;if radiobuffer = radio;
var buffer = 4;buffer;var success = radio;
In some OS like Raspibian yuo need to start node application as super user.