Hi,
I have 2 cheap eBay nRF24L01+ modules with PCB antenna. I cannot make them to communicate. I was writing the drivers on my own so I will not show you the code, it is quite complicated (I may if anyone is interrested but I doubt you will want o read it all). The setup is:
PTX is powered by 2 NiMH AAAs driven by standalone ATMega.
PRX is controlled by Arduino Uno and powered from onboard 3V3.
So far I have checked this:
I can reliably write and read all registers on both devices.
PRX is probably really in receive mode because it draws around 15mA of current.
PTX is transmitting something: when commanded to send data MAX_RT flag is set and interrupt signaled to notify transmission failed and no ACK was received.
On PRX I read the RPD (Received Power Detector) register. It reads 1 when PTX is powered on and reads 0 when I disconnect PTX. So PRX can hear PTX.
Addresses match: I did not change the default settings and I checked it is as Datasheet says it should be. Also autoACK is enabled for all pipelines as well as dynamic payload for everything on the PRX side.
Interesting thing: I tried to sweep all the frequencies on PRX. RPD indicates carrier is present at PTX's frequency and a few (about 5) bands higher - not lower.
Does anyone know where the problem may be? I have read poor power may cause decreased reliability. I have it all build on solderless breadboard. Do you think power issues may be so bad it will disrupt communication of two devices on the same able next to each other? Or do you think being so close may cause this?
Have a look at this Simple nRF24L01+ Tutorial. The examples do work.
...R
Thanks for the link. I tried upload the RX sketch from the post #1 to the Arduino to see if problem is on the PRX side. But I get "Data received " printed on Serial as fast as the Arduino can. I tried to print contents of the dataReceived array and it is all 0s all the time. It does this even when the PTX is turned off. Do you know what can cause this behavior? I tried power cycling Arduino (with the nRF) with no help.
Smajdalf:
Thanks for the link. I tried upload the RX sketch from the post #1 to the Arduino to see if problem is on the PRX side.
All my programs work as pairs. Uploading one of them is no use.
...R
Robin2:
All my programs work as pairs. Uploading one of them is no use.
This is the reason why I prefer NOT to use another's libraries and programs. If the program
// 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 ");
for (byte i=0; i<10; i++) {
Serial.print(dataReceived[i],DEC);
Serial.print(" ");
}
Serial.println();
newData = false;
}
}
did what I expect it should do it would print nothing with no TX. Yet it prints empty packet was received. Or packet full of zeros? Who knows. Now I have two options - look into the source codes of the libraries if there is a bug in the library somewhere or what would explain such behavior (wrong wiring?). Or I can simply discard the code because it does not give me insight into my problem. I hoped someone with knowledge of the library may guess what may cause this behavior.
Smajdalf:
did what I expect it should do
IMHO it would make a lot more sense to expect it to do what its author intends it to do
I make no pretence that my programs meet every possible requirement - just that they do what I wrote them to do, which is to provide basic communication from which someone can develop their project.
Feel free not to use my examples.
...R
Sorry, no offense was meant. When I read the shown program I expect it will print nothing to Serial (except for "SimpleRx Starting") when PTX is not present: I expect radio.available() will never return TRUE. But it does. I don't know what it mean and I hoped you know it and could tell it.
Smajdalf:
Sorry, no offense was meant. When I read the shown program I expect it will print nothing to Serial (except for "SimpleRx Starting") when PTX is not present: I expect radio.available() will never return TRUE. But it does. I don't know what it mean and I hoped you know it and could tell it.
Let's come back to that question after you have the pair working properly - that is the ONLY way to know that everything is correct. What you are doing is a bit like one-hand clapping. Who knows what might be the cause of the problem.
...R
I'm a novice myself, but I feel I can help Smajdalf.
Smajdalf says that all he's getting is a "Data Received" message instead of the intended "Message 0" "Message 1", etc. I think it's a rewire issue.
Try to individually wire the pins ONE BY ONE to the Arduino you are using. I had the same issue, and this fixed it
This is the reason why I prefer NOT to use another's libraries and programs.
Your libraries do not work and you won't post the code.
So, why did you even bother to post this topic on the forum?
Robin2:
Let's come back to that question after you have the pair working properly - that is the ONLY way to know that everything is correct. What you are doing is a bit like one-hand clapping. Who knows what might be the cause of the problem.
Never mind, it looks like I cannot make you understand. Let say I am practicing hand clapping and because it is difficult I train my right hand alone first. I would expect to hear no sound even when I wave the lone hand as a professional clapper. But I hear something! It surely means I am doing it is wrong. Maybe with proper description of the sound someone can guess WHAT is wrong. But you say me "learn hand clapping with both hands and then come back and ask for help". I won't need the help when I figure what is wrong... If you said that it is expected behavior to have (false) new messages with noone transmitting I would try if adding transmitter would help. But since there seem to be a problem on the RX side I think adding TX will help nothing.
Smajdalf, just rewire!
And perhaps try Robin's code on his tutorial. They work.
Try those on your own modules and if they don't work your modules are probably faulty, though that might be unlikely.
And please post your code. We have a community of programmers who might be of some help to you. And I would love to see someone write there own library.
Smajdalf:
But I hear something! It surely means I am doing it is wrong.
Possibly. But the ONLY way to be sure you are not is to get 2-way communication working between the pair.
Imagine you pick two people at random to convey a message from one to the other but you just send one them out into the far corner of a large field. The message won't be received. But you have no idea if that is because the person in the field is unable to speak, if their voice is too quiet or if they speak a different language. And neither do you know if the other person is deaf. More importantly, you have no means to figure out any of those things.
The fact that your single radio appears to detect something does not convey any useful information. In another recent Thread the OP's nRF24 was apparently receiving a spurious 0 as well as the proper message. It turned out to be caused by a broken wire.
...R
Hi Robin!
Smajdalf:
I have 2 cheap eBay nRF24L01+ modules with PCB antenna. I cannot make them to communicate.
I have had that.
I used a known working TX and RX program, and swapped TX and RX devices till I got a working pair.
It turned out that about 75% of the 'cheap eBay nRF24L01+ modules' were faulty, may have just been bad luck.
Once I had a known working pair I was able to start using different RX and TX programs knowing that if I had a problem, it was not the modules.
srnet:
Once I had a known working pair I was able to start using different RX and TX programs knowing that if I had a problem, it was not the modules.
+1
...R
Time for some feedback:
I looked a bit more on this. I have found the Robin2's examples need some library. Since I have no idea which library I have installed it may be the cause of "strange" results.
srnet:
It turned out that about 75% of the 'cheap eBay nRF24L01+ modules' were faulty, may have just been bad luck.
What was wrong with the "faulty" modules? After debugging I found the CONFIG register turned from the right value to 0x7F after a few seconds. All 3 modules I have are doing this. Also the modules sometimes reset to default register configuration. I expect it is poor (noisy) power supply. Are your experience similar?
Smajdalf:
Time for some feedback:
I looked a bit more on this. I have found the Robin2's examples need some library. Since I have no idea which library I have installed it may be the cause of "strange" results.
I have no idea how you cannot know which library I used as there is a link to it in the first part of my tutorial.
...R
Robin2:
I have no idea how you cannot know which library I used as there is a link to it in the first part of my tutorial....R
OMG. I see the link to the library YOU used. I have no idea what library I used. Since it is possible I have wrong library it MAY be the reason why your examples did not work well. I wonder: is my English so poor or you don't understand written text?
Smajdalf:
What was wrong with the "faulty" modules? After debugging I found the CONFIG register turned from the right value to 0x7F after a few seconds. All 3 modules I have are doing this. Also the modules sometimes reset to default register configuration. I expect it is poor (noisy) power supply. Are your experience similar?
Life is short, I did not consider it worthwhile spending any time trying to work out why cheap modules from China did not work, but those sourced in the UK did.