nrf24 with bluetooth helppppppppppp...........

hi, i’m having a problem with the nrf24 and bluetooth. LED in RX and Bluetooth in TX
what i want is to turn ON and OFF the LED using the bluetooth … But what i get now is no reading …

Kindly help me. Thanks :slight_smile:

here’s my TX code:

#include  <SPI.h> //Include SPI Code Library which can be downloaded below
#include "nRF24L01.h" //Include NRF24L01 Code Library which can be downloaded below
#include "RF24.h" //Inlcude NRF24 Code Library which can be downloaded below

int BluetoothData;

int msg[1];

RF24 radio(9,10); // The NRF24L01 Pin CE and Pin CSN
const uint64_t pipe = 0xE8E8F0F0E1LL; //Communication Pip Address
//int switchButton = 7; // Push button connected to Arduino pin 7
 
void setup(void){
 Serial.begin(115200); //Start Serial Communication at baud rate 9600
 Serial.println("Blue server");
 Serial1.begin(57600);
 Serial1.println("Bluetooth On please press 1 or 0 blink LED ..");
 radio.begin();
 radio.openWritingPipe(pipe);} //Open Communication Pipe
 
void loop(void){
 if (Serial1.available()){
BluetoothData=Serial1.read();
   if(BluetoothData=='1'){   // if number 1 pressed ....
    msg[0] = 111;
        radio.write(msg, 1);
   }

 }
}

RX code:

#include  <SPI.h> //Include SPI Code Library which can be downloaded below
#include "nRF24L01.h" //Include NRF24L01 Code Library which can be downloaded below
#include "RF24.h" //Inlcude NRF24 Code Library which can be downloaded below
 
int msg[1];
RF24 radio(9,10); // NRF24L01 Pin 
const uint64_t pipe = 0xE8E8F0F0E1LL; //Start Pipe Communication Address
int Indicator = 10; //This the LED which is connected to Arduino Pin 3
 
void setup(void){
 Serial.begin(115200);
 radio.begin();
 radio.openReadingPipe(1,pipe);
 radio.startListening();
 pinMode(Indicator, OUTPUT);}
 
void loop(void){
 if (radio.available()){
   bool done = false;    
   while (!done){
     done = radio.read(msg, 1);      
     Serial.println(msg[0]);
     if (msg[0] == 111){delay(10);
     digitalWrite(Indicator, HIGH);}
     else {digitalWrite(Indicator, LOW);}
     delay(10);}}
 else{Serial.println("Error: No Radio Transmission");}}

Your keyboard sticks.

But what i get now is no reading

That is not a very helpful description of the problem. Describe what the program(s) should do, and what they actually do instead.

Sorry ...

What i want is the Led will turn ON when the bluetooth(using my phone) send 1 and turn Off when send 0..

Unfortunately my code is not compatible with what i want it appears nothing. I dont know what to do with my code.

Can you get the two programs to work if you just send a number without getting it from Serial1

In other words does this work for your sender

void loop(void){
    msg[0] = 111;
    radio.write(msg, sizeof(msg));
    delay(100);
}

Note, also, that I have used sizeof(msg) so that it knows the correct size of the array you ar sending. In your case it is an int which is 2 bytes. But your code radio.write(msg, 1); only sends 1 byte.

I had a problem with the RF24 library that was solved by stopping the write() function in the file RF24.cpp from calling powerDown()

...R

You're trying to use pin 10 for both LED driver and RF24 CSN control. Move the LED to pin 8.