jack09
Posts: 3
Joined: Fri Nov 07, 2014 4:53 am

Issue with Raspberry pi B+ and nRF24L01 transreceiver

Fri Nov 07, 2014 5:07 am

I am trying to set up the nRF24L01 transceiver to Raspberry Pi B+ using the RF24 library but for some reason its not working at all. Here is how the connection is setup between the transceiver and Pi:
RF | Pi
VCC 3.3V
GND GND
CSN PIN#24
CE PIN#22
MUSI PIN#19
SCK PIN#23
MISO PIN#21

Output from ./rpi-hub:
================ SPI Configuration ================
CSN Pin = CE1 (PI Hardware Driven)
CE Pin = Custom GPIO22
Clock Speed = 8 Mhz
================ NRF Configuration ================
STATUS = 0x00 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-6 = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x00
RF_CH = 0x00
RF_SETUP = 0x00
CONFIG = 0x00
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01
CRC Length = Disabled
PA Power = PA_MIN
Output below : <cursor just sits there>
===========================================

Output from ./gettingstarted
===========================
RF24/examples/pingtest/
================ 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 = 0x65646f4e32 0x65646f4e31
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x65646f4e32
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0e
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX

************ Role Setup ***********
Choose a role: Enter 0 for pong_back, 1 for ping_out (CTRL+C to exit)
>

Any help is appreciated. thanks

rohitranjan1991
Posts: 1
Joined: Sat Nov 08, 2014 6:18 am

Re: Issue with Raspberry pi B+ and nRF24L01 transreceiver

Sat Nov 08, 2014 6:22 am

did u find the answer ?


jack09
Posts: 3
Joined: Fri Nov 07, 2014 4:53 am

Re: Issue with Raspberry pi B+ and nRF24L01 transreceiver

Sat Nov 08, 2014 4:20 pm

rohitranjan1991 wrote:did u find the answer ?
Nope. Are you having the same issue?

AlexHardy
Posts: 6
Joined: Thu Sep 26, 2013 6:12 pm

Re: Raspberry pi B+ and nRF24L01 using python

Wed Nov 26, 2014 10:14 pm

After several attempts to read data sent from an Arduino using the various C, C++ libraries without success. I found this blogg:
http://blog.riyas.org/2014/08/raspberry ... eless.html
This option uses python on the Raspberry Pi and you need to follow the instructions on the blog to install the nrf24rpihub modules.
I have a DHT11 to send temperature and humidity and a BH1750 to send lux data. I modified the 'raspberryfriendly.py' to read the data.
This may not be of use for your particular requirements but may save others a bit of time.
Arduino code

Code: Select all

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include <DHT.h>
#include <BH1750.h>
#include "nRF24L01.h"
#include "RF24.h"

#define LED 7
#define DHTPIN 2
#define DHTTYPE DHT11

//const int chipSelect = 10;
const int SER = 8;
const int LATCH = 9;
const int CLK = 10;

//nRF24 set the pin 9 to CE and 10 to CSN/SS
// Cables are:
//     SS       -> 10
//     MOSI     -> 11
//     MISO     -> 12
//     SCK      -> 13

//for nrf24 debug
int serial_putc( char c, FILE * ) 
{
  Serial.write( c );
  return c;
} 
void printf_begin(void)
{
  fdevopen( &serial_putc, 0 );
}

RF24 radio(9,10);
DHT dht(DHTPIN,DHTTYPE);
BH1750 lightMeter;

const uint64_t pipes[2] = { 0xF0F0F0F0E1LL,0xF0F0F0F0D2LL };

void setup(void) {
  Serial.begin(9600); //Debug 
  printf_begin();
  dht.begin();
  lightMeter.begin();
  //nRF24 configurations
  Wire.begin();
  pinMode(SER, OUTPUT);
  pinMode(LATCH,OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(LED,OUTPUT);
  //nRF24 configurations
  radio.begin();
  radio.setChannel(0x4c);
  radio.setAutoAck(1);
  radio.setRetries(15,15);
  radio.setDataRate(RF24_250KBPS);
  radio.setPayloadSize(32);
  radio.openReadingPipe(1,pipes[0]);
  radio.openWritingPipe(pipes[1]);
  radio.startListening();
  radio.printDetails(); //for Debugging
}

void loop() {
  int SendPayload[4] ;
  
  //Get data from sensors
  int t = dht.readTemperature(); // deg C
  int f = dht.readTemperature(true); // deg F
  int h = dht.readHumidity();
  
  if (isnan(t)){
    Serial.println("Sensor read failed");
    return;
  }
  int lux = lightMeter.readLightLevel();  
  // Assign data to payload array
    
  SendPayload[0] = t;
  Serial.print("degC: ");
  Serial.println(SendPayload[0]);
  SendPayload[1] = f;
  Serial.print("degF: ");
  Serial.println(SendPayload[1]);
  SendPayload[2] = h;
  Serial.print("Hum: ");
  Serial.println(SendPayload[2]);
  Serial.print("Lux : ");
  SendPayload[3] = lux;
  Serial.println(SendPayload[3]);
  radio.stopListening();
  bool ok = radio.write(&SendPayload,sizeof(SendPayload));
  radio.startListening();
  digitalWrite(LED,HIGH);
  delay(1000);  
  digitalWrite(LED,LOW);
}
RPI code

Code: Select all

#!/usr/bin/python
# raspberry pi nrf24l01 hub
# Credits to python port of nrf24l01, Joao Paulo Barrac and 
# maniacbugs original c library
# Modified from 'raspberryfriend.py' at http://blog.riyas.org
# Data sent from Arduino - "ardiuno_to_pi_dht11_bh1750.ino"
# 
#  NRF24L01/RPi Model B+ connections:-
#  -----------------------------------
#	NRF24		RPi- pin
#	1 GND		GND
#	2 3.3v	1 3.3v
#	3 CE		22 GPIO25
#	4 CSN		24 CE0_0
#	5 SCK		23 SCLK_0
#	6 MOSI	19 MOSI_0
#	7 MISO	21 MISO_0
#	8 N/C
#  -----------------------------------
#

from nrf24 import NRF24
import time
from time import gmtime, strftime
import RPi.GPIO as GPIO
try:
    pipes = [[0xf0, 0xf0, 0xf0, 0xf0, 0xe1], [0xf0, 0xf0, 0xf0, 0xf0, 0xd2]]

    radio = NRF24()
    radio.begin(0, 0,25,18)
    radio.setRetries(15,15)
    radio.setPayloadSize(32)
    radio.setChannel(0x4c)
    radio.setDataRate(NRF24.BR_250KBPS)
    radio.setPALevel(NRF24.PA_MAX)
    radio.setAutoAck(1)
    radio.openWritingPipe(pipes[0])
    radio.openReadingPipe(1, pipes[1])
    radio.startListening()
    radio.stopListening()
    radio.printDetails()
    radio.startListening()

    while True:
        pipe = [0]
        while not radio.available(pipe, True):
            time.sleep(1000/1000000.0)
        recv_buffer =[]
        radio.read(recv_buffer)
        #print recv_buffer
        print "Deg C: ",recv_buffer[0]
        print "Deg F: ",recv_buffer[2]
        print "Humidity: ",recv_buffer[4]
        print "Light level (lux): ",recv_buffer[6]
except KeyboardInterrupt:
    print "\n Program stopped \n"
    
finally:
    GPIO.cleanup()	//stops warning message
        

Return to “Automation, sensing and robotics”