I'm having a problem with two nrf24l01+pa+lna connecting to each other when i run the code on both arduino uno's the receiver says it received the code but the transmitter says it isnt able to connect to the receiver. I used this guide on how to do it Simple nRF24L01+ 2.4GHz transceiver demo - Exhibition / Gallery - Arduino Forum and i used reply#1 for the code, if anyone could help me out it would be appreciated.
What Arduinos are you using?
Please post the actual programs that YOU have uploaded to your Arduinos and also please post a sample of the output from each.
The receiver should be printing a message once per second. If it much faster than that then it is likely the wiring to the Arduino is incorrect.
Have you tried the connection test program in (http://forum.arduino.cc/index.php?topic=421081)]my Tutorial? if that does not work then nothing will work.
A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. This seems to be a particular problem with the nano. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.
...R
Arduino UNO both are arduino uno's
transmitter 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;
}
first image is what you'll see in the seriël monitor for the transmitter
and the code for the receiver is:
// 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;
}
}
and the second image is what youll see in the seriël monitor for the receiver
Cycle power to both of the boards. The radios do not reset with the Uno when uploading. Sometimes you need to reset the radios so cycling power will do that. That has worked for me when the radios act like that.
If the higher powered fr24 radios are too close together it can make them not work so well. Move the radios a ways (a couple of meters) apart.
duncanslime4:
and the second image is what youll see in the seriël monitor for the receiver
You have not said how fast the receiver message repeats - that's important for diagnosing the problem.
And you have not said whether you have tried the connection test program.
...R
Robin2:
You have not said how fast the receiver message repeats - that's important for diagnosing the problem.And you have not said whether you have tried the connection test program.
...R
I've run the code again and got the timestamps of the receiver (first image)
I've also tried the test program and like it said that if there are mostly 0x00 or 0xff it means they arent connecting, and there were only 0x00.
Please detail the wiring connections you have made between the nRF24L01 and your Arduino board.
duncanslime4:
I've run the code again and got the timestamps of the receiver (first image)
I don't mean to be offensive in any way but that was a very poor use of your time. If you look back to Reply #1 all that you needed to know was whether the messages arrive once per second or a lot faster than that. You can easily tell the difference just by watching the screen.
I've also tried the test program and like it said that if there are mostly 0x00 or 0xff it means they arent connecting, and there were only 0x00.
Then that's what we need to focus on. Please post a sample of the output from the connection test program.
...R
Robin2:
I don't mean to be offensive in any way but that was a very poor use of your time. If you look back to Reply #1 all that you needed to know was whether the messages arrive once per second or a lot faster than that. You can easily tell the difference just by watching the screen.
Then that's what we need to focus on. Please post a sample of the output from the connection test program....R
That connection test tells me that communication with the Arduino is not working. Incorrect wiring or a loose connection is the most likely cause.
Just out of curiosity, what software are you using to provide the timestamps for each line?
...R
what software are you using to provide the timestamps for each line?
That looks like the serial monitor with the timestamps enabled.
groundFungus:
That looks like the serial monitor with the timestamps enabled.
How interesting. I never use it so I didn't know it had that facility.
...R
It relatively new. A few months, I think. Though I seem to have lost the ability to measure time since I retired.
Robin2:
That connection test tells me that communication with the Arduino is not working. Incorrect wiring or a loose connection is the most likely cause.Just out of curiosity, what software are you using to provide the timestamps for each line?
...R
Do you maybe have any ideas on what the problem could be with the wiring?
duncanslime4:
Do you maybe have any ideas on what the problem could be with the wiring?
Without being at your workbench where I can physically see what you have done I don't know. And, unfortunately, photographs are not a substitute.
When this has happened to me the cause has usually been a mix up between CE and CSN. But it could be anything.
My suggestion is to take everything apart and re-connect everything very carefully according to the wiring connections in my Tutorial.
These things are actually very reliable. I have a few nRF24s with some DuPont cables attached. I know it will work if I plug the cables into my Uno and load up any of the programs from my Tutorial.
...R