Giter Site home page Giter Site logo

ludiazv / node-nrf24 Goto Github PK

View Code? Open in Web Editor NEW
38.0 6.0 15.0 192 KB

nRF24 (nrf24l01/nrfl24l01+) radios in the nodejs way

License: MIT License

Python 0.66% Shell 5.90% JavaScript 12.36% C++ 81.08%
nodejs nrf24l01 rf24 nrf24 radio raspberry orangepi linux

node-nrf24's People

Contributors

ludiazv avatar systemofapwne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-nrf24's Issues

Are there future plans to support the protocol used in RF24Network or RF24Mesh?

@ludiazv I noticed you mentioned nRF24/RF24Audio on #2 discussion. I've been using/testing the RF24Mesh library by the same developer/team on my Arduino/ESP8266/ESP32 microcontroller projects. Are there plans to make node-nrf24 to be able to interact with devices using those libraries?

I've been looking into ways to make Raspberry Pi's to communicate using the same radios and this is the main reason your library caught my attention. RF24Mesh is also supported on the Raspberry Pi but although I've started getting the hang of C/C++ for Arduino, I'm still a long way understanding how to make use of the same on a Linux environment. On the other hand I have a solid JavaScript background so being able to use Node instead would be awesome.

Error writing to pipe depending on scope

Hi,

I am having an issue regarding this code:

      var nrf24=require("nrf24");
      var readline = require('linebyline');
      var rf24= new nrf24.nRF24(174, 20);
      console.log("begin->",rf24.begin(true));
      rf24.useWritePipe("0x72646f4e31");
      var rl = readline(process.stdin);
      
      rl.on('line', function(line){
              success = rf24.write(Buffer.from(line));  ------------> This write works
              console.log("Sent " + ( success ? "OK" : "KO" ));
      });
      
      success = rf24.write("ASD");    ---> This fails: SyntaxError: Unknown error

  I can't see the difference between both. It's weird.

Installation falilure

i am trying to install the package on raspbian 11 bullseye 64bit - nodejs v14.19.1 but i have this error:

g++ -fPIC -marm -march=armv6zk -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -Ofast -Wall -pthread  -c RF24.cpp
g++: error: unrecognized command-line option ‘-marm’
g++: error: unrecognized command-line option ‘-mfpu=vfp’
g++: error: unrecognized command-line option ‘-mfloat-abi=hard’
make: *** [Makefile:42: RF24.o] Errore 1
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] preinstall: `./build_rf24libs.sh`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-03-25T14_52_04_566Z-debug.log

