0

I've been trying on and off to try and get my nrf24l01's working for some time and they never seem to work. Right now i'm just trying to turn a led on and off over the radio and it isn't working.

Here's the code for the transmitter

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


#define button 5
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
boolean buttonState = 0;
void setup() {
  pinMode(5, INPUT_PULLUP);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {

  buttonState = digitalRead(button);
  radio.write(&buttonState, sizeof(buttonState));
}

And here's the code for the receiver

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

int led = 2;
RF24 radio(7, 8); // CE, CSN
boolean buttonState = 0;
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
 radio.startListening();
  while (!radio.available());
  radio.read(&buttonState, sizeof(buttonState));
  if (buttonState == HIGH) 
  {
    digitalWrite(led, HIGH);
  }
  else 
  {
    digitalWrite(led, LOW);
}
}

I have the voltage regulator which steps the 5v arduino to 3.3 to the chip so i don't think not having a capacitor (what others recommended) is a problem. I have both radio chips hooked up to arduino nanos.

For the transmitter and receiver I have CE=7,CSN=8, SCK=13, MO=11, and MI=12

I also know that my led is working and the code for my button is working. Is there a problem with my code or is there a chance that my chips are broken even if im using a voltage regulator

  • The capacitor is not used to regulate the voltage per say, it is used to make sure the supplied voltage is 'clean' when the radio transmits it draws 'a lot' of current real fast, and if the regulator cannot keep up with that spike, the voltage drops. I have found that using a capacitor with these radios clears up some issues. – Chad G Apr 12 '18 at 15:16
-1

Pretty sure your issue is you're not using the capacitor. I used a 10uF capacitor and it works great.

enter image description here

You put the capacitor on pins 1 and 2, make sure ground is on pin 1.

The capacitor is to make sure there is enough power being supplied when it needs it. Without the capacitor it causes unreliable communication.

If you have other issues this is a great summary video on using the NRF24L01+ transceivers: https://www.youtube.com/watch?v=kDTJULtFPgE

  • This is more like a comment, not an answer. – MatsK Jul 22 '18 at 7:25
  • From review: This answer is ok. Although could be improved by adding a diagram of where the capacitor has to go. – sa_leinad Jul 22 '18 at 7:51
  • Added a picture of where the capacitor should go – sand_storm_of_code.txt Jul 22 '18 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.