radio.printDetails()
That is a great library, I use it to connect a T3.2 with a Pi. To make sure you have the wiring correct, can you show the output of thecommand?Code:radio.printDetails()
#include <SPI.h>
#include <RF24.h>
#include "printf.h"
RF24 radio(7,8);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
void setup(void)
{
Serial.begin(9600);
printf_begin();
Serial.println("Test connection to modules");
// Setup and configure rf radio
radio.begin();
// Set the TX and RX addreses in the module
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]);
// radio.setDataRate( RF24_2MBPS ) ;
// radio.setPALevel( RF24_PA_MAX ) ;
radio.enableDynamicPayloads() ;
radio.setAutoAck( true ) ;
radio.powerUp() ;
radio.startListening();
// Print out the configuration of the rf unit for debugging
radio.printDetails();
}
void loop(void)
{
}
Test connection to modules
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x03
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_LOW
while (!Serial) ; // wait for arduino serial monitor
Add this near the beginning:
Code:while (!Serial) ; // wait for arduino serial monitor
Test connection to modules
STATUS = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1 = 0xf0f0f0f0e1 0xf0f0f0f0d2
RX_ADDR_P2-5 = 0xc3 0xc4 0xc5 0xc6
TX_ADDR = 0xf0f0f0f0e1
RX_PW_P0-6 = 0x20 0x20 0x00 0x00 0x00 0x00
EN_AA = 0x3f
EN_RXADDR = 0x02
RF_CH = 0x4c
RF_SETUP = 0x07
CONFIG = 0x0f
DYNPD/FEATURE = 0x3f 0x04
Data Rate = 1MBPS
Model = nRF24L01+
CRC Length = 16 bits
PA Power = PA_MAX
it is right?
Thanks now i can see this:
it is right?
#include <SPI.h>
#include "RF24.h"
bool radioNumber = 1;
RF24 radio(9,10);
byte addresses[][6] = {"1Node","2Node"};
bool role = 1; // 0 = pong back , 1 = ping out
void setup() {
Serial.begin(115200);
while (!Serial) ; // wait for arduino serial monitor
delay(2000); // WNG - println's below started working after I put in this delay
Serial.println("RF24/examples/GettingStarted");
Serial.println("*** PRESS 'T' to begin transmitting to the other node");
radio.begin();
radio.setPALevel(RF24_PA_HIGH);
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();
radio.printDetails();
}
void loop() {
/****************** Ping Out Role ***************************/
if (role == 1) {
radio.stopListening();
Serial.println("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("failed");
}
radio.startListening(); // Now, continue listening
unsigned long started_waiting_at = micros();
boolean timeout = false;
while ( ! radio.available() ){ // While nothing is received
if (micros() - started_waiting_at > 200000 ){
timeout = true;
break;
}
}
if ( timeout ){ // Describe the results
Serial.println("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("Sent ");
Serial.print(start_time);
Serial.print(", Got response ");
Serial.print(got_time);
Serial.print(", Round-trip delay ");
Serial.print(end_time-start_time);
Serial.println(" 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("Sent response ");
Serial.println(got_time);
}
}
} // Loop
Now sending
failed
Failed, response timed out.
Now sending
failed
Failed, response timed out.
Now sending
failed
Failed, response timed out.
Now sending
failed
Sent 735797622, Got response 0, Round-trip delay 19005 microseconds
Now sending
Sent 736817038, Got response 0, Round-trip delay 19267 microseconds
Now sending
failed
Sent 737836715, Got response 0, Round-trip delay 19149 microseconds
Now sending
failed
Sent 738856277, Got response 0, Round-trip delay 19196 microseconds
Now sending
Sent 739875884, Got response 0, Round-trip delay 19291 microseconds
Sent response 4294967295
Sent response 4294967295
Sent response 0
Sent response 0
Sent response 4294967295
Sent response 4294967295
Sent response 4294967295
Sent response 4294967295
are you also changing radioNumber for UNO and teensy? one needs to be radioNumber 0 the other 1. as described in GettingStarted example
Now sending
Sent 132394015, Got response 132394015, Round-trip delay 1641 microseconds
Now sending
Sent 133396067, Got response 133396067, Round-trip delay 1641 microseconds
Now sending
Sent 134398119, Got response 134398119, Round-trip delay 1642 microseconds
Now sending
Sent 135400175, Got response 135400175, Round-trip delay 1640 microseconds
Now sending
Sent 136402230, Got response 136402230, Round-trip delay 1640 microseconds
Now sending
Sent 137404283, Got response 137404283, Round-trip delay 1665 microseconds
Now sending
Sent 138406363, Got response 138406363, Round-trip delay 1640 microseconds
Now sending
Sent 139408417, Got response 139408417, Round-trip delay 1641 microseconds
simple hack: instead of sending micros send your analog value. change unsigned long start_time = micros();
to unsigned long start_time =analogRead(A0);