I think I have solved the problem. I have switched to the Getting Started sketch in the original library and I have bypassed the voltage regulators and powered my units directly from the power supplies. After reading documentation as well as other people's experiences with similar projects, was made aware that some voltage regulators and step up/ step downs can cause noise in the circuit that could disrupt RF activity. Using two high powered NRF24L01 modules connected to two cheap china arduino nano MCUs, I was able to get the sketch working at a minimum. For the transmitter, my power supply consisted of 2x4 AA batteries hooked together to provide a nominal 6.4VDC that was plugged into the VIN on the nano MCU. The RF module was powered via the 3V3 pin. After getting the sketch to work with correlating data being reported on both recieving and transmitting serial ports, I proceeded to edit the code on the transmitter allowing me to add LED lights to report a response or timeout when pinging the receiving unit.
Thank you for your guidance Robin2. Moving onto the next step of the project.
Hello,
I've recently delved into the world of Arduino micro-controlling, and after learning/ experimenting on a breadboard with a single unit, I decided to take a stab at getting a couple of NRF24L01 modules working together. I've been trying multiple different combinations of different libraries and example sketches simply trying to get something to work, and instead of going through an exhaustive list of what I've tried, I'll describe the way things are hooked up now. After seeing a wealth of example sketches, I believe this may be the simplest place to move forward from. It's worth noting that both Arduino Nano chips in use have been tested and appear to operate correctly with basic DPin OUTPUT sketches. Output voltage after the DC Voltage regulator has been verified at 3.3V and there are two capacitors at either end of the reg. I have tried running the sketches on both MCUs with the power setting RF24_PA_MIN. The hardware I'm currently using goes as follows. The left and the right setup are identical, I have an Arduino Nano clone from ATMega model ATmega328/P, my power supply is coming from USB via computer. Attached to the 5V power supply of the Nano is a DC to DC Voltage Stepdown, 5V->3.3V +/- .1V. The NRF24 Module is Connected to the Voltage Regulator. The pin setup for the NRF24 goes as follows.
VCC - DC regulator @ 3.3V +/- .1V
GND - Nano GND
CSN - DPin 7
CE - DPin 8
MOSI - DPin 11
MISO - DPin 12
SCK - DPin 13
IRQ - Not connected
The error I'm receiving:
The unit is reporting this through the serial port after I change to transmit mode.
*** CHANGING TO TRANSMIT ROLE -- PRESS 'R' TO SWITCH BACK
Now sending
Sent 63264628, Got response 0, Round-trip delay 1064612 microseconds
Now sending
Sent 65330804, Got response 0, Round-trip delay 1117288 microseconds
Now sending
Sent 67449656, Got response 0, Round-trip delay 1149324 microseconds
When I unplug and power down the active receiver, the transmitter continues with the above serial communication report indefinitely, while I feel it should lose it's connection.
Here is the code (Example from the NRF24L01 Library) I'm trying to run:
/*
* 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_MAX);
// 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
bool radioNumber = 0;
Here, each radio has its own identity.
Data Sheets for components: Datasheets for components
I suspect the code/ library may be outdated or incompatible.
Any direction that could be provided on this project would be very gladly received.
Thank you for your consideration.
-Ty
(Edited - Spelling)