Teensy 3.2 with NRF24L01+

Status
Not open for further replies.

Lexoli

Member
hello, I need help. I will have to communicate my Teensy 3.2 with a PC to send data, for now I'm doing some tests with an Arduino UNO, to inform the two micros, but with poor results. I found various libraries but all give me problems. what advice you give me? thanks!
 
Please start by posting the complete code that works with Uno, links to the exact version of any extra libs, a part number or link for exactly which NRF board, and photos of how you have connected it to both Uno and Teensy. Yes, I know that's a lot. Please do it. You asked for advice, and with no useful info in your message, this is the advice I can give you. Post this complete info if you want useful help!
 
Thanks for reply. I'm using this libs:
https://github.com/TMRh20/RF24

and i used this configuration(the same for both):
Vcc and GND (3v3)
CE pin7
CSN pin 8
CSK pin13
MOSI pin11
MISO pin12
IRQ disconnected

I tried the exemples in the libs, "GettingStarted", "pingpair", etc. All wit bad results. No comunication between the micros.
 
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 the
Code:
radio.printDetails()
command?
 
Last edited:
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 the
Code:
radio.printDetails()
command?



Hi, thanks for reply. i tried this code on Arduino UNO and Teensy 3.2

#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)
{
}

the arduino show this:

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


With Teensy:
nothing :(
what's the problem?
 
Last edited:
Add this near the beginning:

Code:
while (!Serial) ; // wait for arduino serial monitor

Thanks :) now i can see this:

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?
 
it is right?

How would I know? I haven't used this RF24 library before.

Maybe you could try actually using it to communicate? Does it work? If it doesn't work with Teensy, does the same thing work with the Arduino Uno?

I can help you resolve specific technical problems where Teensy differs from Arduino Uno, like this issue where Teensy starts up too fast and prints everything before you get the serial monitor window opened. But I don't have this specific hardware here and I don't have experience using this particular library.

Usually these sorts of libs do everything through the SPI or Wire library, so things usually just work. But if there is a problem, where it works on Uno but not Teensy, and we can't figure it out from just looking... I do have a budget to buy this sort of hardware and look into the problem. That takes time and usually it's not necessary, and if it is necessary, I don't actually order the hardware until there's a confirmed case where it's not working on Teensy and we can't figure out why (as was done with this serial startup issue). I need you to actually try using it, and if it doesn't work, post that confirmed case....
 
thank you all for the help!!

I tried this simple code:

Code:
#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

I set:
Teensy "role=1" and "RF24 radio(9,10)"
UNO "role=0" and change "RF24 radio(7,8)"
I saw a strange thing now. When all pins are connected i read on Serial Monitor:
Teensy:
Code:
Now sending
failed
Failed, response timed out.
Now sending
failed
Failed, response timed out.
Now sending
failed
Failed, response timed out.

Arduino UNO:
nothing.

When i disconnect pin8 on UNO and pin10 on Teensy (CSN):
i read this:
on Teensy:
Code:
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

on Arduino UNO:
Code:
Sent response 4294967295
Sent response 4294967295
Sent response 0
Sent response 0
Sent response 4294967295
Sent response 4294967295
Sent response 4294967295
Sent response 4294967295

you know why this happens?
 
are you also changing radioNumber for UNO and teensy? one needs to be radioNumber 0 the other 1. as described in GettingStarted example
 
are you also changing radioNumber for UNO and teensy? one needs to be radioNumber 0 the other 1. as described in GettingStarted example

ops! thanks! i read this now:

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

i think is ok :)

which of the examples could help me to learn how to send the data that I read from an analog port on the Teensy to the Arduino?
 
simple hack: instead of sending micros send your analog value. change unsigned long start_time = micros();
to unsigned long start_time =analogRead(A0);
 
Status
Not open for further replies.
Back
Top