2.0.4 • Published 6 years ago

rf24js v2.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

rf24js

Support Node of LTS npm version Build passing Build passing Support dependencies rf24 nan License mit tested


Description

Module rf24js wants to be a simple wrapper of RF24C++ library by TMRH20. No logic added, just existing methods wrapped.

How to use

Install dependencies:

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.git
cd RF24 
make
sudo make install

Import in node js

After RF24 is installed, simple run:

npm install --save rf24js

Use in your project

Typescript

import {radio, PALevel,CRCLength,Datarate} from 'rf24js'

Javascript

var rf24js = require('rf24js');
var radio = rf24js.radio;
var PALevel = rf24js.PALevel;
var CRCLength = rf24js.CRCLength;
var Datarate = rf24js.Datarate;

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.create(2, 10); // OrangePi-Zero 
radio.create(22, 0); // RaspberryPi 1/2/3 
radio.begin();
radio.printDetails(); // Optionally: is used to show radio configuration

Declare and open read and write pipes

var pipe1 = new Buffer("1Node\0");
var pipe2 = new Buffer("2Node\0");
radio.openWritingPipe(pipe1);
radio.openReadingPipe(1, pipe2);

Read data

var buffer = null;
if (radio.available())
    buffer = radio.read(4);

Write data

var buffer = new Buffer(4).fill(0);
buffer.writeUInt32LE(50);
var success = radio.write(buffer, buffer.length);

Note

In some OS like Raspibian yuo need to start node application as super user.

2.0.4

6 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago