Pages: 1 ... 12 13 [14] 15 16 17   Go Down
Author Topic: RF24 Library: Driver for nRF24L01(+) 2.4GHz Wireless Transceiver  (Read 91401 times)
0 Members and 2 Guests are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using Stanley's fork and I'm finding that the first 2-3 packets seem to be buffered or something. How can I explain that better?

I have my transmitter (ATmega328 on breadboard) sending out a counter once a second - 1..2..3..4.. and my receiver is printing it to the screen (on Pi) or serial monitor (on Mega2560). That works fine.

But say the TX goes out of range, or I kill the program on the RX at say count=16, when it comes back in range or I restart the program, instead of the counter being 50 (as TX has continued incrementing) it displays 17...18...19...51...52...53...54... so it seems to sync back up after 2-3 packets.

Any ideas? I get the same problem whichever way I mix up the TX/RX devices - e.g. TX=mega, RX=pi, so I don't think its hardware.

Its not a screen buffering problem, as I happens if I write to file instead of STDOUT/serial.

i tried disabling dynamic payloads and setting it to 3 bytes but it made no difference, it seems that something is not flushing when available() is not true or something odd.

Ah, it seems to happen if there's a big delay, e.g. if I kill the RX program on the Pi at count=100, wait 10secs or so, it produces:
104
105
112
113
114
115
116

But if I stop the program, then quickly start it again within say 2secs, its fine:

sudo ./pi_rf24ping_rx
253
254
255
256
^C
sudo ./pi_rf24ping_rx
258
259
260
261
262

If I reset the TX, it seems to cope - RX displays 0...1...2...3...4... just fine, its only if the RX program is quit or the TX goes out of range and comes back again.

Seems to be more reliable if I use "radio.setAutoAck(0);" and reduce the timeout/retries.

arduino+pi code and 2 arduino's code
« Last Edit: October 11, 2013, 05:02:03 pm by sej7278 » Logged

Kuala Lumpur, Malaysia
Offline Offline
Full Member
***
Karma: 4
Posts: 193
Anything is possible
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If it is 3 packets, it is bcos the nRF24L01 radio have 3 input/output buffers..

You can flush them using the flush_rx() or flush_tx() functions to flush out the buffers..

Stanley
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If it is 3 packets, it is bcos the nRF24L01 radio have 3 input/output buffers..

You can flush them using the flush_rx() or flush_tx() functions to flush out the buffers..

i saw lots of calls to those functions in the library, so assumed there were already enough lol. i'll have to refresh my c++ to recall how to call a protected method.

i've got a feeling it is ack packets and/or retries due to lost packets now though, as with a serial monitor on both ends it seems the RX is always 2-3 packets behind the TX.

radio.setAutoAck(0);
radio.setRetries(2,2);

seems to help a bit.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm new to this modules and am using Stanley's fork trying to connect a RPI with an Arduino Ethernet, I've spent some time reading this forum and played with different configurations for the channels/data rate/pa levels with no much success.

On the RPI I'm running the rpi-hub program and there seems no issues with the RPI (unless the ack maybe is not sent back to the arduino) as the RPI receives all payloads from the arduino:

Code:
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 = 0xabcdabcd71 0xf0f0f0f0e1
RX_ADDR_P2-5 = 0xe2 0xe3 0xe4 0xe5
TX_ADDR = 0xabcdabcd71
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x3f
RF_CH = 0x7d
RF_SETUP = 0x21
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN

Output below :
Recv: size=18 payload=E1,001,009,007,249 pipe=1 Send: size=18 payload=E1,001,009,007,249 pipe:1
Recv: size=18 payload=E1,000,127,075,039 pipe=1 Send: size=18 payload=E1,000,127,075,039 pipe:1
Recv: size=18 payload=E1,001,008,007,249 pipe=1 Send: size=18 payload=E1,001,008,007,249 pipe:1
Recv: size=18 payload=E1,002,232,231,073 pipe=1 Send: size=18 payload=E1,002,232,231,073 pipe:1
Recv: size=18 payload=E1,003,219,217,146 pipe=1 Send: size=18 payload=E1,003,219,217,146 pipe:1
Recv: size=18 payload=E1,004,214,211,162 pipe=1 Send: size=18 payload=E1,004,214,211,162 pipe:1
Recv: size=18 payload=E1,005,211,208,016 pipe=1 Send: size=18 payload=E1,005,211,208,016 pipe:1
Recv: size=18 payload=E1,006,210,206,032 pipe=1 Send: size=18 payload=E1,006,210,206,032 pipe:1
Recv: size=18 payload=E1,007,210,206,110 pipe=1 Send: size=18 payload=E1,007,210,206,110 pipe:1
Recv: size=18 payload=E1,008,210,206,155 pipe=1 Send: size=18 payload=E1,008,210,206,155 pipe:1
Recv: size=18 payload=E1,009,209,206,197 pipe=1 Send: size=18 payload=E1,009,209,206,197 pipe:1
Recv: size=18 payload=E1,010,209,206,184 pipe=1 Send: size=18 payload=E1,010,209,206,184 pipe:1

