Hello, so i was trying to make one arduino uno to send data to another arduino uno using nrf24l01+ by using the example codes given by robin2 (https://forum.arduino.cc/t/simple-nrf24l01-2-4ghz-transceiver-demo/405123/2) but the receiver keeps printing "Data Received" even tho there is no data being sent, and if the data is being sent, it does not receive it. Here is the circuit:
Your device is not connected properly.
what do you mean?
when i tried the demo program by robin2 to test the communications between nrf24l01+ and arduino, it was working
ok so i tried to run the code without the nrf24l01 and it is still printing Data Received
Do You think posting the code could give more precise replies?
The same diagnosis as in your original post
Why do you think it is a good idea to open a second thread for that problem?
the problem is different. first it was that the modules were receiving gibberish data. now they are not receiving data at all
EDIT: ah ok i get it i should had just continued this from the original post as this problem came from there
Nope, both were showing reception when there was none.
i had given the link from where i took the code, but if you still need it, here you go
transmitter:
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 10
#define CSN_PIN 9
const byte slaveAddress[5] = {'R','x','A','T','x'};
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;
}
receiver:
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 10
#define CSN_PIN 9
const byte thisSlaveAddress[5] = {'R','x','A','T','r'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
getData();
showData();
digitalWrite(13, HIGH);
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived[1]);
newData = false;
}
}
The transmitter is missing a radio.stopListening();
call in setup,
which became necessary in newer versions of the library.
That does not explain phantom packets (on the contrary),
this still goes with bad connection or faulty module.
i am using the 1.1.7 version of the library, will i still need radio.stopListening()?
What does the documentation say?
As told, likely a poor connection or bad circuitry..
Minor notes not pinpointing the issue.
Setting D13 HIGH over and over again makes no sense.
Serial.print only prints the second character of 10 character buffer.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.