Skip to content

RF24 not working with /dev/spidev0.0 but well with native C++ lib #54

@freegroup

Description

@freegroup

Dear

sorry for the noise but I have some problems to get your lib up and running
on my Raspberry Pi 3.

I want use Node.js with your pure and clean JS code but the code didn't find my device.

var NRF24 = require("nrf"),
    spiDev = "/dev/spidev0.0",
    cePin = 24, irqPin = 25;

var nrf = NRF24.connect(spiDev, cePin, irqPin);
//nrf._debug = true;
nrf.channel(0x4c)
    .transmitPower('PA_MAX')
    .dataRate('1Mbps')
    .crcBytes(2)
    .autoRetransmit({count:15, delay:500})
    .begin(function () {
        console.log("PONG back");
        var rx = nrf.openPipe('rx', 0xF0F0F0F000, {
            size: 2,
            autoAck: true
        });

        rx.on('data', function (d) {
            console.log("data");
            console.log("Got data, will respond", d.readUInt32BE(0));
        })
//nrf._debug=true;
nrf.printDetails();
});
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

native C++ code is working well (working GPIO) with the same wiring

#include <RF24/RF24.h>
#include <RF24Network/RF24Network.h>
#include <iostream>
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

/**
 * g++ -L/usr/lib main.cc -I/usr/include -o main -lrrd
 **/

// CE Pin, CSN Pin, SPI Speed
RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ);

RF24Network network(radio);

// Constants that identifies this node
const uint16_t pi_node = 0;

// Time between checking for packets (in ms)
const unsigned long interval = 2000;

// Structure of our message
struct message_t {
  float temperature;
  float humidity;
};

int main(int argc, char** argv)
{
    // Initialize all radio related modules
    radio.begin();
    delay(5);
    network.begin(90, pi_node);

    // Print some radio details (for debug purposes)
    radio.printDetails();
    printf("Ready to receive...\n");

    // Now do this forever (until cancelled by user)
    while(1)
    {
        // Get the latest network info
        network.update();
        printf(".\n");
        // Enter this loop if there is data available to be read,
        // and continue it as long as there is more data to read
        while ( network.available() ) {
  printf("network available\n");
            RF24NetworkHeader header;
            message_t message;
            // Have a peek at the data to see the header type
            network.peek(header);
            // We can only handle the Temperature type for now
            if (header.type == 't') {
                // Read the message
                network.read(header, &message, sizeof(message));
                // Print it out
                printf("Temperature received from node %i: %f \n", header.from_node, message.temperature);
            } else {
                // This is not a type we recognize
                network.read(header, &message, sizeof(message));
                printf("Unknown message received from node %i\n", header.from_node);
            }
        }

        // Wait a bit before we start over again
        delay(2000);
    }

    // last thing we do before we end things
    return 0;
}
================ SPI Configuration ================
CSN Pin      = CE0 (PI Hardware Driven)
CE Pin       = Custom GPIO22
Clock Speed  = 8 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     = 0xccccccccc3 0xcccccccc3c
RX_ADDR_P2-5     = 0x33 0xce 0x3e 0xe3
TX_ADDR      = 0xe7e7e7e7e7
RX_PW_P0-6   = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA        = 0x3e
EN_RXADDR    = 0x3f
RF_CH        = 0x5a
RF_SETUP     = 0x07
CONFIG       = 0x0f
DYNPD/FEATURE    = 0x3f 0x04
Data Rate    = 1MBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_MAX
Ready to receive...

It would be great if you have some ideas whats could be wrong on my side.

Best Regards

Andreas

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