this is the log file

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'nrf24' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 3fdf41ab69052fba
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/nrf24 1496ms (from cache)
8 silly pacote tag manifest for nrf24@latest fetched in 1594ms
9 timing stage:loadCurrentTree Completed in 2331ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 5ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 122ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule [email protected] checking installable status
17 http fetch GET 304 https://registry.npmjs.org/bindings 594ms (from cache)
18 silly pacote range manifest for bindings@^1.5.0 fetched in 642ms
19 silly resolveWithNewModule [email protected] checking installable status
20 http fetch GET 304 https://registry.npmjs.org/nan 633ms (from cache)
21 silly pacote range manifest for nan@^2.14.0 fetched in 666ms
22 silly resolveWithNewModule [email protected] checking installable status
23 http fetch GET 304 https://registry.npmjs.org/nan-check 1093ms (from cache)
24 silly pacote version manifest for [email protected] fetched in 1122ms
25 silly resolveWithNewModule [email protected] checking installable status
26 http fetch GET 304 https://registry.npmjs.org/file-uri-to-path 191ms (from cache)
27 silly pacote version manifest for [email protected] fetched in 208ms
28 silly resolveWithNewModule [email protected] checking installable status
29 http fetch GET 304 https://registry.npmjs.org/nan-marshal 808ms (from cache)
30 silly pacote version manifest for [email protected] fetched in 827ms
31 silly resolveWithNewModule [email protected] checking installable status
32 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 2406ms
33 timing stage:loadIdealTree Completed in 2581ms
34 silly currentTree pi
34 silly currentTree ├── [email protected]
34 silly currentTree ├── [email protected]
34 silly currentTree ├── [email protected]
34 silly currentTree └── [email protected]
35 silly idealTree pi
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree ├── [email protected]
35 silly idealTree └── [email protected]
36 silly install generateActionsToTake
37 timing stage:generateActionsToTake Completed in 34ms
38 silly diffTrees action count 6
39 silly diffTrees add [email protected]
40 silly diffTrees add [email protected]
41 silly diffTrees add [email protected]
42 silly diffTrees add [email protected]
43 silly diffTrees add [email protected]
44 silly diffTrees add [email protected]
45 silly decomposeActions action count 48
46 silly decomposeActions fetch [email protected]
47 silly decomposeActions extract [email protected]
48 silly decomposeActions preinstall [email protected]
49 silly decomposeActions build [email protected]
50 silly decomposeActions install [email protected]
51 silly decomposeActions postinstall [email protected]
52 silly decomposeActions finalize [email protected]
53 silly decomposeActions refresh-package-json [email protected]
54 silly decomposeActions fetch [email protected]
55 silly decomposeActions extract [email protected]
56 silly decomposeActions preinstall [email protected]
57 silly decomposeActions build [email protected]
58 silly decomposeActions install [email protected]
59 silly decomposeActions postinstall [email protected]
60 silly decomposeActions finalize [email protected]
61 silly decomposeActions refresh-package-json [email protected]
62 silly decomposeActions fetch [email protected]
63 silly decomposeActions extract [email protected]
64 silly decomposeActions preinstall [email protected]
65 silly decomposeActions build [email protected]
66 silly decomposeActions install [email protected]
67 silly decomposeActions postinstall [email protected]
68 silly decomposeActions finalize [email protected]
69 silly decomposeActions refresh-package-json [email protected]
70 silly decomposeActions fetch [email protected]
71 silly decomposeActions extract [email protected]
72 silly decomposeActions preinstall [email protected]
73 silly decomposeActions build [email protected]
74 silly decomposeActions install [email protected]
75 silly decomposeActions postinstall [email protected]
76 silly decomposeActions finalize [email protected]
77 silly decomposeActions refresh-package-json [email protected]
78 silly decomposeActions fetch [email protected]
79 silly decomposeActions extract [email protected]
80 silly decomposeActions preinstall [email protected]
81 silly decomposeActions build [email protected]
82 silly decomposeActions install [email protected]
83 silly decomposeActions postinstall [email protected]
84 silly decomposeActions finalize [email protected]
85 silly decomposeActions refresh-package-json [email protected]
86 silly decomposeActions fetch [email protected]
87 silly decomposeActions extract [email protected]
88 silly decomposeActions preinstall [email protected]
89 silly decomposeActions build [email protected]
90 silly decomposeActions install [email protected]
91 silly decomposeActions postinstall [email protected]
92 silly decomposeActions finalize [email protected]
93 silly decomposeActions refresh-package-json [email protected]
94 silly install executeActions
95 silly doSerial global-install 48
96 verbose correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
97 verbose lock using /root/.npm/_locks/staging-8a58fe8d264b10c5.lock for /home/pi/node_modules/.staging
98 silly doParallel extract 6
99 silly extract [email protected]
100 silly extract [email protected]
101 silly extract [email protected]
102 silly extract [email protected]
103 silly extract [email protected]
104 silly extract [email protected]
105 silly tarball trying [email protected] by hash: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
106 silly tarball trying nan@^2.14.0 by hash: sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==
107 silly tarball trying [email protected] by hash: sha1-DUoDXpP0WsfyNhPZZjZ/QvsYLPY=
108 silly tarball trying bindings@^1.5.0 by hash: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
109 silly tarball trying [email protected] by hash: sha1-i/0uecNkOSgPpKl11BgkxaLSv6U=
110 silly tarball trying nrf24@latest by hash: sha512-gQhwg02H7QiwI+fdKP0h7m7K9kpQl0Q8YpaIaNQtBerGNVoD7RJPNeoM1ur3oze2uEQYGEegBFLZ96pns5a4vA==
111 timing audit submit Completed in 885ms
112 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 885ms
113 timing audit body Completed in 21ms
114 silly extract bindings@^1.5.0 extracted to /home/pi/node_modules/.staging/bindings-e015561d (847ms)
115 silly extract [email protected] extracted to /home/pi/node_modules/.staging/file-uri-to-path-4702ff23 (973ms)
116 silly extract [email protected] extracted to /home/pi/node_modules/.staging/nan-marshal-ebc6605b (1176ms)
117 silly extract [email protected] extracted to /home/pi/node_modules/.staging/nan-check-280695a4 (1275ms)
118 silly extract nan@^2.14.0 extracted to /home/pi/node_modules/.staging/nan-cbd23b3f (1468ms)
119 silly extract nrf24@latest extracted to /home/pi/node_modules/.staging/nrf24-79acc27a (1520ms)
120 timing action:extract Completed in 1547ms
121 silly doReverseSerial unbuild 48
122 silly doSerial remove 48
123 silly doSerial move 48
124 silly doSerial finalize 48
125 silly finalize /home/pi/node_modules/file-uri-to-path
126 silly finalize /home/pi/node_modules/nan
127 silly finalize /home/pi/node_modules/nan-marshal
128 silly finalize /home/pi/node_modules/bindings
129 silly finalize /home/pi/node_modules/nan-check
130 silly finalize /home/pi/node_modules/nrf24
131 timing action:finalize Completed in 103ms
132 silly doParallel refresh-package-json 6
133 silly refresh-package-json /home/pi/node_modules/file-uri-to-path
134 silly refresh-package-json /home/pi/node_modules/nan
135 silly refresh-package-json /home/pi/node_modules/nan-marshal
136 silly refresh-package-json /home/pi/node_modules/bindings
137 silly refresh-package-json /home/pi/node_modules/nan-check
138 silly refresh-package-json /home/pi/node_modules/nrf24
139 timing action:refresh-package-json Completed in 251ms
140 silly doParallel preinstall 6
141 silly preinstall [email protected]
142 info lifecycle [email protected]~preinstall: [email protected]
143 silly preinstall [email protected]
144 info lifecycle [email protected]~preinstall: [email protected]
145 silly preinstall [email protected]
146 info lifecycle [email protected]~preinstall: [email protected]
147 silly preinstall [email protected]
148 info lifecycle [email protected]~preinstall: [email protected]
149 silly preinstall [email protected]
150 info lifecycle [email protected]~preinstall: [email protected]
151 silly preinstall [email protected]
152 info lifecycle [email protected]~preinstall: [email protected]
153 verbose lifecycle [email protected]~preinstall: unsafe-perm in lifecycle false
154 verbose lifecycle [email protected]~preinstall: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/pi/node_modules/nrf24/node_modules/.bin:/home/pi/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
155 verbose lifecycle [email protected]~preinstall: CWD: /home/pi/node_modules/nrf24
156 silly lifecycle [email protected]~preinstall: Args: [ '-c', './build_rf24libs.sh' ]
157 silly lifecycle [email protected]~preinstall: Returned: code: 2  signal: null
158 info lifecycle [email protected]~preinstall: Failed to exec preinstall script
159 timing action:preinstall Completed in 12057ms
160 verbose unlock done using /root/.npm/_locks/staging-8a58fe8d264b10c5.lock for /home/pi/node_modules/.staging
161 timing stage:rollbackFailedOptional Completed in 755ms
162 timing stage:runTopLevelLifecycles Completed in 19814ms
163 silly saveTree pi
163 silly saveTree ├─┬ [email protected]
163 silly saveTree │ └─┬ [email protected]
163 silly saveTree │   ├── [email protected]
163 silly saveTree │   └── [email protected]
163 silly saveTree ├─┬ [email protected]
163 silly saveTree │ ├─┬ [email protected]
163 silly saveTree │ │ └── [email protected]
163 silly saveTree │ ├─┬ [email protected]
163 silly saveTree │ │ ├─┬ [email protected]
163 silly saveTree │ │ │ └── [email protected]
163 silly saveTree │ │ └── [email protected]
163 silly saveTree │ └── [email protected]
163 silly saveTree ├── [email protected]
163 silly saveTree ├── [email protected]
163 silly saveTree └── [email protected]
164 warn enoent ENOENT: no such file or directory, open '/home/pi/package.json'
165 verbose enoent This is related to npm not being able to find a file.
166 warn pi No description
167 warn pi No repository field.
168 warn pi No README data
169 warn pi No license field.
170 verbose stack Error: [email protected] preinstall: `./build_rf24libs.sh`
170 verbose stack Exit status 2
170 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
170 verbose stack     at EventEmitter.emit (events.js:400:28)
170 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
170 verbose stack     at ChildProcess.emit (events.js:400:28)
170 verbose stack     at maybeClose (internal/child_process.js:1058:16)
170 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
171 verbose pkgid [email protected]
172 verbose cwd /home/pi
173 verbose Linux 5.10.103-v8+
174 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "nrf24"
175 verbose node v14.19.1
176 verbose npm  v6.14.16
177 error code ELIFECYCLE
178 error errno 2
179 error [email protected] preinstall: `./build_rf24libs.sh`
179 error Exit status 2
180 error Failed at the [email protected] preinstall script.
180 error This is probably not a problem with npm. There is likely additional logging output above.
181 verbose exit [ 2, true ]

