My actual question is: is there someplace that has basic code for this hardware? It doesn’t seem correct to use libraries for external hardware that is not actually being used.
The project: I have a circuit that is dormant in the dark. When light is present it trips the transistor which powers the circuit. When the circuit comes on the transmitter arduino transmits its message. I want to send a simple message (“1” for example) to another nano RF, when the message is received turn on LED. It is fairly simple and I have had success doing it with other hardware but I have been having issues with the NRF24L01 needing to be powered independently of the arduino. (A completely different power source has been the only way I could make it work and I don’t have the space for that). Any help directing towards appropriate libraries or code would be greatly appreciated.
Code-wise, there's absolutely no difference between an nRF24L01 right on the Nano RF's PCB and a nRF24L01 module connected to a standard Nano with some jumper wires. It's silly to think you need to find code specifically written for the Nano RF. Just use the standard libraries and example sketches for the nRF24L01.
Has anyone had any luck with finding a tutorial or library that works with the all-in-one RF-Nano boards?
I have tried going through several tutorials, mostly using the RF24 library. I tried changing the CE & CSN pin numbers to "(9,10)" and "(10, 9)" but still no luck. The board is running other code that I upload and the proper text is showing in the serial monitor for the "GettingStarted" example. I just keep getting a message that says "Failed, response timed out".
Then tell us what you are using on the receiving end to do your tests. Your error seems to be telling the receiver did not acknowledge the transmission.
I am using the "GettingStarted" example from the RF24 library for both my transmit and receive setups. I am using two of the boards shown in my previous post. They are connected to two different computers and are sitting about 2 feet apart.
The only difference in the two setups is that I change the "bool radioNumber = 0;" to "bool radioNumber = 1;" in just one of the two programs.
/*
* 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(10,9);
/**********************************************************/
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 start_time = micros(); // Take the time, and send it. This will block until complete
if (!radio.write( &start_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 end_time = micros();
// Spew it
Serial.print(F("Sent "));
Serial.print(start_time);
Serial.print(F(", Got response "));
Serial.print(got_time);
Serial.print(F(", Round-trip delay "));
Serial.print(end_time-start_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
Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.
The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work
There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to. If the first example does not work be sure to try the connection test for both of your Arduinos. Nothing will work if the connection test fails.
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.
There's a discussion I was involved in on this topic: Arduino Forum that got an RF-Nano working.
Sorry, my tablet doesn't post links correctly.
You should also be able to run the connection test code that @Robin2 provided in his series of posts. You need to get this working first, before trying to communicate with another NRF24L01 module.
Thanks for the link Robin2! I will be sure to check those out.
The high-power nRF24s (with the external antenna) will definitely need an external power supply.
The boards I am using do not have an external nRF24 module, it is mounted directly on the board instead. Adding an external power supply would be problematic. Have you ever tried using a board like mine with any of your examples?
I looked at this and it is not very simple for me How is it that I install the library files from TMRH20's site? I could some stuff under "files" but I have no idea what I am looking for in there.
You can install it by following these instructions:
(In the Arduino IDE) Sketch > Include Library > Manage Libraries...
Wait for the update to finish.
In the "Filter your search..." field, type "rf24.
Press the "Enter" key.
From the list of search results, click on "RF24 by TMRh20"
Click the "Install" button.
Wait for the installation to finish.
Click the "Close" button.
bkirkby:
I could some stuff under "files" but I have no idea what I am looking for in there.
That is a huge pet peeve of mine about doxygen generated documentation. The idea seems good, and it can produce quality documentation with some effort, but almost always I find that the doxygen documentation is absolutely horrible, even worse than no documentation at all in many cases.
bkirkby:
Thanks for the link Robin2! I will be sure to check those out.The boards I am using do not have an external nRF24 module, it is mounted directly on the board instead.
I presume your board does not need an external power supply - if it does it would be really cr*p design.
bkirkby:
Has anyone had any luck with finding a tutorial or library that works with the all-in-one RF-Nano boards?
I have tried going through several tutorials, mostly using the RF24 library. I tried changing the CE & CSN pin numbers to "(9,10)" and "(10, 9)" but still no luck. The board is running other code that I upload and the proper text is showing in the serial monitor for the "GettingStarted" example. I just keep getting a message that says "Failed, response timed out".
Hallo, I have your same model, if anyone have some success with this unknown "tsar tech" board please let us know!
I've tested this good tuts but without success
then i've tried with a standard simple rx tx sketch, for test the wiring of another two "classic" RF24 https://forum.arduino.cc/index.php?topic=421081.0
that confirmed my wiring on the classic nanons + shields works...
but the same sketches dont works on "tsar tech" also trying all the combinations of CE CSN
two hours of "fun" without results
You should also be able to run the connection test code that @Robin2 provided in his series of posts. You need to get this working first, before trying to communicate with another NRF24L01 module.
Hey markd833 - I plan on trying to run that test but I was not able to follow along with the instructions. The issue was that the instructions state that it is necessary to install this library. I went to that page and found the files but they are not in a .zip folder and I have no idea how to install a library without a zip folder. I will try to download all the files from there and put them in my own .zip file but I am not sure if that is the right approach. If you have any idea how I could get that library installed, I would greatly appreciate some guidance.