I recently got into arduino coding and want to build an rc car using nrf24l01 module.
I refered to a lot of tutorials and tried a lot of codes but the 2 arduinos' wont communicate.
i tried this code
/*`Preformatted text`
If your serial output has these values same then Your nrf24l01 module is in working condition :
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0f
This code is under public domain
Last updated on 21/08/28
https://dhirajkushwaha.com/elekkrypt
*/
#include <SPI.h>
#include <RF24.h>
#include <printf.h>
RF24 radio(7, 8);
byte addresses[][6] = { "1Node", "2Node" };
void setup() {
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1, addresses[1]);
radio.startListening();
Serial.begin(9600);
printf_begin();
radio.printDetails();
}
void loop() {
// empty
}
and i got this reciever :
RX_ADDR_P0-1 = 0x65646f4e31 0x65646f4e32
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x65646f4e31
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1 MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
ARC = 0
transmitter :
RX_ADDR_P0-1 = 0x65646f4e31 0x65646f4e32
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x65646f4e31
RX_PW_P0-6 = 0x20 0x20 0x20 0x20 0x20 0x20
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 1 MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
ARC = 0
BUT , when i tried this code in transmitter
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
// Instantiate RF24 class with CE and CSN values
RF24 radio(7, 8);
// Address to devices comunicate each other (same in both)
const uint64_t pipe = 0xE8E8F0F0E1LL;
// A variable to hold some info
boolean info = false;
void setup() {
// Setup serial output
Serial.begin(9600);
// Start RF
radio.begin();
// Setup the channel to work within, number 100
radio.setChannel(100);
// Open wite pipe
radio.openWritingPipe(pipe);
}
void loop() {
// it changes every interval
info = !info;
if (info) {
Serial.print("Sending positive... ");
} else {
Serial.print("Sending negative... ");
}
// Send info over RF
bool success = radio.write(&info, sizeof(boolean));
if (success) {
Serial.println("sent!");
} else {
Serial.println("fail!");
}
// Wait 2 seconds and repeat
delay(2000);
}
Then the serial moniter was:
Sending positive... sent!
Sending negative... fail!
Sending positive... fail!
Sending negative... fail!
Sending positive... fail!
Sending negative... fail!
Sending positive... fail!
Sending negative... fail!
Sending positive... fail!
Sending negative... fail!
reciver code :
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
// Instantiate RF24 class with CE and CSN values
RF24 radio(7, 8);
// Address to devices comunicate each other (same in both)
const uint64_t pipe = 0xE8E8F0F0E1LL;
// A variable to hold some info
boolean info = false;
void setup() {
// Setup serial output
Serial.begin(9600);
// Start RF
radio.begin();
// Setup the channel to work within, number 100
radio.setChannel(100);
// Open recept pipe
radio.openReadingPipe(1, pipe);
// Start to listen
radio.startListening();
}
void loop() {
// Wait until some data
if (radio.available()) {
Serial.println('A');
// Read payload, and check if it finished
radio.read(&info, sizeof(info));
// Manage info
if (info) {
Serial.println("We received positive!");
} else {
Serial.println("We received negative!");
}
}
// Wait a bit
delay(50);
}
reciever serial monitor shows nothing
So Pls help me