How to send big buffers (4000 bytes)

Hi @ludiazv,

I'm having a problem. I need to transmit buffers with a size of 4000 bytes. This package can't transmit more than 32 bytes.
Do you have any idea or hint how to transmit bigger buffers?

ASUS Tinker board CE

Hello,

I can not manage to get it working fine on a tinker boar.

I spent a lot of hours trying and, by change, I could send some data when I disconnected CE completely.

The problem seems to be related to GPIO.

var rf24= new nrf24.nRF24(22, 20);

or

var rf24= new nrf24.nRF24(15, 20);

The CE pin is wired to the pin GPIO5B7 (tinker), physical pin 15, GPIO22. If I keep it wired:

RF24 HARDWARE FAIL: Radio not responding, verify pin connections, wiring, etc.

If I disconnect the wire it works.

Any idea?

Writing fail on nRF24L01+ with raspberry pi zero W and arduino pro mini

Hi, I am using the Gettingstarted program on the pi and arduino.
When i start the program on pi, i get this output of the details:

Cofiguration pins CE-> 22 CS-> 0 IRQ-> -1
Radio details after config:

================ SPI Configuration ================
CSN Pin = 0
CE Pin = Custom GPIO22
SPI Speedz = 10 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 = 0x65646f4e32 0x65646f4e31
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x65646f4e32
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x00
CONFIG = 0x7e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN

So i think everything is working there, however, when i set the arduino radio number to 0 and set send mode on the pi, i get a writing fail error: Sending....[Sync] Failed to send 1627043188

I have tried many changes to running these programs, changing writing mode, changing radio numbers etc.. nothing has worked so far. But when i try the gettingstarted example of the RF24 library written in C++ everything does work, so it's very odd.
Is there something i am missing here? Thank you in advance.

Traing to llisten to slave, or prhebs make some radio scanner

Hi,
tying to get new skills in IoT
here code for master:
`const nrf24=require("nrf24"); // Load de module

// Init the radio
var rf24= new nrf24.nRF24(37,24);
rf24.begin();
// Configure the radio
rf24.config({
PALevel: nrf24.RF24_PA_LOW,
DataRate: nrf24.RF24_1MBPS,
});

// Register Reading pipes
var pipe=rf24.addReadPipe("0x65646f4e31",true) // listen in pipe "0x65646f4e31" with AutoACK enabled.

// Register callback for reading
rf24.read( function(data,n) {
// when data arrive on any registered pipe this function is called
// data -> JS array of objects with the follwing props:
// [{pipe: pipe id, data: nodejs with the data },{ ... }, ...]
// n -> number elements of data array
console.log(" reciver Onn");
console.dir(data);

},function(isStopped,by_user,error_count) {
console.log(" reciver stopped");
console.log(" isStopped ", JSON.stringify(isStopped));
console.log(" by_user ", JSON.stringify(by_user));
console.log(" error_count ", JSON.stringify(error_count));

// This will be if the listening process is stopped.
});

//rf24.stopRead();

// If you want to abort pending async writes
//rf24.stopWrite();

// Finally to assure that object is destroyed
// and memory freed destroy must be called.
//rf24.destroy();

`
result:
getting error 101
reciver stopped
isStopped true
by_user false
error_count 101

