Open engmarconi opened 5 years ago
Uh-oh, I did recently push an update to pi-spi
for node v12 compatibility and perhaps that broke something :-/ I filed https://github.com/natevw/pi-spi/issues/31 to followup if that is the case.
If you are able to npm install pi-spi@1.1.0
does the problem go away?
Thanks @natevw for reply. I updated pi-spi and error not appeared again, but I changed some config like data rate and transmit power, then print details I got different values. //Code const cePin = 24; const irqPin = 25; const spiDev = "/dev/spidev0.0"; pipes = [0x7878787878, 0xB3B4B5B6F1];
var nrf = require('nrf'); var radio = nrf.connect(spiDev, cePin, irqPin); //radio._debug = true
radio.channel(115).transmitPower('PA_MAX').dataRate('250kbps').crcBytes(2) .autoRetransmit({count:15, delay:4000}).begin(function () { var rx = radio.openPipe('rx', pipes[0]); var tx = radio.openPipe('tx', pipes[1]); rx.on('data', function (d) { console.log("Got data, will respond", d); tx.write(d); }); tx.on('error', function (e) { console.warn("Error sending reply.", e); }); radio.printDetails(); });
//Details SPI device: /dev/spidev0.0 CE GPIO: 24 IRQ GPIO: 25 STATUS: 0x0 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–5: 0x0 0x0 0x0 0x0 0x0 0x0 EN_AA: 0x00 EN_RXADDR: 0x00 RF_CH: 0x0 RF_SETUP: 0x00 CONFIG: 0x00 DYNPD/FEATURE: 0x00 0x00 Data Rate: 1Mbps Model: nRF24L01 CRC Length: Disabled PA Power: PA_MIN
@engmarconi Okay, sorry about the pi-spi issue — I will have to fix that and for now you should keep the older one installed. With that fixed, it looks like it is not actually talking to the NRF device (all data is 0) so please double-check your wiring and which pin connections you are using as a next step.
Can you support me with standard connection with pi3? Regards
Matching the diagram at https://pinout.xyz/pinout/spi with your configuration:
const cePin = 24;
const irqPin = 25;
const spiDev = "/dev/spidev0.0";
The CE (RX/TX) pin of the transceiver should be on BCM 24
[header pin 18] and the IRQ on BCM 25
[header pin 22].
Then for spidev0.0 that means SPI0 bus using its CE0 pin:
BCM 10
[header 19]BCM 9
[header 21]BCM 11
[header 23]BCM 8
[header 24]Hope this helps!
Thanks @natevw, I got right config now. Is there any pi to arduino example?
According to this code:
//Code
const cePin = 24;
const irqPin = 25;
const spiDev = "/dev/spidev0.0";
pipes = [0x7878787878, 0xB3B4B5B6F1];
var nrf = require('nrf');
var radio = nrf.connect(spiDev, cePin, irqPin);
//radio._debug = true
radio.channel(115).transmitPower('PA_MAX').dataRate('250kbps').crcBytes(2)
.autoRetransmit({count:15, delay:4000}).begin(function () {
var rx = radio.openPipe('rx', pipes[0]);
var tx = radio.openPipe('tx', pipes[1]);
rx.on('data', function (d) {
console.log("Got data, will respond", d);
tx.write(d);
});
tx.on('error', function (e) {
console.warn("Error sending reply.", e);
});
radio.printDetails();
Is TX_ADDR right? I set tx pipe to pipes[1] = "0xB3B4B5B6F1"
If the Arduino is what you show in second screenshot, with TX_ADDR of 0x7878787878 then yes rx
on pipes[0] = 0x7878787878
should be correct on Pi.
I do not have an Arduino example handy, but if I remember I tested it with RF24 library (https://github.com/maniacbug/RF24) maybe it was https://github.com/nRF24/RF24/blob/master/examples/pingpair_ack/pingpair_ack.ino file? I will have to look on an older laptop for more details.
this screenshot for pi side not Arduino
const cePin = 24;
const irqPin = 25;
const spiDev = "/dev/spidev0.0";
pipes = [0x544d52687C, 0xB3B4B5B6F6]
var nrf = require('nrf');
var radio = nrf.connect(spiDev, cePin, irqPin);
//radio._debug = true
var count = 0;
radio.channel(115).transmitPower('PA_MAX').dataRate('250kbps').begin(function () {
var rx = radio.openPipe('rx', pipes[0], { autoAck: false });
var tx = radio.openPipe('tx', pipes[1], { autoAck: false });
rx.on('data', function (d) {
console.log("Got data, will respond", d);
});
tx.on('ready', function () {
console.log("TX ready.");
setInterval(function () {
tx.write(count + "");
console.log("send", count);
count++;
}, 2000);
})
tx.on('error', function (e) {
console.warn("Error sending reply.", e);
});
radio.printDetails();
});
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 mRadio (9, 10);
const uint64_t pipes[1] = { 0xB3B4B5B6F6LL};
bool initDone = false;
byte pipeNum = 0;
char dataRecieve[] = "";
void setup() {
Serial.begin(115200);
mRadio.begin();
mRadio.setChannel(115);
mRadio.setPALevel(RF24_PA_MAX);
mRadio.setDataRate(RF24_250KBPS);
mRadio.openReadingPipe(0, pipes[0]);
mRadio.startListening();
Serial.println("Start listening");
}
void loop() {
if (mRadio.available()) {
while (mRadio.available(&pipeNum)) {
mRadio.read( &dataRecieve, sizeof(dataRecieve) );
}
Serial.print("Recieve from : ");
Serial.println(pipeNum);
Serial.print("Package:");
Serial.println(dataRecieve);
}
}
This pi output:
Although I changed pipes to [0x544d52687C, 0xB3B4B5B6F6] but still RX_ADDR_P0–1: 0x7878787878 0x544d52687c I reset spi using these commands: sudo modprobe -r spi_bcm2835 sudo modprobe spi_bcm2835
I can't receive on arduino, can you help me? Regards Marco
reopen it
Sorry, I tried to get a Pi set up again to test but ran into some trouble getting the OS/node updated and probably won't be able to get back to it until next Monday.
this my nodejs code on Pi3
But I got the following response