NRF24 fails to send data

Hi!

I am making a remote with two arduinos using NRF24. Heres my code:

Transmitter:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   7
#define CSN_PIN 8

// Create Radio and define pins
RF24 radio(CE_PIN, CSN_PIN);

// Create Radio channels
const byte address[6] = "00001";

/* Vault */
int Array[4];

void setup() {
  Serial.begin(9600);
  Serial.println("setup");

  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  
  radio.stopListening();

}

void loop() {
  Array[0] = /* analogRead(0) */ 1337;
  Array[1] = analogRead(1);
  Array[2] = analogRead(2);
  Array[3] = analogRead(3);


  if (!radio.write( &Array, sizeof(Array))) {
    Serial.println("Transmition failed");
    Serial.println();
  }
  else {
    Serial.println("Transmition successful.");
    Serial.println();

  }



}

Reciver:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   7
#define CSN_PIN 8


// Create Radio and define pins
RF24 radio(CE_PIN, CSN_PIN);

// Create Radio channels
const byte address[6] = "00001";

//Radio recived array
int recivedDataArray[4];

void setup() {
Serial.begin(9600);

radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  
  radio.startListening();
}

void loop() {
if (radio.available()) {
    radio.read( &recivedDataArray, sizeof(recivedDataArray) );
    Serial.print("Recieved array:");
    for (byte i = 0; i < 4; i++) {
      Serial.println(recivedDataArray[i]);
    }
    Serial.println();
  }
}

I get the error "Transmition failed" in my serial monitor. If you can find something ive done wrong in my code it would be very helpful :slight_smile: . Thanks beforehand!

Best regards Max

Transmitters needs quite some power. I recommend You to post a wiring diagram, not any joke like Fritzings.

This is unusual to see on the receiver part. Post a link to the tutorial you are following.

Transmission failed could simply mean that the receiver part did not send an 'ack'

@6v6gt Oh! I didnt see that, I changed it and found that I wired the CSN and CE port wrong, but it still doesnt print out anything inside radio.avalible()

I dont have a super ambitious wiring diagram. I only have a simple diagram, its the same for both arduinos (Uno and Nano):

Arduino Uno - NRF24

VCC - 3.3v
GND - GND
MOSI - D11
MISO - D12
SCK - 13
CE - 9
CSN - 10

Do You have pen and paper?
My interest is how You power the units, controllers and NRFs.

Can you test the code from this example of NRF24L01 communication
(post is in French but code is code)

  • install each code on each arduino
  • open a Serial monitor for each arduino (so you need a terminal application as the IDE can only open one)
  • whatever you type on one side should appear on the other side

➜ if that works then you know your setup is likely OK. (which is likely not unless you have a cap to answer to peak demand when transmitting and your Tx might require to be changed from 5V ➜ 3.3V to not burn your module).

UNOs need 5.0 volt. 3.3 volt would not work well.

The Uno it self is powered by the USB connection, the NRF is powered via the 3.3v from the Uno right?

is your nRF module 5V compatible?

I dont belive so. Thats why I wasnt sure. I tested the example you shared and I get the error: "erreur d'envoi".

it means it failed to send anything.

usually the pins tolerate 5V logic, so finger crossed.

Try adding a decoupling capacitor across the power supply line of the module (The capacitor can be anything from 10µF to 100µF).

Should the transmitters radio.write post successful even if the reciver wasnt working properly?

no because you don't get the ACK

Ok, in my setup I never enable ack. I that something that could fix it?

My code has been used successfully many times so it's supposed to work.
if it did not work with my code then you likely have an Hardware issue.
did you add the cap?

Yes, but there was no difference, I have tested multiple modules but nothjing seems to work. I got it working about a month ago but I accidently ruined my old arduinos usb so I could not reprogram it. I have the scimatics for it but it doesnt work on my new arduino for some reason.

I am using one NRF01 (the small one) and one NRF01 + Antenna if that makes a difference

The 3.3V from the UNO does not provide a lot of current.

@srnet I just tested with a 5 - 3.3v regulator but it didnt make a difference..