But the arduino sometimes it sent the payload and receive the ack correctly but most of the time it shows errors, I'm running the nRF24_sendto_hub just commented all the lcd code:

Code:
Sending nodeID & 4 sensor data

STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0e1
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 = 0x7d
RF_SETUP = 0x21
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MIN
outBuffer: E1,000,127,075,039 len: 18
Send successful
outBuffer: E1,001,008,007,249 len: 18
Send failed
outBuffer: E1,002,232,231,073 len: 18
Send failed
outBuffer: E1,003,219,217,146 len: 18
Send failed
outBuffer: E1,004,214,211,162 len: 18
Send failed
outBuffer: E1,005,211,208,016 len: 18
Send failed
outBuffer: E1,006,210,206,032 len: 18
Send failed
outBuffer: E1,007,210,206,110 len: 18
Send failed
outBuffer: E1,008,210,206,155 len: 18
Send successful
outBuffer: E1,009,209,206,197 len: 18
Send failed
outBuffer: E1,010,209,206,184 len: 18
Send failed
outBuffer: E1,011,209,206,165 len: 18
Send successful
outBuffer: E1,012,209,206,236 len: 18
Send failed
outBuffer: E1,013,209,206,042 len: 18
Send failed
inBuffer:  E1,013,209,206,042
inBuffer --> rtt: 23
outBuffer: E1,014,209,206,219 len: 18
Send successful

Any idea where I can continue looking to fix the issue? Anyone else with similar issues around here?

UPDATE: Well it happen that this was the problem, two 10 uF capacitors between 3.3v and GND, to filter the Ardiono 3V regulator http://forum.arduino.cc//index.php?PHPSESSID=9sru8nusnntmqipj2pgtqlaq17&topic=171611.0
« Last Edit: October 17, 2013, 09:33:40 am by cmanon » Logged

Utah
Offline Offline
Newbie
*
Karma: 0
Posts: 7
.NET Micro Framework guy, now Arduino fan. Pro .NET client and server developer, hardware is a hobby.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Stanley, maniacbug, greg and others... fantastic work here.  Very impressive.

Questions
  • -Is there a version of RF24Network that supoprts ATTiny 85/4?
  • -If not, is it possible?
  • -If possible, are there plans to? and when?
  • -If not possible, is there some way for ATTiny RF24 to participate at least at the leaf level?

Please tell me there is good news here.

Total noob evaluation:
I'm a noob, not only to nRF, but Arduino, period!  Got the maniacbug RF24 GettingStarted example running on my Uno R3's only after several hours of reading through this entire post.  Sorely lacking a noob tutorial, so I will gladly volunteer to write one and post a link here later. smiley  In short, I found 2 blockers and 1 annoyance for noobs not obvious from the examples or the doc files:  1) you need a 10uf cap on 3.3v to ground.  and 2) you must set BOTH the transmitter and receiver to TX mode at least once (setting one of them back to RX) before they will talk.  Weird. 

The annoyance? Many variations of the code out there, cant make heads nor tails of it.  For example, the fork from gcopeland is said to be more stable, but none of the examples work (i.e. wont even compile), and in fact, is missing the Getting Started example altogether.   hmfff.

Anyway, this stuff is AWESOME.  A die hard .NET Micro Framework guy quickly becoming converted.  smiley   (I came to Arduino because I really want to use nRF24L01+, and C# support for it totally sucks)
Logged

Utah
Offline Offline
Newbie
*
Karma: 0
Posts: 7
.NET Micro Framework guy, now Arduino fan. Pro .NET client and server developer, hardware is a hobby.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One other question:  do I need to do anything special to get RF24 running on atmega328 8MHz as opposed to 16MHz? (pro mini)
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@dapug,

PLEASE do write up your Noob Experience!  I would like to host it on the http://ArduinoInfo.Info WIKI.

nRF24L01 is VERY popular reading there. thousands of hits a month:
http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo

And many people have trouble getting it off the ground, as you did.

I'd like to have a "Just Get Started" section, (And a "Don't Forget THIS at the very top, like the 3.3V Issue..)