code for slave:
`SPI1.setup({sck:A5, miso:A6, mosi:A7});
var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );
function onInit() {
nrf.init([0,0,0,0,1], [0,0,0,0,2]);
}
onInit();
setInterval(function() {
digitalWrite(LED1,1);

//var value = analogRead(A0); // read a value in
nrf.sendString("!!!!!!.");

}, 2000);
`

Performance issues

I'm having a sender and a receiver.

The sender constantly sends packages (32byte), and the receiver prints out the number of packages received per second.

These are my relevant settings (the are the same for sender and receiver):

PALevel: nrf24.RF24_PA_MAX
DataRate: nrf24.RF24_2MBPS
CRCLength: nrf24.RF24_CRC_DISABLED
PayloadLength: 32

I can't get it to transmit more than 78 packages per second which is (78*32) 2496 Bytes per second. (2496 / 1000) = ~2.5 kB/s.

I assumed that 2Mb/s = 250 kB/s = 25000 B/s and therefore 25000 / 32 = ~780 Packages per second. I know these rates are theoretical, but I thought at least 75 % were possible.

Is it possible, that the DataRate option is currently ignored?

P.S.: Sorry, if I did the math wrong. In my daily work, I'm not confronted with it very often.

Channel 0 doesn't work

Hi !

The channel 0 is not taken into account, it is replaced by default 76.
The line 189 in rf24_setup.cc seems to test the range [1;127] instead of [0;126].

Regards.

[not a bug or issue]please help about raspi gpio pins and pipe address

var rf24= new nrf24.nRF24(<CE gpio>,<CS gpio>);
  • my raspi is module 3b +
  • i link nrf24 and raspi follow this:
