Dear friends,
A few days ago I received two nRF24L01+ PA LNA modules (the larger ones, with a duck-antenna).
I’ve been experimenting with Robin2’s code from his guide, but unfortunately my progress virtually non existent.
My items :
UNO ------ > Adapter module ---- > nRF24L01+ PA LNA (RX)
UNO ------ > Adapter module ---- > nRF24L01+ PA LNA (TX)
RX code :
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.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);
Serial.println("SimpleTx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3, 5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//====================
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;
}
The RX UNO is trowing me :
SimpleRx Starting (and nothing else)
UNO TX code:
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.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);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
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;
}
}
The TX UNO Serial Monitor is spitting :
Data Sent Message 0 TX failed (once every second)
3v3 to VCC (since I have removed the adapters)
SCLK 13
MISO 12
MOSI 11
CE 9
CSN 10
So I started troubleshooting.
I saw the code on reply #29 *(Robin2 nRF guide), and the code is checking if the nRF module is communicating with the
micro controller.
I saw a lot of 0x00 in the test, so i knew that something was wrong.
I found I that one adapter is probably faulty, while the other was working ok.
I tried to test the modules without the adapters, and you can see the results in the attachment.
I guess the SPI connection between the UNO and the module is ok, correct me if i’m wrong.
Since I ran out of ideas on how to fix the problem, I am asking your help Please, help me escape from this “dead point” !
In my language, a “dead point” is a place were there is no progress, and I am stuck in one.
Wise colleagues, please help me