Hi I have 2 Tx Rx Nrf24l01+ Pa Lna 100 mw to communicate between 1 arduino uno and 1 arduino nano. but i haven't succeed. I have try a lot of tutorials but I have not been able to communicate with them. So is there some skech that let me taste the rf individually to see if they are broken, cables are bad or the arduinos are failing?
Thenx for all
Edit
I will include the extra data on the main post both arduinos are connected in different computers and supply from L78L33 regulator
Let me show you what I get from the example code Getting Started.
Library RF24.h
/*
* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20
*/
#include <SPI.h>
#include "RF24.h"
/****************** User Config ***************************/
/*** Set this radio as radio number 0 or 1 ***/
bool radioNumber = 0;
/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7,8);
/**********************************************************/
byte addresses[][6] = {"1Node","2Node"};
// Used to control whether this node is sending or receiving
bool role = 0;
void setup() {
Serial.begin(115200);
Serial.println(F("RF24/examples/GettingStarted"));
Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
radio.begin();
// Set the PA Level low to prevent power supply related issues since this is a
// getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
radio.setPALevel(RF24_PA_LOW);
// Open a writing and reading pipe on each radio, with opposite addresses
if(radioNumber){
radio.openWritingPipe(addresses[1]);
radio.openReadingPipe(1,addresses[0]);
}else{
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1,addresses[1]);
}
// Start the radio listening for data
radio.startListening();
}
void loop() {
/****************** Ping Out Role ***************************/
if (role == 1) {
radio.stopListening(); // First, stop listening so we can talk.
Serial.println(F("Now sending"));
unsigned long time = micros(); // Take the time, and send it. This will block until complete
if (!radio.write( &time, sizeof(unsigned long) )){
Serial.println(F("failed"));
}
radio.startListening(); // Now, continue listening
unsigned long started_waiting_at = micros(); // Set up a timeout period, get the current microseconds
boolean timeout = false; // Set up a variable to indicate if a response was received or not
while ( ! radio.available() ){ // While nothing is received
if (micros() - started_waiting_at > 200000 ){ // If waited longer than 200ms, indicate timeout and exit while loop
timeout = true;
break;
}
}
if ( timeout ){ // Describe the results
Serial.println(F("Failed, response timed out."));
}else{
unsigned long got_time; // Grab the response, compare, and send to debugging spew
radio.read( &got_time, sizeof(unsigned long) );
unsigned long time = micros();
// Spew it
Serial.print(F("Sent "));
Serial.print(time);
Serial.print(F(", Got response "));
Serial.print(got_time);
Serial.print(F(", Round-trip delay "));
Serial.print(time-got_time);
Serial.println(F(" microseconds"));
}
// Try again 1s later
delay(1000);
}
/****************** Pong Back Role ***************************/
if ( role == 0 )
{
unsigned long got_time;
if( radio.available()){
// Variable for the received timestamp
while (radio.available()) { // While there is data ready
radio.read( &got_time, sizeof(unsigned long) ); // Get the payload
}
radio.stopListening(); // First, stop listening so we can talk
radio.write( &got_time, sizeof(unsigned long) ); // Send the final one back.
radio.startListening(); // Now, resume listening so we catch the next packets.
Serial.print(F("Sent response "));
Serial.println(got_time);
}
}
/****************** Change Roles via Serial Commands ***************************/
if ( Serial.available() )
{
char c = toupper(Serial.read());
if ( c == 'T' && role == 0 ){
Serial.println(F("*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK"));
role = 1; // Become the primary transmitter (ping out)
}else
if ( c == 'R' && role == 1 ){
Serial.println(F("*** CHANGING TO RECEIVE ROLE -- PRESS 'T' TO SWITCH BACK"));
role = 0; // Become the primary receiver (pong back)
radio.startListening();
}
}
} // Loop
I get this from the both arduino. It doaent mater if both were conected or not.
There is a protocol for posting for help. This is the long version.
This is the short version.
1- Describe your problem (which you did already (briefly, anyway)
2- Post your wiring. Either a handdrawn schematic or a wiring list that says xxxxx_pin-x to yyyy_pin-y
etc.
3-Post your code. We do NOT want a link to some tutorial. You can link that at the end of your post but what we want is for you to copy the code from your IDE and paste it into the forum window using the
CODE toolbutton "</>" [FIRST TOOLBUTTON] by pasting the code in the screen and then highlighting it and clicking the CODE toolbutton.
3-Identify WHICH LIBRARY YOU ARE USING !!
(there is more than one NRF24L01 library)
4-If we are unsatisfied with your schematic or wiring list we may request a closeup photo of your circuit.
There are least 6 different reasons why your circuit isn't working. Without the above we have no idea which one is causing your problem.
Without the above, we can't help you.
Warday:
Hi I have 2 Tx Rx Nrf24l01+ Pa Lna 100 mw to communicate between 1 arduino uno and 1 arduino nano. but i haven't succeed. I have try a lot of tutorials but I have not been able to communicate with them. So is there some skech that let me taste the rf individually to see if they are broken, cables are bad or the arduinos are failing?
Thenx for all
As a first test I suggest not to follow a tutorial; instead try the most basic Tx and Rx example in the library you are using.
Unless you did something silly with the wiring (such as connecting a 3v device to a 5v supply or mixing up positive and negative) it would be best to assume they are NOT broken and that your code is at fault.
As @aisc says - get the simplest possible demo code working.
If that does not work I suggest you get two new good devices and get them working with the demo code. Then you can use the good devices to test the doubtful ones.
I suspect any other test equipment would be a great deal more expensive than a pair of NRF24s
@Warday,
There is really no point in posting on the forum if you are not going to respond to each and every reply you get. People will lose interest or become disgusted with the unresponsiveness and simply stop posting.
Sorry I created the post late at night when when I Exhausted all my effort to make it work. And in the morning I was solving the hydraulic calculations that this sistem will control.
The first post have been edited to include the information asked
I believe one should have code for a master and the other for a SLAVE. How are you distinguishing one from the other ? I don't think you can run the exact same code on both.
raschemmel:
I believe one should have code for a master and the other for a SLAVE. How are you distinguishing one from the other ? I don't think you can run the exact same code on both.
My understanding is that he does indeed.
This is the example sketch that runs both on the Tx and Rx. The role changes simply by typing the correct letter to the serial monitor. Have a look at the actual code.
Personally I never made this library work with the my NRF24L01 with PA. Instead the MIRF library, although primitive, worked just fine.
nikosk:
My understanding is that he does indeed.
This is the example sketch that runs both on the Tx and Rx. The role changes simply by typing the correct letter to the serial monitor. Have a look at the actual code.
Personally I never made this library work with the my NRF24L01 with PA. Instead the MIRF library, although primitive, worked just fine.
Exactly The code work for both and you type R or T to switch them
Where can I download the MIRF library?
Hi,
Please don't edit previous posts in reply to later replies, it upsets the continuity of the thread of your enquiry.
Your sketch is for Tx/Rx operation,so it looks like it can be used in both units, but each sketch will ineed to be modified to identify the two different units.
/****************** User Config ***************************/
/*** Set this radio as radio number 0 or 1 ***/
bool radioNumber = 0;
Sketch is radionumber 0 the other will be 1.
Please read the sketch comments.
TomGeorge:
Hi,
Please don't edit previous posts in reply to later replies, it upsets the continuity of the thread of your enquiry.
Your sketch is for Tx/Rx operation,so it looks like it can be used in both units, but each sketch will ineed to be modified to identify the two different units.
/****************** User Config ***************************/
/*** Set this radio as radio number 0 or 1 ***/
bool radioNumber = 0;
Sketch is radionumber 0 the other will be 1.
Please read the sketch comments.
Tom..... :)
Hi I read the skech and I try it but it doasent work
That example doesn't work. I've wired up dozens of NRF24L01 examples and circuits and that particular one doesn't work. Try any of the other examples. You just were unlucky enough to pick the one example that doesn't work. There's one in that library called led something or other that turns on a led when you press a button. All of the other examples work, except that one you chose. I think I tried all the examples in the RF24 library and that was the only one that didn't work. I recall one with 6 switches and 6 leds and the leds are on the Rx end and they mimic the switch status on the Tx end. I think they were just push buttons and the status toggles when you press them . Press once to change from 0 to 1 and again to change from 1 to 0. That example works too. There is one thing I don't think I tried with that example and that is to change the serial monitor setting to something else , like Newline.
The serial monitor output from both units in Reply#6 is from the LED REMOTE example I told you about. . Did jumper the correct pin to tell the sketch which one is the Master ? (look at the code)
Did you have the switches at the Tx end and the leds at the Rx end ? (A4)
// sets the role of this unit in hardware. Connect to GND to be the 'led' board receiver
// Leave open to be the 'remote' transmitter
const int role_pin = A4;
I got it! I could make it work! I had a wrong connection Mosi and miso (were mixed god dammit).
Checking the connections I found the mistake (the first tutorial have them mixed up and well, they stay like that). Thanks for all! Naw I need to learn how to transmit 4-3 data at same time.
Really thanks!!!!