natevw / node-nrf

Pure-JavaScript nRF24L01 driver library
117 stars 31 forks source link

Can't get communication working, s.th. wrong using tx.write() #63

Open ngfelixl opened 6 years ago

ngfelixl commented 6 years ago

Hi, I'm trying for about two days getting your library to work. My setting is Raspberry Pi Zero W should send 5byte data to an Arduino Nano. Also tested sending the data with an additional Arduino Uno, which is working perfectly. So I tried copying all the details output and configured the RPi NRF exactly like the Uno ones. No data is arriving. I think the issue how I'm using the tx stream, but I can't figure it out.

I'm using the pipes like

this.radio.begin(() => {
  const tx = this.radio.openPipe('tx', this.txPipe, {size: 5});
  const rx = this.radio.openPipe('rx', this.txPipe, {size: 5});
  // some .setStates to get the UNO config

  tx.on('ready', () => {
    const data = new Buffer(5).fill(0xa0);
    tx.write(data);
  });
})

The details outputs are the following:

Arduino Nano

Type Arduino Nano RPi Zero W and Arduino Uno
STATUS 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 0xf0f0f0f0e1 0xf0f0f0f0d2 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 0xc3 0xc4 0xc5 0xc6 0xc3 0xc4 0xc5 0xc6
TX_ADDR 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_PW_P0-6 0x05 0x05 0x00 0x00 0x00 0x00 0x05 0x05 0x00 0x00 0x00 0x00
EN_AA 0x3f 0x3f
EN_RXADDR 0x02 0x03
RF_CH 0x5a 0x5a
RF_SETUP 0x01 0x01
CONFIG 0x0f 0x0e
DYNPD/FEATURE 0x00 0x00 0x00 0x00
Data Rate 1MBPS 1MBPS
Model nRF24L01+ nRF24L01+
CRC Length 16 bits 16 bits
PA Power PA_MIN PA_MIN

Also have a postet this issue/question at stackoverflow.

Using the _debug flag right before the write, the output is the following, but only the first time I use the write command. All following write's have no impact. Also if I do radio.end() and start again, write doesn't seem to do anything.

Set CE low.
setStates { TX_ADDR: <Buffer f0 f0 f0 f0 d2>, PRIM_RX: false, RX_ADDR_P0: <Buffer f0 f0 f0 f0 d2> }
// Right after the first tx.write()
execCommand [ 'R_REGISTER', 0 ] 1
 - exec read: <Buffer 0e 0e>
execCommand [ 'W_REGISTER', 10 ] <Buffer f0 f0 f0 f0 d2>
execCommand [ 'W_REGISTER', 16 ] <Buffer f0 f0 f0 f0 d2>
execCommand W_TX_PAYLOAD <Buffer a0 a0 a0 a0 a0>

The tx.write(buffer) function everytime I restart the application returns exactly 12x true, followed by false in an interval of 1s.