1

I specifically had saved code for the purpose of checking the connection, but it doesn't seem to work anymore.

All the examples from this simple tutorial work, so it can't be a hardware issue.

Maybe someone can find a reason why the code wouldn't work? It returns radio.available() as false

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

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
float valueTransmit;
float valueRecieved;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00002
  radio.openReadingPipe(1, addresses[0]); // 00001
  radio.setPALevel(RF24_PA_LOW);
  valueTransmit = 0
}
void loop() {
  radio.stopListening();
  radio.write(&valueTransmit, sizeof(valueTransmit));
  delay(5);

  radio.startListening();
  if (radio.available() ) {
      radio.read( &valueRecieved, sizeof(valueRecieved) );
  Serial.print(valueRecieved);
  valueTransmit = valueRecieved + 0.01;
  }
}




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

RF24 radio(7, 8); // CE, CSN
const byte addresses[][6] = {"00001", "00002"};
float valueTransmit;
float valueRecieved;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_LOW);
}
void loop() {
  radio.startListening();
  if (radio.available() ) {
    radio.read( &valueRecieved, sizeof(valueRecieved) );
    Serial.print(valueRecieved);
    valueTransmit = valueRecieved + 1;
  }
  
  radio.stopListening();
  radio.write(&valueTransmit, sizeof(valueTransmit));
  delay(5);

}
3
  • suddenly not working means that it was working and it failed without any changes ... is that what happened?
    – jsotola
    May 16, 2021 at 21:47
  • @jsotola Honestly it's been a while since I wrote that code, so can't be too sure. But I remember being happy to finally see it working and pasting it into a notepad. If I did any changes, it was just to make it flow/look better.
    – Maksiss
    May 16, 2021 at 21:51
  • Also, I had tried to edit the tutorial example code to work with just integers and adding up numbers and made this to show what I changed. That also made it stop working and I couldn't figure out why. It's not like I changed anything critical, just the data that it sends.
    – Maksiss
    May 16, 2021 at 21:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.