http://tmrh20.github.io/RF24/
![image](https://user-images.githubusercontent.com/20190746/65207550-8917e300-dac4-11e9-8005-cdcd8f1a8ce6.png)

question 1 : in my project ,new nrf24.nRF24 should be:

var rf24= new nrf24.nRF24(22,8);   
or
var rf24= new nrf24.nRF24(15,24);
??????

question 2: byte address[6] = '00001' How to convert to "0x0000000000" ?

in c++ (arduino IDE),the read address is "byte address[6] = '00001'"
in nodejs the write address is ???

i want that raspi(nodejs) send message to arduino(c++)

Please forgive me for taking the liberty and ignorance
I used nrf24 for the first time, Im a javascript developer and i don't understand C++ and hardware development.

Fix some documentation (README)

Import
const nrf24=require("nRF24"); // Load de module -> const nrf24=require("nrf24"); // Load de module or import * as nrf24 from 'nrf24';

Constructor
var rf24= new nrf24.RF24(<CE gpio>,<CS gpio>); -> this.rf24 = new nrf24.nRF24(22, 0)

GettingStarted.js cannot read more than the first 4 bytes on the buffer

Thank you for your outstanding work.

I have a great interest for radio and networking, unfortunatly I am not a dev, so my comments might be not smart at all...
Anyway..

I use this to readthe buffer and print the data.
An arduino is sending two values (from two sensors) grouped in a structure (weather sensors)

radio.read(function(d,items) {
for(var i=0;i<items;i++){
let r=d[i].data.readFloatLE(0);
console.log("Payload Rcv [" + r +"], reply result:" + radio.write(d[i].data));
console.log(d);

the results are :

{
pipe: 1,
data: <Buffer 4a 36 48 3f 00 00 ce 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>
}
]
Payload Rcv [0.7820783853530884], reply result:1

As yuo can see, the first 4 bytes " 4a 36 48 3f " are decoded as 0.78207... This is a correct value from the first sensor (Checked on the console of the arduino)
However the following 4 bytes "00 00 ce 42" ( 103 ) are not decoded

I would like the two 4 bytes to be decoded and put in a structure too in order to be forwarded to some websocket process.

Thanks you By advance.
Regards.

Vincent.

Option to set SPI CLK frequency

Right now, this lib uses the max SPI CLK (set to 10 MHz). This can cause some trouble, especially if cables are too long or if interferences happen. In principle, a proper PCB design or shielded wiring scheme might solve this. Yet, it is not always possible to achieve this goal, especially for prototypes.
This can cause errors like the radio not responding at all (10 cm long cables will definitly fail) or having it occasionally failing (RF24 HARDWARE FAIL: Radio not responding, verify pin connections, wiring, etc.).
Allowing one to reduce the CLK speed via the node interface to a customized and lower speed, this problem can be minimized.
In the original RF.24 library, this is done at RF24.begin(). Here, it would suit best at the constructor though: nRF24(CE.CSN,speed = 10MHz).

ReadMe seems to be out of date

Hi @ludiazv ,

thanks for this awesome library. I'm currently trying to use it, but the ReadMe seems to be out of date.

For example:

  • Instead of var nrf24 = require("nRF24"); you have to const nrf24 = require("nrf24");.
  • var rf24 = nrf24.RF24(22, 0); does not work, you have to instantiate it instead: var rf24 = new nrf24.nRF24(22, 0);
  • You have to enable SPI

If pull requests are welcome, I will create one - in case I find out on my own how to run this library.

Reading strings and converting C++ structs

Do you have any insight into how to use this library to read strings sent from a radio on an arduino? It's simple enough to read an integer sent from the arduino radio but I cant figure out how to convert the buffer in node back into a string - I've tried node Buffers .toString() method but nothing gets returned.

I was also wondering if you have any idea how to send something from this library that could be used as a struct on the arduino side? I've passed structs between different radios running on arduinos but I cant figure out how to create a buffer in node that could be used as a struct when sent to an arduino.

So far the library is great! Thanks for any help.

Packages arrive only when auto_ack: true

I'm having a sender and a receiver.

The sender constantly sends packages, and the receiver prints out the number of packages received per second.

When I disable auto_ack, less than 1% of the packages arrive.
Only when auto_ack is enabled, all the packages arrive.

I assumed that at least 50% of the packages will arrive. But less than 1% seem strange to me.
Is that normal?

NPM Install fails

Hello,

I have just tried to install this on a raspberry pi, and the install fails, log file below... any ideas?

I have tried running the install command as sudo

Most settings not being displayed correctly

PA Power = PA_MIN
IRQ (negative is unused):-1
PayloadSize:32

That's not the full list but a lot of settings are not showed their real values, tho the values I used are indeed applied

Hardware Not Found

I have been trying to get 1 x Arduino Uno and 1 x Raspberry Pi 1 (Model B) talking for a couple of weeks now.

I am sure this isn't a hardware issue, as I can get the gettingstarted example in rf24libs working, but I can't make any of the node versions to work.

Each time node seems to fail to detect the hardware, despite me configuring the pins correctly.

I have had similar issues with python ports too, and any of the other lib examples. Any ideas on what might be causing this?

Advanced features - Dyn Payloads + Ack payload

First of all, thanks to those who collaborated on this project.

I want to know when dynamic payloads and acknowledge payload will be ready.


Right now I'm working on a project which communicates between RPI and Arduino. Somehow the packages which sent from Arduino can't auto ack. (Arduino-to-Arduino works fine). So that's why I thought it's because I'm using dyn.payload and autoack at Arduino, but this library is not supporting.

Note: I enabled auto_ack at openreadpipe (and I can see it in info). I'm receiving the package at nrf24.read and it matches exactly but Arduino is not understanding acknowledge.

Thanks again

Issues when building from scratch

Hi,
I just lately got my new RPi so I started from a clean install of everything, including this library.
On May 17, you outcommented the building of RF24Gateway from build_rf24libs.sh, as it is not yet supported by this lib. But this now causes the initial build to fail, if there is no librf24gateway.so available (The linker complains and makes e.g. npm rebuild fail).
In turn, if this library already has been built in the past, re-compiling this library works flawless (because the gateway lib is still present)

Steps to reproduce:

  • Delete all RF24 libraries from /usr/local/lib
  • Run npm rebuild on a project, which uses this lib here

Fix
Build RF24Gateway again via build_rf24libs.sh or remove/comment-out the code of RF24Gateway from this lib, so the linker does not complain

usb adapter

Hello there !

Is there a way to use this library with an USB adapter ?

CH340T USB + 2.4G NRF24L01 (ch341-uart)

Thanks for your help !

Unable to connect radio

I'm using the current master branch.
And running the code with a PI 3 B+.
SPI enabled
CE => GPIO22
CSN => SPICS0

const lib = require('nrf24');

const radio = new lib.nRF24(22, 0);

radio.begin(true);

radio.config({
  PALevel: lib.RF24_PA_LOW,
  DataRate: lib.RF24_1MBPS,
  Channel: 76,
}, true);

console.log("Radio connected:" + radio.present());
console.log("Is + Variant:" + radio.isP())

const readPipe = radio.addReadPipe('0xf0f0f0f0e1', true);

const pipeNum = radio.read(
  (data, n) => {
    console.log('read', data, n);
  },
  (stopped, user, errorCount) => {
   console.log('stopped', stopped, user, errorCount);
  }
);

console.log('pipeNum', pipeNum);
console.log('state', radio.getStats());

process.on('SIGINT', () => {
  radio.stopRead();
  radio.destroy();
  console.log('Bye, bye!');
  process.exit();
});

Results:

pi@raspberrypi:~/dev/radio $ sudo node radio.js 
Radio details after config:
===========================
STATUS		 = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1	 = 0x0000000000 0x0000000000
RX_ADDR_P2-5	 = 0x00 0x00 0x00 0x00
TX_ADDR		 = 0x0000000000
RX_PW_P0-6	 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA		 = 0x00
EN_RXADDR	 = 0x00
RF_CH		 = 0x00
RF_SETUP	 = 0x00
CONFIG		 = 0x00
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 1MBPS
Model		 = nRF24L01
CRC Length	 = Disabled
PA Power	 = PA_MIN
IRQ gpio (negative if disabled):-1(0)
Config internals:
check the values as incorrect values fallback to default values.
 PALevel:1 DataRate:0 Channel:76 CRCLength:2 Retries:(5+1*250us,15 attempts) PayloadSize:32 AddressWidth:5 AutoAck:1 TxDelay:250 PollBaseTime:35000
===========================
Radio connected:false
Is + Variant:false
pipeNum undefined
state { TotalRx: 0,
  TotalTx_Ok: 0,
  TotalTx_Err: 0,
  PipesRx: [ 0, 0, 0, 0, 0, 0 ] }
^CBye, bye!

Am I doing something wrong? I'm not able to connect the radio or get a pipeNum?

print_details not working for config() function

Hey,
this seems to be a great library, thanks! While the lib successfully and correctly prints true for .begin(), .present() and .isP(), calling config with the print_details flag enabled like follows

radio.config({
  PALevel: nrf24.RF24_PA_MIN,
  [...]
}, true);

The code in a try catch environment prints the following error with the line number pointing to the config function

SyntaxError: Unknown error

Also the JS code stops without terminating or printing any errors after using useWritePipe(pipe) and addReadPipe(pipe).

console.log('[Nrf] start test');
radio.useWritePipe(pipe);
console.log('[Nrf] set up pipes'); // Does not execute this line

Running a simple c++ test program using rf24 class works. Platform is Raspberry Pi Zero W. Connection as you suggest

NRF24L01+ RPi Zero W (GPIO) Pin Number
VCC 3.3V 17
GND GND 20
CE GPIO 22 15
CSN GPIO 8 24
MISO GPIO 9 21
MOSI GPIO 10 19
SCK GPIO 11 23
IRQ GPIO 25 22

Any suggestions?

RX pipes

Hi, thank you for great job with integrate NRF24 with nodejs.

Unfortunately I have problem with identify pipe on read.
In your docs on read arg .pipe should be the same what register by .addReadPipe.
Now in simple code

var rpipe = radio.addReadPipe(Pipes[0]);

console.log("Read Pipe " + rpipe + " opened for " + Pipes[0]);

radio.read(
  function(d, items) {
    for (var i = 0; i < items; i++) {
      console.log(`in ${d[i].pipe} rpipe ${rpipe}`);
}})

I've only receive

Read Pipe 1 opened for 0xaaaaaaabbc
in 2 rpipe 1

Doesn't matter what I change before .read I've always reveive .pipe =2

Do you have any idea or explanation why ?

Changing Channel After Initialization

I have a use case that requires changing the channel the radio is configured to before writing. Is it possible to do this with the library? From what I've tried I do not believe so, but want to ask

build with RPi driver : radio not working or in use

Hi !

I installed this library with the command line : DRIVER=RPi npm install [email protected] --save
When I use your nRF24input node I get these error messages :

  • flow : RF24 radio not working or in use
  • log : [info] [RF24radio:module radio] Radio Failed to initialize, wiring or hardware problem. FailureDetected:true

The same flow works fine when I use the default driver (SPIDEV).
Enabling or disabling SPI (with raspi-config) doesn't change anything.
Using the getting_started.py from https://tmrh20.github.io/RF24/ works.

Regards

Mesh not working with RF24Mesh 1.0.6 but slightly on latest 1.0.7

I have tried to narrow down, why I'm completely unaible to connect my Arduinos to my RPi while the arduinos (when one of them is a master) can connect to each other in a mesh.

The symptoms:

  • If I'm running the mesh on my RPi in master-mode but no arduino-node can connect to the RPi.
  • If I have an additional arduino as a master in parallel, all my other arduinos will connect to the arduino-master and the RPi master sees the data communication.

Configuration
RF24: 1.3.2
RF24Network: 1.0.9
RF24Mesh: 1.0.6 on RPi, 1.0.7 on Arduino

Conclusion:
Data communication works, but the DHCP seems to fail, if RF24Mesh 1.0.6.
I updated RF24Mesh to 1.0.7 on the RPI and now , at least, the RPi seems to see the external nodes now. But the external nodes won't accept/see their associated addresses (yet). I will try to further narrow this down. all arduinos can connect to the RPi.
Note: It also seems to fail, if I downgrade the arduino RF24Mesh to 1.0.6 (so RPi and Arduino share the same lib).

Suggested fix:
Tell build_rf24libs.sh to build against RF24Mesh 1.0.7.

test_simple.js Syntax error

tested on raspberry pi 3 B + "raspian buster"

The two RF24 modules connect well together, but I get this error when the server receives

`/home/pi/NODE/node_modules/nrf24/test/test_simple.js:36
rfo.write(d); // Pong back
^

SyntaxError: Unknown error
at /home/pi/NODE/node_modules/nrf24/test/test_simple.js:36:7
`

radio.resetStats() does not reset stats

Hi,

I think the resetStats() function isn't working as it should. Using it in an interval reading the stats and resetting it afterwards will not reset the stats.

setInterval(() => {
  console.log(this.radio.getStats()); // works properly { TotalTx_Ok: #, etc... }
  this.radio.resetStats();
}, 500);

As a workaround one could use the difference of two steps, but that's not intended for using the lib I think, so I thought it might be a good idea to open an issue.

Thanks again for your great work and support!

RF24 HARDWARE FAIL: after first write

First write works fine and is received at the other end. But any write after that blocks forever in an infinite loop of "RF24 HARDWARE FAIL: Radio not responding, verify pin connections, wiring, etc." error messages.

This happens with my own test program in js, with test/test_RF24.js (when invoked with parameter "1") and also when used from NodeRed.

The C++ test program from the RF24 library works fine using the exact same version of the C++ lib running in the same hardware. And so does the C++ version of my test program. They can send as many transfers as needed with no error.

I'm using a RaspberryPi3 running raspbian, kernel 4.4.38-v7+ and using SPIDEV.

Sending fails, wrong pin?

Hi,
I am not able to send or receive anything.

var rf24 = new nrf24.nRF24(19, 0);
 rf24.begin();

 rf24.config({
   PALevel: nrf24.RF24_PA_MAX,
   DataRate: nrf24.RF24_1MBPS,
   Irq: 16
 });

 console.log(rf24.present());

 var data = Buffer.from("Turn LED on");
 rf24.useWritePipe("0xF0F0F0F0E1", true);
 console.log(rf24.write(data));

 rf24.destroy();

Output:

true
0

The wiring is correct, but the second output tells me nothing was sent. Also my receiver doesn't receive any data.

Is it possible, my code doesn't work because I am using another CE Pin?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.