nrf24 / rf24 Goto Github PK
View Code? Open in Web Editor NEWOSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
Home Page: https://nrf24.github.io/RF24
License: GNU General Public License v2.0
OSI Layer 2 driver for nRF24L01 on Arduino & Raspberry Pi/Linux Devices
Home Page: https://nrf24.github.io/RF24
License: GNU General Public License v2.0
Hi, sorry to bother again. I'm stucked on this issue/bug, would like to know if it is a known bug or I am doing something wrong.
Hardware: Raspberry B ver1 and Arduino Nano 328, both with NRF24l01+, filtered DC with capacitors.
How to reproduce:
Alter the gettingstarted.cpp code:
while(1)
infinte loop to exit after a .read()
occurs, perhaps after writing buffer got_time
line 139 .Expected result: the application exit with 0 status.
Actual result: the application exit with segmentation fault.
Additional Info:
in gdb I've found this error
c++ crash in fflush () from /lib/arm-linux-gnueabihf/libc.so.6
It looks like, maybe, that read()
function is messing with the stack, although didn't have a way to test my sentence.
Please note: Gettingstarted application works perfectly fine, I believe it's because the only way to kill it is with ctrl+c.
When trying to setup pyRF24 as per the readme I get the following errors. Not sure if I'm doing something silly?
running build
running build_ext
building 'RF24' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-protpes -fPIC -I/usr/include/python2.7 -c pyRF24.cpp -o build/temp.linux-armv6l-2pyRF24.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/bjC but not for C++ [enabled by default]
pyRF24.cpp: In function ‘void init_module_RF24()’:
pyRF24.cpp:276:81: error: no matches converting function ‘txStandBy’ to type ol (class RF24::)(uint32_t) {aka bool (class RF24::)(unsigned int)}’
/usr/local/include/RF24/RF24.h:450:9: error: candidates are: bool RF24::txStay()
/usr/local/include/RF24/RF24.h:468:9: error: bool RF24::txStay(uint32_t, bool)
error: command 'gcc' failed with exit status 1
Hello,
Thanks for making this library, first of all. It looks promising and I am eager to get it working.
I have been using Greg copelands library up till now on Uno, Mini etc.
I just got my new DUE today, and would like to use your library with it,
but I am getting various compile errors which suggest it does not like the SPI library, e.g.
Arduino: 1.5.8 (Windows 8), Board: "Arduino Due (Programming Port)"
In file included from PRX_SORTER_33.ino:162:0:
\Documents\Arduino\libraries\SPI/SPI.h: In static member function 'static byte SPIClass::transfer(byte)':
\Documents\Arduino\libraries\SPI/SPI.h:56:3: error: 'SPDR' was not declared in this scope
SPDR = _data;
^
\Documents\Arduino\libraries\SPI/SPI.h:57:12: error: 'SPSR' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
^
\Documents\Arduino\libraries\SPI/SPI.h:57:23: error: 'SPIF' was not declared in this scope
while (!(SPSR & _BV(SPIF)))
I have not been able to find any fixes on the arduino forum, so your help would be welcomed.
Hi, I have tried to use the python pingpair_dyn example where the other side is an arduino running the same pingpair_dyn example. When the rpi running python example has received or transmitter data it will freeze and wont even exit with ctrl-C. If I use the c++ version of the example everything works.
Here's the output:
pyRF24/examples/pingpair_dyn/
================ SPI Configuration ================
CSN Pin = CE0 (PI Hardware Driven)
CE Pin = Custom GPIO25
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 = 0x000264000b 0xf0f0f0f0e1
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0d2
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 = 0x3f 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
************ Role Setup ***********
Choose a role: Enter 0 for receiver, 1 for transmitter (CTRL+C to exit) 1
Role: Ping Out, starting transmission
Now sending length 4 ... got response size= 4 value=" ABCD "
Hi,
I see that when I set "setRetries(x,15)" when x is a multiple of 16 I receive a sent error.
On the receiver I can see that the packet is arrived.
The same issue can be found in the ManiacBug version, but there the receiver receives a lot of
packets (15) with the same value.
Bye Andrea
Hi,
first, thanks for your work and sorry for my english.. :)
I used with success your library with a my c++ program that recive a payload from an arduino micro to a Raspberry Pi; the problem is when i try to use the examples done with python (rf24libs/RF24/example_RPi/pingpair_dyn.py).
If i run inside the console "python pingpair_dyn.py" i recive this error:
Traceback (most recent call last):
File "pingpair_dyn.py", line 10, in
from RF24 import *
ImportError: No module named RF24
It's seems that the script didn't find the RF24 library..but..after cloning the libraris with git i have done the command to install libs and headers with success..
How can i use this libraries with python?
Thks.
ruzzine
Hi,
RF24 library works on ATmega32u4 of Arduino Yun?
Thanks
I have a question about that ce(LOW)
in line 689 of RF24.cpp. What is it for?
The state diagram on page 21 of the NRF24L01 datasheet tells us that CE needs to be high to remain in transmit mode. My version of the GettingStarted example freezes in the write method, as neither TX_DS nor MAX_RT come up in the status register, as long as CE is low.
The code works as soon as I comment out line 689.
Hi,
this is not a real bug or issue, yet I want to discuss a strange behaviour:
I finally had time to experiment with the ATTiny85 and RF and got it only to work while using the CE
logic and the pin assignment. If I connect CE
to HIGH, I cannot communicate with the RF module. (CE
is always HIGH in the NerdRalph 3-pin example)
It was strange, so I hocked up a logic analyser only to find out that CE
is not always HIGH (99,9% of the time, yet not always).
I'm using the Receiver part of the GettingStarted example:
void loop(void){
if( radio.available()){
unsigned long got_time; // Variable for the received timestamp
while (radio.available()) { // While there is data ready
radio.read( &got_time, sizeof(unsigned long) ); // Get the payload
}
radio.stopListening(); // First, stop listening so we can talk
radio.write( &got_time, sizeof(unsigned long) ); // Send the final one back.
radio.startListening(); // Now, resume listening so we catch the next packets.
}
}
and every second, I got a small gap of 0.76ms
LOW, 0.74ms
HIGH, 0.28ms
LOW and then almost a second high again. If I only connect CE
with a resistor to high, the module is malfunctioning.
Has anyone an idea why this is happening?
https://github.com/TMRh20/RF24/blob/master/examples/Usage/led_remote/led_remote.pde
line 236: done = radio.read( button_states, num_button_pins );
led_remote:236: error: void value not ignored as it ought to be
in RF24.h read() returns a void, but in the example an int (or something else) is expected.
Compiling for Arduino UNO on windows 7 / 64 bit using the Arduino 1.0.5 rc2 IDE.
Thanks
Hi!
I've been developing a little application to switch lights on and off with raspberry/arduino.
I see that when I use the same procedure as the ping ack example (send, wait for ack), I don't get any response (radio.available() is always 0). Same code was working with old version.
Do you know where can I start to debug it?
I'm trying to convert gettingstarted_call_response to python and I keep getting an error that there is no attribute setPayloadSize. Also when running I cannot send or recieve any data, says write(RF24, int, int) does not match c++ signature write(RF24 {lvalue}, std::string buf, bool multicast). Any information on how to solve this would be greatly helpful.
Hello,
I try to implement a simple handshake. Basically, a terminal is waiting for packets from client. Client send a packet with it's own ID, then the terminal reply by sending back the ID and switch to a comm channel. The client who received his own ID switch channel to communicate with the terminal. So,
Client <-> Terminal
1.Client send(writing pipe: default_terminal_id,data:own address) ------> (Terminal is waiting client)
2.client is waiting confirmation packet <--------- Terminal send(writing pipe: received_id, data:received_id)
3. if received_confirmation code == client_id, switch to communication channel.
For the moment, I just try the 2 first steps and get back the confirmation code. I try to use auto-ack to define when a packet is sent. This simple code doesn't work. I've tried with a volatile variable in the IRQ, updated with whatHappened, and with:
while (! sent) {
sent = radio.write(&local_bike_id,sizeof(uint32_t))
}
Both doesn't work. I'm starting to think it's an hardware problem, even if all the examples seem to work.
I don't know if it's an issue or if it's my fault... Maybe this will work for you. In my case, if the client start to send its id and the terminal is not up, and if I switch it on, the terminal received the id but the client doesn't received the ACK and then doesn't know that the packet was received... You can get the entire code here:
https://gist.github.com/hachpai/7f5ccdddbae9c979fb0e#file-handshake-ino
Thank you a lot for your precious work!
PH
Hello,
I own a pair of nrf24L01+ transceivers.
I tried the GettingStarted example using Arduino IDE 1.0.5: it works at 1 mbps but at 250kbps it just don't work.
I tried reducing the data size to 3 bytes but still does not work.
May be is there anything more to configure before?
I really would like to see compatibility with RFDuino. RFDuino is a Arduino Compatible implementation of Nordics nRF51822 which is Over the Air Compatible with nRF24L01. It should be possible to run this library on a RFDuino. That would shrink the size a lot, and RFDuino is very cheap, too. Featuring a powerful 32-Bit ARM Cortex M0 and a lot more SRAM which should simplify development, too.
I have a question regarding the RPi compatibility.
I've followed the instructions in the readme, and got both the GettingStarted and helloworld_rx programs working, but when I create my own program (server.cpp) in rf24libs/RF24Network/examples and try to compile it using "sudo make server" it shows a fatal error:
server.cpp:16:26: fatal error: ../RF24/RF24.h: no such file or directory
compilation terminated.
If I switch the include lines to
#include "./RF24Network.h"
#include "../RF24/RF24.h"
I get the same error for ./RF24Network.h
I am a 100% sure both files are there. I tried modifying helloworld_rx.cpp and compiling with the same result.
Hey,
I don't know how to make c++ or python program that contain the RF24 and RF24Network library on the raspberry pi. I followed the setup and got both library examples to work and communicate with my arduino. So I tried making my own programs and compiled it with g++ and gcc, kept getting "undefined reference to" errors which I guess means it can't find the libraries. After this I tried using -I/location/of/library or -l/location/of/library to link them to my program. I found a pyRF24 folder which I think links c++ with python so you can use it with python? I tried building and installing the setup.py file but got:
running build
running build_ext
building 'RF24' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -02 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pyRF24.cpp -o build/temp.linux-arm61-2.7/pyRF24.o
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for Ada/C/0bjC but not for C++ [enabled bu default]
pyRF24.cpp:2:28: fatal error: boost/python/hpp: No such file or directory compilation terminated
error: command 'gcc' failed with exit status 1
I think the issue is I don't have boost/python installed. I tryed following the install process on http://www.boost.org/doc/libs/1_42_0/libs/python/doc/building.html but it just confused me.
I can get both RF24 and RF24Network library examples to work with my arduino. But I don't know how to run my own programs on the raspberry pi. I would preferably like to use python (using boost/python wrapper) as I am not familiar to C++. Can you please help me?
I used snippets from this example for IRQ test on Arudino Pro Micro (ATmega32u4):
http://tmrh20.github.io/RF24/pingpair_irq_8ino-example.html
IRQ pin on Arduino works fine (ISR is invoked on LOW/FALLING when I connect pin 7, IRQ4, to GND). However when Arduino (pin 7) is connected to appropriate IRQ pin on radio ISR is not called after radio.startWrite(...). The voltage on IRQ pin of radio module is OK: ~3,5 V.
Would you please make some hint what might be wrong in my settings. I'm little confused if radio module invokes IRQ by default no other library uses it except "RF24".
best regards,
Alexey
I was using maniacbug library but encountered little problems... I decided to use TMRH20 library. Everything is fine on remote modules but the main arduino wich is listening on multiple pipe is receiving square characters (wrong, not sent by any remote module). I can see that because I implemented a sort of debug receive/sent packets.
Maybe I'm wrong... Can somebody help please ?
Pierre
I'm having serious problems combining RF24 with w5100 ethernet module (which hogs SPI interface) and a touch screen I've been working on. Would it be possible to add support for soft SPI in your fork?
Found this PR to maniacbug..
https://github.com/maniacbug/RF24/pull/34/files
A little explaination:
http://shanes.net/how-to-use-an-nrf24l01-rf24-with-an-arduino-ethernet-shield/
Hello,
a library should not do infinite loops:
//Wait until complete or failed
// If this hangs, it ain't coming back, no sense in timing out
while( ! ( get_status() & ( _BV(TX_DS) | _BV(MAX_RT) ))) { }
Whether the radio is coming back or not is irrelevant - the program should not infinite loop if the radio is broken!
Case in point, my radio has an issue: it will reset (as if it got an electrical reset) at random, for reasons that are unclear to me.
Once it has resetted, the next write call will never succeed, and with your lib write goes in an infinite loop.
The correct thing to do in my opinion would be to add a timeout to write().
More details about my radio issues follow, in case you're interested or have an idea. I have a Arduino sketch that sends a stream of radio packets.
On the receiver side this is the configuration:
================ RASPBERRY PI SPI Configuration ================
CSN Pin = Custom GPIO8
CE Pin = Custom GPIO18
Clock Speed = 8 Mhz
==================== NRF24L01 Configuration ====================
STATUS = 0x46 RX_DR=1 TX_DS=0 MAX_RT=0 RX_P_NO=3 TX_FULL=0
RX_ADDR_P0-1 = 0xe7e7e7e7e7 0xf0f0f0f0f0
RX_ADDR_P2-5 = 0xf1 0xf2 0xc5 0xc6
TX_ADDR = 0xe7e7e7e7e7
RX_PW_P0-6 = 0x00 0x04 0x04 0x04 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x0f
RF_CH = 0x5f
RF_SETUP = 0x27
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Retries = 15 * 4000 us
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
It receives the stream just fine. However, if the stream is interrupted (either because the sender stopped sending, or because I switch the radio to PTX mode), then the radio may reset to its factory defaults. (2Mbit/s, default addresses, default channel, and so on).
After this happens, any write() attempt will fail, and TX_DS and MAX_RT don't even get set (not sure why), so the write() goes into an infinite loop with your lib.
Thanks
did you changed something on the code, I've tried to import RF24 to new RasPi but when run it says
"Traceback (most recent call last):
File "pingpair_dyn.py", line 10, in
from RF24 import *
ImportError: No module named RF24"
*make'd and installed all
weird?
I have a sketch that has been working properly on Uno, but is not working on Due,
Where the data (float, char) becomes garbled when received on Due.
I am sending the following struct which includes IMU data plus some chars,
and receiving it with the following receive function.
typedef struct{
byte PIPE;
float YAW;
float PCH;
char MSG[15];
}
A_t;
A_t RFL_STRCT;
void NRF_RECEIVE(){
if ( radio.available(&pipe_num) ) {
radio.read( &RFL_STRCT, sizeof(RFL_STRCT) );
RFL_YAW_STR = String(RFL_STRCT.YAW);
RFL_PCH_STR = String(RFL_STRCT.PCH);
RFL_PRX_MSG = String(RFL_STRCT.MSG);
Serial.print("RFL_YAW_STR: ");
Serial.println(RFL_YAW_STR);
Serial.print("RFL_PRX_MSG: ");
Serial.println(RFL_PRX_MSG);
}
On the UNO, I receive the data properly formatted as expected, like so;
RFL_YAW_STR: -168.25
RFL_PCH_STR : 132.65
RFL_PRX_MSG: GTRK,
But on the DUE, I get the same exact data showing up garbled or wrongly terminated/formatted.
RFL_YAW_STR: 0.00
RFL_PCH_STR : 227634315264.00
RFL_PRX_MSG: K,
The sketch is only changed where necessary, so that it compiles and runs on Due.
Would like to help port your libraries over to the BeaglBone Black (BBB). This issue started with a request comment on the TMRh20's Project Blog for March 2014 and a reply from TMRh20 with some initial suggestions.
I am going over the reply from TMRh20 and looking at the original port to the BBB of the maniacbug/RF24 library done by Purinda Gunasekara https://bitbucket.org/purinda/rf24bb/wiki/Home, and a more recent fork https://github.com/mlsorensen/RF24/tree/master/librf24-bbb/librf24 of the stanleyseow/RF24 for the BBB.
It is going to take a few days to digest all this, I am willing to test any updates on my system, I have the BBB, several Arduino Nano's and an Arduino Due with several nRF24L01 boards. I hope to help with the coding as I come up to speed.
saves 432 bytes of program memory.
RF24.cpp RF24.h:
add #if !defined (MINIMAL) ... #endif
to include all print_ functions:
void RF24::print_status(uint8_t status)
void RF24::print_observe_tx(uint8_t value)
void RF24::print_byte_register(const char* name, uint8_t reg, uint8_t qty)
void RF24::print_address_register(const char* name, uint8_t reg, uint8_t qty)
diff --git a/libraries/MySensors/utility/RF24.cpp b/libraries/MySensors/utility/RF24.cpp
old mode 100644
new mode 100755
index 2efb7bb..38053ab
--- a/libraries/MySensors/utility/RF24.cpp
+++ b/libraries/MySensors/utility/RF24.cpp
@@ -270,6 +270,7 @@ uint8_t RF24::get_status(void)
}
/****************************************************************************/
+#if !defined (MINIMAL)
void RF24::print_status(uint8_t status)
{
@@ -325,7 +326,7 @@ void RF24::print_address_register(const char* name, uint8_t reg, uint8_t qty)
printf_P(PSTR("\r\n"));
}
-
+#endif
/****************************************************************************/
RF24::RF24(uint8_t _cepin, uint8_t _cspin):
diff --git a/libraries/MySensors/utility/RF24.h b/libraries/MySensors/utility/RF24.h
old mode 100644
new mode 100755s
index 55253bb..89ed231
--- a/libraries/MySensors/utility/RF24.h
+++ b/libraries/MySensors/utility/RF24.h
@@ -863,7 +863,7 @@ private:
* @return Current value of status register
*/
uint8_t get_status(void);
-
+#if !defined (MINIMAL)
/**
* Decode and print the given status to stdout
*
@@ -907,7 +907,7 @@ private:
* @param qty How many successive registers to print
*/
void print_address_register(const char* name, uint8_t reg, uint8_t qty = 1);
-
+#endif
/**
* Turn on or off the special features of the chip
*
diff --git a/libraries/MySensors/utility/RF24_config.h b/libraries/MySensors/utility/RF24_config.h
old mode 100644
new mode 100755
index b7154a5..55962f1
--- a/libraries/MySensors/utility/RF24_config.h
+++ b/libraries/MySensors/utility/RF24_config.h
@@ -21,7 +21,7 @@
#include <stddef.h>
//TMRh20:
- //#define MINIMAL
+ #define MINIMAL // saves 432 bytes!
// Define _BV for non-Arduino platforms and for Arduino DUE
#if defined (ARDUINO)
I'm having issues with sending and receiving char[]. It seems to be truncating it. I don't have a problem sending single bytes. I'm not even sure how to debug this.
Any thoughts?
Here's a rundown of what I'm seeing:
Sender method (Arduino Uno):
void send_data(char msg[31]){
radio.stopListening();
printf("Sending %s (%u)\n\r", msg, strlen(msg));
bool ok = radio.write(&msg,strlen(msg));
sd();
if (!ok) {
printf("Sending Failed.\n\r");
get_response();
}
else {
get_response();
}
}
void loop(void) {
char msg[31] = "1234567890\0";
send_data(msg);
delay(1000);
}
Receiver method (RPi):
char* get_data() {
int len = 0;
//RecvPayload[0] = 0; // Clear the buffers
if ( radio.available() ) {
bool done = false;
while ( !done ) {
len = radio.getDynamicPayloadSize();
radio.read(&RecvPayload,len);
delay(5);
done = true;
}
RecvPayload[len] = 0; // null terminate string
cout << "Got cool message from node: " << len << ":" << RecvPayload << "\n\r";
printf("Debug: %u : %s\n\r", (unsigned)strlen(RecvPayload), RecvPayload);
return RecvPayload;
}
else {
return NULL;
}
}
Here's a snippet of the output:
Got cool message from node: 10:??123
Debug: 10 : ??123
hi, I received the following error message when compiling the example of node sleep on a Arduino UNO:
Arduino: 1.5.8 (Mac OS X), Placa:"Arduino Uno"
Network_Ping_Sleep.cpp.o: In function setup': /Network_Ping_Sleep.ino:104: undefined reference to
RF24Network::setup_watchdog(unsigned char)'
Network_Ping_Sleep.cpp.o: In function loop': /Network_Ping_Sleep.ino:139: undefined reference to
RF24Network::sleepNode(unsigned int, int)'
collect2: error: ld returned 1 exit status
compile error
I copy the library RF24Network.h on Contents/Java/libraries/RF24Nework-master folder into Arduino.app
unaware that marks this mistake in advance appreciate your advice on this error.
I think the diagram in examples/rf24_ATTiny/rf24ping85/rf24ping85.ino is incorrect. On NerdRalph's page he says:
When connecting the nrf module to a tiny85, connect MISO(pin7) on the module to MOSI/DI(PB0), and not MISO/DI(PB1). Here's the connections required:
nrf module ATtiny85 pin
SCK(5) PB2 (physical pin 7)
MOSI(6) PB1 (physical pin 6)
MISO(7) PB0 (physical pin 5)
Which also matches the pinout for the NRF module (MOSI = 6, MISO = 7). Therefore should the diagram not be:
^^
+-\/-+ nRF24L01 CE, pin3 ------| //
PB5 1|o |8 Vcc --- nRF24L01 VCC, pin2 ------x----------x--|<|-- 5V
NC PB3 2| |7 PB2 --- nRF24L01 SCK, pin5 --|<|---x-[22k]--| LED
NC PB4 3| |6 PB1 --- nRF24L01 MOSI, pin6 1n4148 |
nRF24L01 GND, pin1 -x- GND 4| |5 PB0 --- nRF24L01 MISO, pin7 |
| +----+ |
|-----------------------------------------------||----x-- nRF24L01 CSN, pin4
10nF
So that pin 7 (MISO) is connected to pin 5 (PB0) and pin 6 (MOSI) is connected to pin 6 (PB1)?
Also, the example uses 3 in the comments and code for the CE & CSN pins, but the diagram shows it connected to PB2, so should it not be 2 instead?
Hi,
After some struggle I have managed to get a ATtiny85 to communicate with an UNO.
The readme reports the ATtinyXX is supported and in the end this is definitely true!
However, the examples do not have an example for ATtiny85 out of the box.
Also the pin assignment and power issue with 3v3 line on arduino board almost made me quit (problems never come alone). To easy the use of ATtiny85 is an experiment I propose to add the example code I made. It is the gettingStarted.ino stripped to transmit mode only with some introduction text for the setup. Within IDE the text shows much better. Don't know (yet) how to show it in courier font.
rf24ping85.ino
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
/*
// Hardware configuration:
// ATtiny25/45/85 Pin map
// +-/-+
// Reset/Ain0 (D 5) PB5 1|o |8 Vcc (3v3 or -- LED -- 5v)
// nRF24L01 CE, Pin3 - Ain3 (D 3) PB3 2| |7 PB2 (D 2) Ain1 - nRF24L01 SCK, pin5
// nRF24L01 CSN, Pin4 - Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1 - nRF24L01 MOSI, pin7
// GND 4| |5 PB0 (D 0) pwm0 - nRF24L01 MISO, pin6
// CE and CSN are configurable
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = {"1Node","2Node"};
unsigned long payload = 0;
void setup() {
// Setup and configure rf radio
radio.begin(); // Start up the radio
radio.setAutoAck(1); // Ensure autoACK is enabled
radio.setRetries(15,15); // Max delay between retries & number of retries
radio.openWritingPipe(addresses[0]); // Write to device address '1Node'
radio.openReadingPipe(1,addresses[1]); // Read on pipe 1 for device address '2Node'
radio.startListening(); // Start listening
}
void loop(void){
radio.stopListening(); // First, stop listening so we can talk.
payload++;
radio.write( &payload, sizeof(unsigned long) );
radio.startListening(); // Now, continue listening
unsigned long started_waiting_at = micros(); // Set up a timeout period, get the current microseconds
boolean timeout = false; // Set up a variable to indicate if a response was received or not
while ( !radio.available() ){ // While nothing is received
if (micros() - started_waiting_at > 200000 ){ // If waited longer than 200ms, indicate timeout and exit while loop
timeout = true;
break;
}
}
if ( !timeout ){ // Describe the results
unsigned long got_time; // Grab the response, compare, and send to debugging spew
radio.read( &got_time, sizeof(unsigned long) );
}
// Try again 1s later
delay(1000);
}
The Raspberry Pi has a longer response time when these drivers are used, as opposed to the (non-bcm) drivers available in the stanleyseow fork. In a number of applications, the added delays cause the ACK to be sent after the transmitter has already timed out.
Are there any usage/code changes required after b7c24a8? I've looked through the examples, but nothing stands out.
I'm experiencing difficulty communicating between nodes after upgrading RF24 to the specified commit.
For example when trying to communicate from node 00 to node 031, network.available() is always false (please excuse the "node" terminology, I am also using your RF24Network fork). Downgrading the RF24 lib back to commit b7e4a09 fixes the issue.
I'm trying to understand how to make a battery powered system. I'm assuming that using the IRQ pin tied to the arduino is the best way to do this ?
If the radio is set to powerdown I'm guessing the IRQ pin wont change state if traffic is rx'd ?
If it's stoplistening() ?
From the doco
After calling startListening(), a basic radio will consume about 13.5mA at max PA level. During active transmission, the radio will consume about 11.5mA, but this will be reduced to 26uA (.026mA) between sending
Is it possible to have a radio consume 26uA and stil respond to incoming data ?
Hi, i try to use this library (RPi version) with MySensors library and I see every call to write() return false.
Thanks for this library, it seems more stable than a lot of the other NRF24 stuff out there!
I'm using this get communication between an arduino and a raspberry pi working, so far I have all of your 'simple' examples (GettingStarted, PingPair,...) working fine between my arduino and RPi.
However, when I try to move to one of the examples which uses the RF24::available() function, with a pointer to a pipe number, it never seems to catch any data on the receiver end (RPi in my case).
I have tested this running the rpi-hub.cpp on my RPi, and the startping.pde sketch on my arduino.
The arduino keeps saying 'response timed out', and the RPi end logs abolutely nothing about receiving anything.
Any ideas on what I could try?
thanks!
for whoever is interested, my fork of RF24 lib with implementation of remote calls via USB and Serial is available here: https://github.com/mz-fuzzy/RF24
Check readme:
https://github.com/mz-fuzzy/RF24/blob/master/RF24VUsb/README.md
https://github.com/mz-fuzzy/RF24/blob/master/RF24Serial/README.md
https://github.com/mz-fuzzy/RF24/blob/master/RF24Frontend/README.md
it's not finalized and polished yet, but should work.
@TMRh20 sorry for using this place for announcement, but I thought you could be interested as well. You can also check this with respect to future pull request to your lib.
In file included from src/main.cpp:4:
lib/RF24/RF24.h:55: error: ISO C++ forbids initialization of member 'lastAvailableCheck'
lib/RF24/RF24.h:55: error: making 'lastAvailableCheck' static
lib/RF24/RF24.h:55: error: ISO C++ forbids in-class initialization of non-const static member 'lastAvailableCheck'
lib/RF24/RF24.h:56: error: ISO C++ forbids initialization of member 'listeningStarted'
lib/RF24/RF24.h:56: error: making 'listeningStarted' static
lib/RF24/RF24.h:56: error: ISO C++ forbids in-class initialization of non-const static member 'listeningStarted'
I set EN_AA=0b00111111 and EN_CRC=0. But in the datasheet says that EN_CRC is reset to 1 if the ESB is enabled.
EN_CRC 3 1 R/W Enable CRC. Forced high if one of the bits in the EN_AA is high
Then I do not know if PTX inserts the CRC in packet actually.
Dependent functions: setCRCLength(), setAutoAck(), printDetails(), disableCRC(), getCRCLength()
Might be worth to change the function getCRCLength(), to return the value depending on the enabled ESB?
Code says that the default value for the power amp is MAX, but the line that sets it is commented out. So what is the default value? (below is the lines in the source that are commented out in RF24.cpp)
// Reset value is MAX
//setPALevel( RF24_PA_MAX ) ;
Hi, I have no clue how to submit a patch, but I wanted to submit the following for inclusion. I have two different types of NRF14L01+ modules that behave slightly different (this is what the patch addresses).
In RF24.cpp
/****************************************************************************/
void RF24::enableDynamicPayloads(void)
{
// Enable dynamic payload throughout the system
//toggle_features();
write_register(FEATURE,read_register(FEATURE) | _BV(EN_DPL) );
if (!read_register(FEATURE)) {
toggle_features();
write_register(FEATURE, read_register(FEATURE) | _BV(EN_DPL));
}
IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n",read_register(FEATURE)));
// Enable dynamic payload on all pipes
//
// Not sure the use case of only having dynamic payload on certain
// pipes, so the library does not support it.
write_register(DYNPD,read_register(DYNPD) | _BV(DPL_P5) | _BV(DPL_P4) | _BV(DPL_P3) | _BV(DPL_P2) | _BV(DPL_P1) | _BV(DPL_P0));
dynamic_payloads_enabled = true;
}
/****************************************************************************/
void RF24::enableAckPayload(void)
{
//
// enable ack payload and dynamic payload features
//
//toggle_features();
write_register(FEATURE,read_register(FEATURE) | _BV(EN_ACK_PAY) | _BV(EN_DPL) );
if (!read_register(FEATURE)) {
toggle_features();
write_register(FEATURE, read_register(FEATURE) | _BV(EN_ACK_PAY) | _BV(EN_DPL));
}
IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n",read_register(FEATURE)));
//
// Enable dynamic payload on pipes 0 & 1
//
write_register(DYNPD,read_register(DYNPD) | _BV(DPL_P1) | _BV(DPL_P0));
dynamic_payloads_enabled = true;
}
/****************************************************************************/
void RF24::enableDynamicAck(void){
//
// enable dynamic ack features
//
//toggle_features();
write_register(FEATURE,read_register(FEATURE) | _BV(EN_DYN_ACK) );
if (!read_register(FEATURE)) {
toggle_features();
write_register(FEATURE, read_register(FEATURE) | _BV(EN_DYN_ACK));
}
IF_SERIAL_DEBUG(printf("FEATURE=%i\r\n",read_register(FEATURE)));
}
/****************************************************************************/
Hi,
I'm doing some tests of this fork to see if we can incorporate it into the MySensors project. But I'm having a hard time getting auto-ack to work. Testing using the simple pingpair_ack example.
Have you verified auto-ack lately?
pingpair_dyn transmits fine with the same setup.
Hey I got getting started working, I think! But... when I plug my temp humidity sensor into my Nano, I stop getting responses. What do you think that could be?
I am involved in a project with multiple nodes to a central node. It includes AckPayload operation of all nodes to the central node. Central node is a TX node, and the others and RX ones with AckPayload between central node.
After several days fighting with my source code, I finally think I found the reason.
In order to isolate the cause of all my source code, I decided to check it in the GettingStarted_CallResponse example (two nodes and AckPayload functionallity)
To do this, all you have to do is change the pipe number 1 to number 2 in the example file (lines 50, 112 and 120).
In that case the "role_pong_back node" makes the read call (radio.read) successful and executes the writeAckPayload call but, "role_pong_out node" gets "false" after calling radio.write function.
In my project I have a pipe also 1, then I understand that problem is NOT pipe 1 being undefined. (I've also tested GettingStarted_CallResponse with a new node in pipe 1. In pipe 2 still does not work the ackPayLoad functionallity)
You can verify this issue by modifying the GettingStarted_CallResponse example? If necessary, I could send you the modified file, but is very simple.
Could you test it ? Just replace "openReadingPipe(1" with "openReadingPipe(2".
Cheers
NOTE: If someone with two arduinos could check it, please contribute with your test in this issue.
I'm new to the RPi and Arduino, and need some help with using your library.
I have wired up my Arduino Nano and RPi, attaching my nrf24l01+ modules to each using jumper cables. The Arduino has a 1.5uF capacitor across the 3v3 and GND pins on the breadboard. On the RPi I have connected jumper cables direct from the GPIO header to the pins on the radio module.
Both sides report sensible values via printdetails().
I have simply compiled the getting started examples from your library for each platform and run them.
I have set the Arduino into 'role_pong_back', and the RPi into 'role_ping_out'.
The first exchange works perfectly - on the RPi I see:
Now sending...
Got response 8967, round-trip delay: 6
On the Arduino I see:
Sent response 8967
Then on the RPi I see:
Now sending...
Then nothing.
This leads me to believe that the RPi has gotten hung up in radio.write() on the second attempt.
This happens consistently - every time I Ctrl-C to quit the getting started application on the RPi and then run it again, the same thing happens - the first transmit then receive cycle works and second one hangs.
Is this a power problem perhaps? Do I need a capacitor across the 3v3 and GND pins on the RPi as on the Arduino?
Could it be a timing problem? I am logging in remotely to the RPi via RDP, and the RPi is running LXDE - is this too much for it?
Any help gratefully received.
Thanks.
Do one of you use irc? you can find me in #nrf24l01 on freenode
Hello!
I've the same issue with this lib and with the one of maniacbug.
If I call the printDetails method, it stucks during the serial printf output. Generally just after the line specifying the model.
I've noticed that it didn't happen if startListening was called first.
So i've tested by isolating lines, and it seems that a call at the line
write_register(CONFIG, read_register(CONFIG) | _BV(PRIM_RX));
in startListening unblock the output.
I've tried with 2 arduinos and 2 RF modules, and i get the same conclusion.
Due to the number of changes lately, and expanding hardware support, please create all new pull requests against the updates branch, except for 'show-stopping' bug fixes etc. for the time being.
Updates will be synced with the master after testing etc is completed, with timeframes etc. TBD. The intent is to allow more consistency in the master branch without stopping development.
Hello
Sorry if I use the wrong terms I'm still learning.
I have purchased an Iboard from itead studio and are planning to use it with the RFNetwork library. The processor is ATMEL mega 328P, and it has a connector for a nrf24l01. I think the pins do not align with the SPI bus. the pins are described in the data sheet as:
CE = D3
CSN = D8
SCK = D7
MO = D5
MI = D6
I looked in RF24 library files and saw SOFTSPI which I believe means software SPI. I only know how to change CE and CSN pins. Is there a way to change the pin number to match the ones above or do I need another library?
I'm trying the low consumption modes but it looks like there is something wrong on my module (this is a generic one bought at eBay).
I tried this code:
void setup() {
Serial.begin(9600);
radio.begin();
radio.setDataRate(RF24_250KBPS);
Serial.println("Ready");
radio.txStandBy();
radio.powerDown();
}
But I read 4.7 mA consumption on my multimeter.
I try removing connections but I don't get any progress unless I remove the pin 13 (there is a led connected on my Arduino Nano board) connection: consumption falls to 2.5 mA ¿?
So I googled a bit and found this issue:
http://forum.diyembedded.com/viewtopic.php?f=4&t=1242
It looks like the way is to use pull up resistors, but I tried by setting every digital pin on Arduino to INPUT_PULLUP mode just after writing power down register:
void RF24::powerDown(void)
{
ce(LOW); // Guarantee CE is low on powerDown
write_register(CONFIG,read_register(CONFIG) & ~_BV(PWR_UP));
for (int i=0; i<14; i++) {
pinMode(i, INPUT_PULLUP);
}
}
After trying it, I got a 3.6 mA power consumption, but it's far away from values on the datahseet.
I am having trouble maintaining volume. The volume starts out fine and than tapers off to 0 as I talk.
Thanks
Ralph
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.