maniacbug / rf24 Goto Github PK
View Code? Open in Web Editor NEWArduino driver for nRF24L01
Home Page: http://maniacbug.github.com/RF24
Arduino driver for nRF24L01
Home Page: http://maniacbug.github.com/RF24
This library is not maintained by anyone. If you wish to get any support or updates please go to:
Hello,
thank you ManiacBug for RF24 and RF24Network!
I have a question. Is there a way to check signal strength between trasmitter and receiver??
Thanks,
Arthur.
[PS Chapter 6.4 of nRf24L01+ documentation (http://www.nordicsemi.com/kor/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf) describes something like RPD (Received Power Detector measurements).]
Hello,
I'm trying to connect a raspberry and Arduino, When I try to make a delivery from raspberry to Arduino Arduino packets arrive at, but do not receive the ACK in the raspberry.
otherwise, when sending packages from the Arduino to the raspberry everything works correctly.
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include "./RF24.h"
#include <wiringPi.h>
#include <errno.h>
#define INTERRUPT 4
using namespace std; // CE Pin, CSN Pin, SPI Speed
// Setup for GPIO 22 CE and CE0 CSN with SPI Speed @ 8Mhz
RF24 radio(RPI_V2_GPIO_P1_15, RPI_V2_GPIO_P1_24, BCM2835_SPI_SPEED_8MHZ);
// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xFFFFFFFFFFLL, 0x0000000002LL };
char receive_payload[33],output[32]; // +1 to allow room for a terminating NULL char
int count = 0;
bool tx,rx,fail;
float h,t,f;
void interrupt(){
radio.whatHappened( tx,fail,rx);
if(rx){
printf("recibido: ");
count ++;
if(radio.available()){
while(radio.available()){
radio.read( receive_payload, 32 );
memcpy(&h, (receive_payload)+10, 4);
memcpy(&t, (receive_payload)+14, 4);
memcpy(&f, (receive_payload)+18, 4);
printf("H:%f C:%f F:%f\n", h,t,f);
}
}
}
if(tx){
printf("enviado\n");
radio.startListening();
}
if(fail){
printf("fallo\n");
radio.startListening();
}
}
int main(int argc, char** argv){
radio.begin();
radio.setRetries(5,15);
radio.setPALevel(RF24_PA_HIGH);
radio.setAutoAck(1);
radio.setChannel(50);
radio.setDataRate(RF24_1MBPS);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1,pipes[0]);
radio.printDetails();
radio.stopListening();
if (wiringPiSetup () < 0) {
fprintf (stderr, "Unable to setup wiringPi: %s\n", strerror (errno));
return 1;
}
// set Pin 17/0 generate an interrupt on high-to-low transitions
// and attach myInterrupt() to the interrupt
if ( wiringPiISR (INTERRUPT, INT_EDGE_FALLING, &interrupt) < 0 ) {
fprintf (stderr, "Unable to setup ISR: %s\n", strerror (errno));
return 1;
}
radio.startListening();
output[0] = 'G';
string txt;
while(1){
cin>>txt;
radio.stopListening();
radio.startWrite( &output , 32, 0);
}
}
#include <Timer.h>
#include <Event.h>
#include <SPI.h>
#include <EEPROM.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <TimerOne.h>
#include "DHT.h"
#include "printf.h"
#define DHTPIN 4
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);
//MEMORY POSITIONS
#define CHANNEL_POSITION 10
#define POWER_POSITION 12
uint64_t address_server = 0xFFFFFFFFFFLL;
uint64_t address_cliente = 0x0000000002LL;
uint8_t output[32];
String inputString = "";
String serialAction = "";
boolean stringComplete = false, readValue=false;
//ID identificador de tipo de dispositivo
#define TYPE "0003" //INTERRUPTOR
// POSITION VALUES PAYLOAD PARAMS [ACTION]
#define ACTION_B 0
// ACTION VALUES
#define GET 'G'
#define OK 'O'
#define FAIL 'F'
// PIN RELES
#define LED 9
#define BUTTON 3
// Hardware configuration
RF24 radio(7,8);
bool tx,fail,rx;
// PAQUETE RECIVIDO
uint8_t receive_payload[33];
uint8_t action;
/********************** Setup *********************/
void setup(){
pinMode(BUTTON,INPUT_PULLUP);
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
delay(500);
Serial.begin(115200);
inputString.reserve(200);
radio.begin();
digitalWrite(LED, LOW);
printf_begin();
radio.setPALevel(readData(POWER_POSITION));
radio.setDataRate(RF24_1MBPS);
radio.setAutoAck(true);
radio.setRetries(5,15);
radio.setChannel(readData(CHANNEL_POSITION));
readAddr(&address_cliente);
radio.openWritingPipe(address_server);
radio.openReadingPipe(1,address_cliente);
radio.printDetails();
radio.whatHappened(tx,fail,rx);
radio.startListening();
delay(50);
attachInterrupt(0, check_radio, LOW);
//attachInterrupt(1, push_interrupt,RISING);
delay(50);
dht.begin();
readTemp();
Serial.println("INICIADO");
}
/********************** Main Loop *********************/
int boton = HIGH;
int pulsacion = 0;
void loop() {
boton = digitalRead(BUTTON);
if( boton == LOW && pulsacion == 0){
output[9] = GET;
radio.stopListening();
radio.startWrite( &output , 32, 0);
pulsacion = 1;
}
if( boton == HIGH && pulsacion == 1){
pulsacion = 0;
digitalWrite(LED,!digitalRead(LED));
delay(100);
}
}
float h,t,f;
void readTemp(){
int i;
h = dht.readHumidity();
t = dht.readTemperature(); //Celsius
f = dht.readTemperature(true); //Fahrenheit
for(i=0;i<4;i++){
output[10+i]= ((uint8_t*)(&h))[i];
output[14+i]= ((uint8_t*)(&t))[i];
output[18+i]= ((uint8_t*)(&f))[i];
}
}
/********************** Interrupt RADIO *********************/
void check_radio(void)
{
radio.whatHappened(tx,fail,rx);
if ( tx ) { //transmisin completada
radio.startListening();
printf("Ack Payload:Send\n\r");
}
if ( fail ) {
delay(100);
radio.stopListening();
radio.startWrite( &output , 32, 0);
printf("Ack Payload:Failed\n\r");
}
if ( rx ){
radio.read( receive_payload, 32 );
Serial.println(radio.isAckPayloadAvailable());
Serial.println(radio.testRPD());
action = receive_payload[ACTION_B];
if(action == GET){
output[9] = GET;
}else{
output[9] = FAIL;
}
//radio.stopListening();
//delay(200);
//radio.startWrite( &output , 32, 0);
}
}
void readAddr(uint64_t* addr){
short pos;
for (pos = 0; pos < 8; pos++){
((uint8_t*)addr)[pos] = EEPROM.read(pos);
output[pos] = ((uint8_t*)addr)[pos];
}
}
void writeAddr(uint64_t* addr){
short pos;
for (pos = 0; pos < 8; pos++){
EEPROM.write(pos, ((uint8_t*)addr)[pos]);
output[pos] = ((uint8_t*)addr)[pos];
}
}
void saveData(int pos, uint8_t ch){
EEPROM.write(pos, ch);
}
uint8_t readData(int pos){
return EEPROM.read(pos);
}
}
Thank you very much.
Software in such a bad state should be kept under lid. It lacks directions on how to setup. It has several severe bugs and it spends its time in infinite loops. Stay away from this library.
I'm not sure where to post this issue because I think the bug is with @jonathongrigg's fork.
When I try to use the pyRF24 Cython wrapper, I get this (not very verbose and no traceback) error
can't send spi message: Invalid argument
Is this something to do with NOOBS now using Device Tree and the Pi 2 also using a different peripheral base as mentioned in this thread?
I have a small trial code with a struct to be send. Works great. But when I enter directly after the write() a delay greater than 10, No data can be received and the write function returnes a false.
Her the code snipped:
void loop()
{
remPack.valXJoy = analogRead(JOYSTICK_X);
remPack.valYJoy = analogRead(JOYSTICK_Y);
Serial.print("X= "); Serial.print(remPack.valXJoy);Serial.print(" Y= "); Serial.println(remPack.valYJoy);
radio.write( &remPack, sizeof(remPack) );
delay(10);
}
On the receiver side I tried both if ( radio.available() ) and while ( radio.available() ). Both with the same result:
Snipped:
if ( radio.available() )
{
bool done = false;
while (!done)
{
done = radio.read( &remPack, sizeof(remPack) );
}
This is an issue, that is allready in discussion also on stackexchange: https://arduino.stackexchange.com/questions/8129/arduino-rf24-library-delay-after-write-function-causes-no-byte-availability
But here is no real solution for this problem.
The following lines inside setup() should NOT be commented. This makes the receiver unable to receive anything unless you set it to Sender and then back to Receiver (because doing so does setup it correctly). Some new users are having problems because of this, so I thought I should make the cause clear. After uncommenting and uploading, both Arduinos communicate perfectly.
//if ( role == role_ping_out )
{
//radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]);
}
//else
{
//radio.openWritingPipe(pipes[1]);
//radio.openReadingPipe(1,pipes[0]);
}
I have read many issues regarding the RF24 not working reliably. I have had issues myself. Power stability seems to be the major factor affecting this device. Placing a tantalum 10uF capacitor and a ceramic 0.01uF capacitor in parallel across the power input pins (in close proximity to the module) seems to fix the stability problems. Electrolytic will work, but tantalum is preferred. Many small caps can be used instead of ceramic but they must be types used for standard "de-coupling" which is well known with all TTL electronics. I am a seasoned electrical engineer and am not surprised that this solution is needed based upon the electrical system the RF24 module represents.
When I visit the Downloads page via any of the several links to it, it says "There aren't any uploads for this repository".
URL is: https://github.com/maniacbug/RF24/downloads
I am trying to establish a connection between my Arduino Uno and RPi.
I followed the connections and run the Getting Started example on the Arduino and "pongtest" on the Pi
Output on Arduino -
�¼8)>±û8<«<²)=��á'kmcû»%?'ãpdq1>6ãh>1>�ñ4{"j#bca(�&UOê��eTY)`
RF24/examples/GettingStarted/
ROLE: Pong back
*** PRESS 'T' to begin transmitting to the other node
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 � = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 � = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 � = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR � = 0x03
RF_CH = 0x4c
RF_SETUP � = 0x07
CONFIG = 0x0f
DYNPD/FEATURE � = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
Now sending 7010...failed.
Failed, response timed out.
Now sending 8286...failed.
Failed, response timed out.
Now sending 9560...failed.
Failed, response timed out.
Now sending 10833...failed.
Failed, response timed out.
Output on Pi -
RF24/examples/pingpair/
ROLE: Pong back
SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0d2 0xf0f0f0f0e1
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
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
Now when I change to "R" mode, output on Arduino :
*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK
Output on Pi running "pingtest"
RF24/examples/pingpair/
ROLE: Ping out
SPI device = /dev/spidev0.0
SPI speed = 8000000
CE GPIO = 25
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x00
EN_RXADDR = 0x03
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
Now sending 3411559399...ok...Failed, response timed out.
Now sending 3411560616...ok...Failed, response timed out.
Now sending 3411561831...ok...Failed, response timed out.
I cannot establish communication between the 2 devices. I have checked, double checked and triple checked the connections. They're all correct. Using connections as mentioned in http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/
Also, both devices are in the same room so range is not a problem.
Hi, I have a Wring mini v1.0 board(atmega128). I want to use nRF24L01 modules with your RF24 library. But I can't complie the sketch. There are several errors following:
In file included from C:\Program Files\Wiring\libraries\RF24/RF24.h:18,
error: C:\Program Files\Wiring\libraries\RF24/RF24_config.h:28: error: 'HardwareSPI' does not name a type
C:\Program Files\Wiring\libraries\RF24/RF24_config.h:54: error: multiple types in one declaration
C:\Program Files\Wiring\libraries\RF24/RF24_config.h:54: error: declaration does not declare anything
Please let me know how can I modify RF24 library.
Thanks in advance,
Jeong
in july of 2014 i got the ping response example sketch to work.
Now im trying all the examples and nothing works. I have tried all the available libraries on the internet mirf, RF(radiohead), and maniac.
Now sending length 22...Got response size=255 value=ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
Now sending length 16...Failed, response timed out.
Now sending length 18...Failed, response timed out.
Now sending length 20...Failed, response timed out.
Now sending length 22...Failed, response timed out.
These are the serial prints from the pingpair_dyn sketch.
What can I do? all the hardware connections are correct. Perhaps one or both of the boards are broken? i am using sparkfun nrf+ w/ breakout.
Earlier i did not get a failed response i received some sort of communication but it was printing the odd characters. I dont think the boards have errored.
I am using the leonardo. arduno IDE 1.0.6. and i am using the most recent github of maniac release.
Please help.
Hello, I am using the RF24 library with ethercard, I am wondering if I can send the node pipe in a command to my base station instead of having the node pipe fixed in the code.
Something like: 192.168.0.10/?nodePipe=0xF0F0F0F0D2LL&message=hello
if(strstr((char *)Ethernet::buffer + pos, "GET /?nodePipe=") != 0) {
uint64_t nodePipe = (the node pipe);
radio.openWritingPipe(nodePipe);
radio.stopListening();
bool ok = radio.write( &message, sizeof(unsigned long) );
}
The Node will have the BS pipe added fixed in the code to respond back.
Is this possible?
When trying to compile sensor net example from the zip it reports a eeprom_update_block is not declared.
Hi!
I started to use an nrf24 enabled boot loader. After that your RF24 library stopped working.
That's because the boot loader uses 3 byte addresses, and RF24 wants to use 5, but leaves the SETUP_AW on the previous.
The solution is to initialize that register:
// 5 byte addresses
write_register(SETUP_AW, 0x03);
Regards,
Gábor
Payload ack example does not work. Not sure if its a Arduino issue (v1.0.5) or the example code.
Hello Thanks for writing this great code. Is it possible to get RSSI (signal strength indicator) ? Rgds Matt
Hello, since this is the main lib and it doesn't seem to be maintained anymore, I just thought I'd mention here that I've been maintaining an updated/optimized fork of the library which simply builds upon the foundations laid by maniacbug, and incorporates changes (among others) from the stanleyseow , gcopeland , and jscrane forks. Many if not all of the bugs/issues are also fixed, and it supports hardware from ATTiny to RPi and Galileo. It seems I cannot submit a pull request, because someone already submitted one with a slightly misleading title, #45
Hi maniacbug,
I have set the nRF24L01+ module power output using this code: radio.setPALevel(RF24_PA_HIGH);
When I then check this using radio.printDetails(); I get Power = LA_MED
Also I believe we are using these mnemonics?
"According to 6.5 of the nRF24L01+ specification sheet, they translate to: RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_MED=-6dBM, and RF24_PA_HIGH=0dBm."
RF24_PA_MED will not compile as get this message = error: 'RF24_PA_MED' was not declared in this scope. All other mnemonics work.
If I use RF24_PA_MIN ,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX these all work.
Regards
Gary
These lines are commented out in begin fuction which causes it to always return false
setup = read_register(RF_SETUP);
if( setup == 0b00001110 ) // register default for nRF24L01P
{
p_variant = true ;
}
Hi,
I am really new to Arduino & C++.
I tried the example. I found that removing printf.h in example will cause the Arduino(Leonardo in my case) become Unknown Device in Windows 7.
By observing the LED blink. I believe the Sketch cause the Arduino fail to startup.
I have no idea to dig the source of problem out. but try and error by elimination, I found that removing printf.h will cause this problem.
Thanks
Hello,
thanks a lot for this library and all your public explanations of your work. It's great not to have to re-do things from scratch.
nRF24L01.h defines the value CONFIG to 0x00. I believe this not to be very smart, because it means that any use of the symbolic name CONFIG in a custom sketch or other lib (like JeeLib) will not build properly.
When implementing a device driver, it is common for the defines to be prefixed with the name, such as :
RF24L01_CONFIG
I would advise you to do that - I can make the patch if you're interested.
As it stands, RF24 is incompatible with JeeLib unless you include it after JeeLib includes. Not a big deal, but it may confuse beginners.
Thanks!
EDITED: Investigating further more the feedback from the community of DigiX, it could be resolved and not an issue with RF24 library to begin with.
Hello,
I run this library and when there are transmission problems (i don't know exactly what) the last character of the last message is repeated n times (n = payload of the previous message) in the message following this previous one.
The problem can be once a day or twice/hour, very erratic, all the rest of the sketch is running fine but nrf24 library stops receiving and talking.
My configuration is last library version, nRF24+PA+LNA, Arduino 1.5.6-r2 or 1.0.5-r2 (I tried both)
Let me know for more information.
Pierre
I've been working on a project using your libraries and the Nrf24+ modules.
Setup:
2 Nano's with NRF24+ attached to each. One I call the "controller" which sends command to the "Target".
Upon start up the controller polls for targets. It sends a 'U' to all 5 channels (I can have up to 5 targets in this application) and then loops for 10 seconds to send an 'R' on each channel and wait for a reply from the remote target. If I receive a reply, then I know that target is online.
Problem:
When I have a target connected via USB and have the Serial Monitor window open, the target radio works intermittently. The target will be in the loop() where it looks for radio.available() and if there is data, I process it. However, when the Serial Monitor is up, the radio.available() returns false most of the time even though data is being sent.
If I close the Serial Monitor -- No other changes are made -- then it works as expected. I open the Serial Monitor (Ctrl-Shift-M) and the problem comes back. I can cause this behavior at will by using the Serial Montior.
Do you have any suggestions as to what would be the reason for this? I'm using the original NRF24 library, not the new forked one. Thanks in advance for anyone who has suggestions.
Chris
I noticed a small issue, and realized it is described in a note in the datasheet on page 30:
"Note: Always check if the packet width reported is 32 bytes or shorter when using the
R_RX_PL_WID command. If its width is longer than 32 bytes then the packet contains errors and must be discarded. Discard the packet by using the Flush_RXcommand."
I have confirmed this is an issue in practical use, and that discarding the packet clears the issue.
In RF24::startWrite, there is a coded delay of 15us after power up. This time is in the data sheet as Tpd2stby and only valid for chips using an external clock. I'm using a Sparkfun board (https://www.sparkfun.com/products/691) and couldn't find Ls for the crystal on it, but I was getting odd behavior with the default setting of 150us. I bumped it up to 4ms and all was well.
R24.cpp R24::write() the line:
status = read_register(OBSERVE_TX,&observe_tx,1);
should be:
status = read_register(STATUS);
because your registry status bits gert used on the status:
while( ! ( status & ( _BV(TX_DS) | _BV(MAX_RT) ) ) && ( millis() - sent_at < timeout ) );
RF24::whatHappened():
uint8_t status = write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
should be:
uint8_t status = read_register(STATUS);
and reset after:
// Report to the user what happened
tx_ok = status & _BV(TX_DS);
tx_fail = status & _BV(MAX_RT);
rx_ready = status & _BV(RX_DR);
status = write_register(STATUS, _BV(TX_DS) | _BV(MAX_RT) );
return;
Michael Spohnholtz
ps great work,just stated learning arduino and r24 has been a great learning project! thanks! You live in my part of the woods, i live in lynnwood wa... small world.
Hi Guys
I have a few of these units lying at home and cant get them to work , I found this site lastweek and have been trying to get the” getting started” example working but with no luck, checked all the wires 4 times made all the libraries local in the Pde to try cancel out file path issues , but still nothing when i start the serial monitor next to all the Config print lines I get 0xff so it seesm like the radio doesnt int. properly . any ideas?
https://github.com/maniacbug/RF24/blob/master/RF24.cpp#L356
According to nRF24L01 documentation B0100
in ARD
in SETUP_RETR
register stands for 1250uS delay (see page 54 of documentation with registers description) but comment above states that this value should be 1500uS (minimal universal value for the delay).
So the correct value here should be B0101
. :)
Hi,
I tried the RF24 library but it is not printing the debug detail at serial monitor. could you please point me out what wrong i am doing? This issue took a whole day of my frustration. How would i know if my device is not dead, or setup is not wrong?
I am trying the pingpair example, and the printf method working perfect, but the printdetails method is printing nothing.
Anyway the setup is not working although. Could you please tell me if I remove the device at all, whether the printdetails should still work. I am asking this to isolate if the problem with the arduino itself or the problem with the device setup. If it does not print any detail if the device is not at all connection then i am sure that it is not printing for my case becuase of some wrong wiring. If it prints (although some garbage) something without the device connected, then it would be definitely some stdout redirection issue.
Just to add, I added a Serial.println as the first line inside the RF24Debug. printdetails() method, but this Serial.println does not work even. It seems the method is not being called altogether.
Could you please point out whats going wrong in my case?
Thanks in advance,
Debojit
I've an arduino uno and a mega. I tried the GettingStarted project without success.
Mega can send packets and uno can receive them, but mega doesn't receive the ACK's. I already switched the RF modules beetween arduinos with same results.
How can I find uot the problem? Mega doesn't receive or uno doesn't send?
I use arduino ide 1.0.5.
Any suggestions appreciated,
Thanks!
how can i use RF24
for send and transmit for moving acar
Hello,
Just one remark, the Downloads Page is died.
Is-it possible to repair it ?
Thanks a lot
Hi, I'm following your guide at http://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/ and it works fine when used with an Arduino Uno R3, but I'm having troubles when running the exact same code on my Arduino Micro: it seems the setup function crashes somewhere and locks out the board USB serial port.
After some crazy time spent trying to figure this out it seems the problem source is the printf function... ANy idea what I can do regarding this? I've temporarily replaced some printf calls with Serial.print, but I would prefer to go back to your original implementation if possible.
Hi Guys,
I'm facing problem to implement on model nRF24L01 without +, please have you tried with this model?
Tks
First, THANK YOU for this great library!!!. I looked through it whole night last night and I am very impressed with the code. The code is very neat, well written and well documented. You obviously an very experienced C programmer and I learned a lot.
My issue is probably with my modules, but since you know these things inside and out I hope you maybe have some insight for me. I am working with the pingpair_pl.pde example, basically unmodified code. I have it setup and it works sort of, about 95% of the packets that are send are received on the receiver. But only maybe 5% of ACKs are received by the sender. Setting up the debug information I can see that the sender runs out of retries, waiting for the ACK. (I think reading the documentation, the sender only reports a successful send if it received the ACK, otherwise it will retry)
Further if i reverse the roles of sender and receiver than a lot less of the send packets are received. So I assume that either unit "S" has a problem with receiving or unit "R" has a problem with sending.
So my question(s)
Have you experienced something like this, working with these modules? Do you have an idea on how to look deeper? I.e. there a way to verify whether the sender actually send the data? Could this be a mis-tuning issue and doyou know of a way to fix that?
Thanks
Paul
I am running the gettingStarted samples with "+" radios from sparkfun, on Arduino Uno. I use pins 7 and 8 in ordr not to interfere with 10 and 4 which are used for the shield. With only the board everything looks ok. When on one board I stack over the ethernet shield communication has problems:
I'm having a problem compiling the RF24 library in the Arduino 1.01 IDE for Mac
I keep getting this error message:
"In file included from GettingStarted.cpp:21:
/Users/Chow/Google Drive/Arduino/libraries/RF24/RF24.h:25:9: error: invalid suffix "add79a5375479cd29a7433c598b8ce56ee60b" on integer constant
In file included from GettingStarted.cpp:21:
/Users/Chow/Google Drive/Arduino/libraries/RF24/RF24.h:22: error: expected unqualified-id before '<<' token"
I'm using RF24master library with Arduino Mega2560 and nRF24L01 (+) modules.
Unfortunatelly I'm unable to send any packets as I get failed message while trying. (see the attached file).
I've been trying both with no capacitor, 10uF and 47uF one, but without luck. The wiring was checked several times (also checked in board pins are working correctly). My CE is on 53 pin while CSN is on 48 to allow simple connection in bundle. The voltage that the module receives is 3,41 V. Also I've been trying to do so with few examples and all of them have same results. The RF module is powered from Arduino 3,3V pin. The Arduino is powered from the PC via USB cable.
Does anyone knows what might be the problem ?
Thanks in advance.
Big thanks for this amazing libary, at the momment I already tried all the examples included, and even made some modifications.
I want to go further but there are some basic concepts I miss, tried on google, in the main site, taking closer look to the examples, but nothing, I just dont understand some things. I really want to go deeper but I feel a good tutorial is missing. Here are some of the things I dont get.
Whats a pipe? How it changes if I want 2 or 6 nodes to speak.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
What the numbers mean?
Maybe after the explanation, I will figure how to solve the next issue, but just in case; How do I need to set the pipes if my network is static 6 nodes, one base. The nodes some times send data to the base and then the base answers with some other data back to the emiting node...
Thanks for any help!
Hello!
Thank you a lot for this library. I encounter a strange issue, when I let a radio.printDetails() in the setup the serial output and all the arduino stuck... Without everything is fine.
Any idea?
PH
Hi,
I install fork of RF24 for BananaPi. It looks like all is fine (configuration at least). I run this code on BananaPi:
#!/usr/bin/python
from nrf24 import NRF24
import time
pipes = [[0xe7, 0xe7, 0xe7, 0xe7, 0xe7], [0xc2, 0xc2, 0xc2, 0xc2, 0xc2]]
radio = NRF24()
radio.begin(0, 0, 23, 24) # board GPIO.4 == GPIO 23 on 'gpio readall' as CE, board GPIO.5 == GPIO 24 on 'gpio readall' as IRQ
radio.setRetries(15,15)
radio.setPayloadSize(8)
radio.setChannel(0x60)
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
And on Arduino I have
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
RF24 radio(9,10);
const uint64_t pipes[2] = { 0xE7E7E7E7E7, 0xC2C2C2C2C2 };
void setup(void)
{
Serial.begin(57600);
printf_begin();
radio.begin();
radio.setRetries(15,15);
radio.setPayloadSize(8);
radio.setChannel(0x60);
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
radio.startListening();
radio.stopListening();
radio.printDetails();
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
}
void loop(void)
{
const char message[] = "PING";
radio.write(&message, sizeof(message));
delay(1000);
}
Communication dont work properly. This is what Arduino print:
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xc2c2c2c2c2 0xe7e7e7e7e7
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xc2c2c2c2c2
RX_PW_P0-6 = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x60
RF_SETUP = 0x27
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_HIGH
And what I see on BananaPi:
BAPI: revision(1)
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x08 0x08 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x03
RF_CH = 0x60
RF_SETUP = 0x26
SETUP_AW = 0x03
OBSERVE_TX = 0x00
CONFIG = 0x0e
FIFO_STATUS = 0x11
DYNPD = 0x00
FEATURE = 0x00
Data Rate = 250KBPS
Model = nRF24l01+
CRC Length = 16 bits
PA Power = PA_MAX
[80, 73, 78, 71, 0, 0, 0, 0]
Last line ([80, 73, 78, 71, 0, 0, 0, 0]) is repeated after each reset of Arduino - this is text which I want to send - INT to ASCII gives "PING", but only once after reset. Any ideas?
EDIT
Somehow adding
radio.startListening()
before
radio.write(&message, sizeof(message));
fix problem. But why it happens?
The Code appears to return a bool indicating if there is more data to be read (or rather that there is no more data to be read).
bool RF24::read( void* buf, uint8_t len )
{
// Fetch the payload
read_payload( buf, len );
// was this the last of the data available?
return read_register(FIFO_STATUS) & _BV(RX_EMPTY);
}
however the documentation indicates that the return value indicates success in reading the data.
bool RF24::read ( void * buf,
uint8_t len
)
Read the payload.
Return the last payload received
The size of data read is the fixed payload size, see getPayloadSize()
Note:
I specifically chose 'void*' as a data type to make it easier for beginners to use. No casting needed.
Parameters:
buf Pointer to a buffer where the data should be written
len Maximum number of bytes to read into the buffer
Returns:
True if the payload was delivered successfully false if not
Hi all
Thank you very much for the great work in making life so easy with arduino and the RF24
please notice that this library still not work with arduino Due
I am looking forward to use it with my Due board.
thank you again
Mujahed
Hello,
I use Arduino Mega2560 and nRF24L01+
and latest IDE Arduino 1.0.5-r2.
Everything worked fine until I decided to save SRAM
by moving all strings to PROGMEM using this macro I found here:
http://web.archiveorange.com/archive/v/9kgcbyrylQlWrNyNBOjW
class __FlashStringHelper;
#define F(str) reinterpret_cast<__FlashStringHelper *>(PSTR(str))
Then, I can use F(str) in my code like this:
Serial.println(F("Failed to read from DHT22"));
and move this string into PROGMEM from RAM.
Ok. Everything worked fine. I saved a lot of RAM.
Then I added RF24 library from here
https://github.com/maniacbug/RF24
and got this error:
" reinterpret_cast from type 'const char_'
to type '_FlashStringHelper' casts away constness "
And compiling of my code stopped.
Please, help me.
Thank you.
P.S.
When I include Mirf library from here:
https://github.com/stanleyseow/arduino-nrf24l01
no errors appear. But I am not accustomed to Mirf library yet.
It's a very low level hardware library.
regards
Steve
I can not find the RF24 library. links are broken
I have looked through the code and cannot find where to change the MISO/MOSI/SCK pins from their default definitions:
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11
7 - MISO to Arduino pin 12
I'm using my NRF with a Funduino Joystick Shield, and they map the SPI differently. per http://www.elecfreaks.com/wiki/index.php?title=Joystick_Shield#External_Links
D11 11 SCK
D12 12 MOSI
D13 13 MISO
Note that in order to make the library work with the Joystick shield, I need to figure out a way to flip these 3 pins. Anyone have any idea where these pins are defined in the library?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.