ludiazv / node-nrf24

nRF24 (nrf24l01/nrfl24l01+) radios in the nodejs way
MIT License
39 stars 15 forks source link

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

Open Maksss2018 opened 4 years ago

Maksss2018 commented 4 years ago

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); `

ludiazv commented 4 years ago

Hi @Maksss2018, From the trace you are showing it seems that there is a problem in reading thread. It stops as the error_count is >100. This is a safety features to avoid non working radios and the application can detect this condition. It seems that you have a wiring/pin assingantion problem. Your initialization command is also uncommon: var rf24= new nrf24.nRF24(37,24); What board are you using? How the radio is wired?

Regards,

Maksss2018 commented 4 years ago

well, ludiazv, I'm using orange pi pc - I was using this instruction to connect nrf24l01 + adapter for receiver зображення

As you can see this is schema for orange pi no Pc so i runWiringOP readall to get correct gpio

ludiazv commented 4 years ago

For Orange Pi you need to have spidev activated in your case spi0 is /dev/spidev0.0. Check constructor documentation CS pin in this case should be 0. (CS=*10+ for /dev/spidev.) for the CE pin should be 25 if this is the pin. check the documentation of the orange pi to map the pin to the number in linux.

Maksss2018 commented 4 years ago

Sounds nice - I'll investigate in this way. Thank you very much

Maksss2018 commented 4 years ago

Well, I've changed boot environment with armbian-config to . And than I found that al this time there was no power 8)))) now I wondering how to check is other pinc is working because after I run ls -l /dev/*spi* ... command return nothing

`

ludiazv commented 4 years ago

Without spidev the library can't work. Check armbian documentation on how to enable spidev overlays for your board. Armbian forums are great to solve this kind of issues. Sorry I can't help with that.

Maksss2018 commented 4 years ago

Thank you anywhere ... I've turn on spidev overlay with armbian-config but steel no result. I was hoping to so some-sing with gpio readall - no changes there .. well thank you again, i will try luck on armbian dist forums