Skip to content

Problems getting node-nrf on Rasp Pi to talk to tmrh20 on Arduino Uno. #57

@runia1

Description

@runia1

My goal is being able to send commands from my nodejs script and have the arduino pick up the command and do something. As a proof of concept, I'm just trying to get the Arduino to print out a message when data comes in.

My devices:

  1. Raspberry pi 1B (Running this library on Node v6.9.1)
var NRF24 = require('nrf');
var spiDev = "/dev/spidev0.0";
//pins for rasp pi 1B according to: https://gist.github.com/natevw/5789019
var cePin = 18, irqPin = 22;

var radio = NRF24.connect(spiDev, cePin, irqPin);
radio.channel(0x4c)
  .transmitPower('PA_MAX')
  .dataRate('1Mbps')
  .crcBytes(2)
  .autoRetransmit({count:5, delay:4000})
  .begin(function () {
    //open pipe for sending
    var tx = radio.openPipe('tx', 0xD2F0F0F0F0);

    //when the transmitter is ready...
    tx.on('ready', function () {
      //radio.printDetails();
      for(var i=1; i<=100; i++) {
        var data = 'sending ' + i;

        console.log(data);
        tx.write(data);
      }
    });
  });

This runs without errors, and appears to send out data but I never receive anything on my Arduino. When I uncomment the printDetails() I get this:

SPI device:      /dev/spidev0.0
CE GPIO:         18
IRQ GPIO:        22
STATUS:          0xe RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0–1:    0xd2f0f0f0f0 0x65646f4e31
RX_ADDR_P2–5:    0xc3 0xc4 0xc5 0xc6
TX_ADDR:         0xd2f0f0f0f0
RX_PW_P0–5:      0x0 0x0 0x0 0x0 0x0 0x0
EN_AA:           0x3f
EN_RXADDR:       0x01
RF_CH:           0x4c
RF_SETUP:        0x07
CONFIG:          0x0e
DYNPD/FEATURE:   0x03 0x07
Data Rate:       1Mbps
Model:           nRF24L01+
CRC Length:      16 bits
PA Power:        PA_MAX

Which leads me to believe the Pi has a good connection to the NRF chip (It's able to assign the address and other configs.)

  1. Arduino Uno R3 (Running tmrh20 c++ lib)
#include <printf.h>
#include <SPI.h>
#include "RF24.h"

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7,8);

uint64_t recieveAddress = 0xD2F0F0F0F0LL;

void setup() {
  Serial.begin(115200);
  printf_begin();
  Serial.println(F("Arduino is being setup()."));

  radio.begin();
  radio.setChannel(0x4c);           //Physical channel: 0x4c, AKA: 76
  radio.setPALevel(RF24_PA_MAX);    //Transmit Power: MAX
  radio.setDataRate(RF24_1MBPS);    //Data Rate: 1Mbps
  radio.setCRCLength(RF24_CRC_16);  //CRC Length: 16 bit, AKA: 2 bytes.
  radio.setRetries(15, 5);         //Auto-retransmit: 5 times, once every 4000us.
  radio.setAutoAck(true);

  radio.openReadingPipe(1, recieveAddress);
  
  // Start the radio listening for data
  radio.startListening();

  Serial.println(F("Arduino finished setup. Radio is listening."));
  radio.printDetails();
}

void loop() {
  unsigned long data;
  
  if(radio.available()) {
    //radio.read(&data, sizeof(data));

    //JUST PRINT OUT THAT THERE IS DATA TO READ, WE DON'T CARE WHAT IT IS YET.
    Serial.print(F("Recieving data: "));
    //Serial.println(data);
  }

}

Results of the printDetails()

STATUS		 = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1	 = 0x65646f4e31 0xd2f0f0f0f0
RX_ADDR_P2-5	 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR		 = 0x65646f4e31
RX_PW_P0-6	 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA		 = 0x3f
EN_RXADDR	 = 0x02
RF_CH		 = 0x4c
RF_SETUP	 = 0x03
CONFIG		 = 0x0f
DYNPD/FEATURE	 = 0x00 0x00
Data Rate	 = 1MBPS
Model		 = nRF24L01+
  CRC Length	 = 16 bits
PA Power	 = PA_LOW

So I'm pretty sure the wiring is correct on the arduino as well, as I'm able to set the address and other configs.

Troubleshooting I've tried

  • Arduino Uno to another Uno both with same wiring and both running the tmrh20 Lib. These two were able to talk back and forth, so I'm pretty certain I have the wiring right and that I'm using the library right on the Uno's end.

Any help is appreciated, I'm not really sure where to go from here. Maybe I'm not writing to the tx stream correctly? I'm new to nodejs streams but I'm pretty sure you just have to do a tx.write("some data"); to send out some data correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions