Go Down

Topic: nrf24l01 doesn't send (Read 92 times) previous topic - next topic

timdemand

I have an ATmega8 and an Arduino UNO and wanted them to communicate over the nrf24l01 module.
First I used the Arduino to programm the ATmega8 (I flashed a modified pingpair sketch which only receives and sends the data back) and the flashed the transmitter program to the Arduino UNO.

When I connect the Arduino to the PC and open the Serial Monitor it shows
Code: [Select]
0STATUS          = 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       = 0x08 0x08 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
Now sending 84...failed.
Failed, response timed out.
Now sending 1357...failed.
Failed, response timed out.
Now sending 2627...failed.
Failed, response timed out.
Now sending 3898...failed.
Failed, response timed out.
Now sending 5169...failed.
Failed, response timed out.
Now sending 6438...failed.
Failed, response timed out.


As you can see it shows the startup details which I think seem to be ok but it always fails at sending.

I double checked all the connections, used a different 3.3v source and even used another nrf24l01 module but everytime it fails.

Maybe there is a mistake in the code?

TX-Code:
Code: [Select]
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

RF24 radio(9,10);

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

void setup(void)
{
  Serial.begin(57600);
  printf_begin();

  radio.begin();

  radio.setRetries(15,15);
  radio.setPayloadSize(8);

  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);
   
  radio.startListening();

  radio.printDetails();
}

void loop(void)
{
    radio.stopListening();

    unsigned long time = millis();
    printf("Now sending %lu...",time);
    bool ok = radio.write( &time, sizeof(unsigned long) );
   
    if (ok)
      printf("ok...");
    else
      printf("failed.\n\r");

    radio.startListening();

    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout )
      if (millis() - started_waiting_at > 200 )
        timeout = true;

    if ( timeout )
    {
      printf("Failed, response timed out.\n\r");
    }
    else
    {
      unsigned long got_time;
      radio.read( &got_time, sizeof(unsigned long) );

      printf("Got response %lu, round-trip delay: %lu\n\r",got_time,millis()-got_time);
    }

    delay(1000);
  }

RX-Code:
Code: [Select]
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

RF24 radio(9, 10);

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };


void setup(void)
{
  radio.begin();

  radio.setRetries(15, 15);
  radio.setPayloadSize(8);

  radio.openWritingPipe(pipes[1]);
  radio.openReadingPipe(1, pipes[0]);

  radio.startListening();
}

void loop(void)
{
    if ( radio.available() )
    {
      unsigned long got_time;
      bool done = false;
      while (!done)
      {
        done = radio.read( &got_time, sizeof(unsigned long) );
        delay(20);
      }
      radio.stopListening();
      radio.write( &got_time, sizeof(unsigned long) );
      radio.startListening();
    }
  }


I really appreciate any help

Robin2

Have a look at this Simple nRF24L01+ Tutorial. I have deliberately kept everything simple to make the examples as reliable as possible.

IMHO it is impossible to know whether the failure is in sending or receiving.

If you have a pair of Unos (or a Mega, or Leonardo) it would eliminate any uncertainty associated with the Atmega8. Then when you know the system works you can try the code on the Atmega8.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

timdemand

I tried it with your tutorial but it`s the same again it only shows "Tx failed" like the other code...
Code: [Select]
Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino
SimpleTxAckPayload Starting
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed
Data Sent Message 0  Tx failed


I also tried it with a 10uF Capacitor between Ground and Power but still no success :(

Robin2

I tried it with your tutorial but it`s the same again it only shows "Tx failed" like the other code...
Post the two programs from my tutorial as YOU have uploaded them to YOUR two Arduinos.

Also make two pencil drawings showing how you have everything connected and post photos of the drawings.


It can help to disconnect power from the Arduino after uploading the code to ensure that the nRF24 resets. The normal Arduino reset does not reset the nRF24.


Do you have a 3rd nRF24 that you could use to verify if either of the first pair is broken?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up