AND there is the Raspberry Pi Connection everyone wants and people are working on!

terry@yourduino.com
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I have updated the ArduinoInfo.Info WIKI page on nRF24L01 HERE: to include two example sketches that transmit the position of a  Joystick on one nRF24L01/Arduino to another that receives and displays the X,Y positions.  I have tried to make this as simple as possible.

Also I added a downloadable .PDF with the typical nRF24L01 module pinouts and Arduino connections. I'm always looking for that. 

Hope to add some more examples soon.

Thanks for the Great Library, ManiacBug!
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Kuala Lumpur, Malaysia
Offline Offline
Full Member
***
Karma: 4
Posts: 193
Anything is possible
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Terry,

Nice writeups on the newbie stuff.. especially the 10uF on the Vcc (3.3) and Gnd, these radios don't requires lots of current but they works much better with a 10uF ... I needed the 10uF only when getting 5V from Pin 10 and a LDO for my nRF adapter...

I wrote this simple serial chat code for a training class using two UNO (and optional 16x2 LCD), 2 nRF24L01 and text input via Serial Monitor ... if you are bored, you can chat with yourself over nRF ...

https://github.com/stanleyseow/RF24/tree/master/examples/nRF24_Serial_Chat

Stanley


Logged

Kuala Lumpur, Malaysia
Offline Offline
Full Member
***
Karma: 4
Posts: 193
Anything is possible
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Questions
  • -Is there a version of RF24Network that supoprts ATTiny 85/4?
  • -If not, is it possible?
  • -If possible, are there plans to? and when?
  • -If not possible, is there some way for ATTiny RF24 to participate at least at the leaf level?

The attiny84/85 are NOT using RF24 libs... they are using the smaller size Mirf libs (with less functions.. ) due to the limited flash size of the attinys..

I'll explore the RF24Network one day when I'm free, there seems to be improvements on the RF24Network...

My forks are still behind some of the recent improvements/bug fixes....
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 49
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To add some extra information to Stanley's reply I can tell you that I have successfully implemented rf24 and rf24network on an attiny84 and was able to connect a DHT11 and a PIR sensor and send the states back to the base-station running on a raspberry pi. In my case the limiting factor was RAM space so I needed to be careful with variable storage. Adding too many serial write debug statements was also enough to make it fail to run. Selecting the right version of the libraries took me a while.

If there is interest I will document how I got it working.

Martin
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

crofter - i'd be interested, i've got a similar setup with an atmega328p transmitting to a rpi, but i'd rather use an attiny85
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 252
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One other question:  do I need to do anything special to get RF24 running on atmega328 8MHz as opposed to 16MHz? (pro mini)

Nothing special needed... I run NRF24 on 8MHz atmega 328 all the time.
Logged

Offline Offline
Sr. Member
****
Karma: 1
Posts: 252
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an issue where my NRF 2.4 radio has a conflict with another device on the SPI bus. The radio will not properly initialize if the other device is connected (does even have to be powered!) I have the cs, csn on the radio on pins 8,9 and the cs on the other device on 4. Each device was test individually and working.

When the code runs, I get a serial output of all zeros on the radio details and then get repeating:

******WARNING******** Address 177000 not valid    (or maybe is not found, I can't remember)

Has anyone else run into similar conflicts???

The other SPI device is Adafruit's tft screen driver RA8875.

I was using most recent RF24 and RF24network libraries from Maniacbug.

Any help would be greatly appreciated!!!
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have this set up on a breadboard or just sticking jumpers into Arduino headers?

I experieced similar symptom with ethernet shield initially, which cleared up when I mounted the nRF on a proto shield with better connections.

I then moved to custom PCB's with plug in ENC28J60 and everything works fine together.

You could also investigate what speed each library sets the SPI bus, to see if there is any issue there. If a device sets SPI speed and then it is left at a speed the next device doesn't expect then that could cause issues.
Logged

Pages: 1 ... 12 13 [14] 15 16 17   Go Up
Jump to: