Hi,
I am using 2 nrf2401 PA LNA chips and connecting them to an Arduino MEGA and and an UNO. I cant seem to get them to send/receive a message. I am using the RF24 library. Thanks in advance for the help. To power the nrfs I used a power supply and put a cap between the vcc and gnd (47uF)
The connections I am using are:
MEGA
M1----->50
M0----->51
SCK----->52
CSN----->10
CE----->9
UNO
M1----->12
M0----->11
SCK----->13
CSN----->10
CE----->9
For the mega when I run printPrettyDetails(); on the mega:
SimpleTx Starting
16:28:08.902 -> SPI Frequency = 10 Mhz
16:28:08.935 -> Channel = 76 (~ 2476 MHz)
16:28:08.968 -> Model = nRF24L01+
16:28:09.000 -> RF Data Rate = 250 KBPS
16:28:09.033 -> RF Power Amplifier = PA_LOW
16:28:09.066 -> RF Low Noise Amplifier = Enabled
16:28:09.099 -> CRC Length = 16 bits
16:28:09.099 -> Address Length = 5 bytes
16:28:09.131 -> Static Payload Length = 32 bytes
16:28:09.164 -> Auto Retry Delay = 1000 microseconds
16:28:09.197 -> Auto Retry Attempts = 5 maximum
16:28:09.263 -> Packets lost on
16:28:09.263 -> current channel = 0
16:28:09.295 -> Retry attempts made for
16:28:09.328 -> last transmission = 5
16:28:09.328 -> Multicast = Disabled
16:28:09.361 -> Custom ACK Payload = Disabled
16:28:09.394 -> Dynamic Payloads = Disabled
16:28:09.426 -> Auto Acknowledgment = Enabled
16:28:09.459 -> Primary Mode = TX
16:28:09.492 -> TX address = 0x4141417852
16:28:09.525 -> pipe 0 ( open ) bound = 0x4141417852
16:28:09.557 -> pipe 1 ( open ) bound = 0x65646f4e31
16:28:09.590 -> pipe 2 (closed) bound = 0xc3
16:28:09.622 -> pipe 3 (closed) bound = 0xc4
16:28:09.656 -> pipe 4 (closed) bound = 0xc5
16:28:09.688 -> pipe 5 (closed) bound = 0xc6
16:28:09.926 -> Data Sent Message 0 Tx failed
16:28:10.937 -> Data Sent Message 0 Tx failed
16:28:11.941 -> Data Sent Message 0 Tx failed
16:28:12.969 -> Data Sent Message 0 Tx failed
16:28:13.961 -> Data Sent Message 0 Tx failed
When I run it on the UNO here is the printPrettyDetails();
SimpleRx Starting
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0x65646f4e31 0x4141417852
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0x65646f4e31
RX_PW_P0-6 = 0x04 0x20 0x04 0x04 0x04 0x04
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x23
CONFIG = 0x0f
DYNPD/FEATURE = 0x00 0x00
Data Rate = 250KBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
SimpleRx Starting
SPI Frequency = 10 Mhz
Channel = 76 (~ 2476 MHz)
Model = nRF24L01+
RF Data Rate = 250 KBPS
RF Power Amplifier = PA_LOW
RF Low Noise Amplifier = Enabled
CRC Length = 16 bits
Address Length = 5 bytes
Static Payload Length = 32 bytes
Auto Retry Delay = 1500 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
current channel = 0
Retry attempts made for
last transmission = 15
Multicast = Disabled
Custom ACK Payload = Disabled
Dynamic Payloads = Disabled
Auto Acknowledgment = Enabled
Primary Mode = RX
TX address = 0x65646f4e31
pipe 0 (closed) bound = 0x65646f4e31
pipe 1 ( open ) bound = 0x4141417852
pipe 2 (closed) bound = 0xc3
pipe 3 (closed) bound = 0xc4
pipe 4 (closed) bound = 0xc5
pipe 5 (closed) bound = 0xc6
Here is the code I am running on the Mega
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "Message 0";
char txNum = '0';
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
Serial.begin(9600);
printf_begin();
Serial.println("SimpleTx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
radio.printPrettyDetails();
}
//====================
void loop() {
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
prevMillis = millis();
}
}
//====================
void send() {
bool rslt;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.print(dataToSend);
if (rslt) {
Serial.println(" Acknowledge received");
updateMessage();
}
else {
Serial.println(" Tx failed");
}
}
//================
void updateMessage() {
// so you can see that new data is being sent
txNum += 1;
if (txNum > '9') {
txNum = '0';
}
dataToSend[8] = txNum;
}
Here is the code I am running on the UNO
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
printf_begin();
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
radio.printPrettyDetails();
}
//=============
void loop() {
getData();
showData();
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}