NRF24L01 and Teensy 3.1

Status
Not open for further replies.

TelephoneBill

Well-known member
Just started with NRF24L01. Not used these boards before. Hit a compile issue with "Serial.printf".

I have modified some code that I already use the SPI bus for on an ADF4351 board (which works fine). I have included two new "includes" as shown here...
#include <stdint.h>
#include <SPI.h>
#include <nRF24L01.h> //new
#include <RF24.h> //new

The code imported was from another forum post which directed me to...
https://lastminuteengineers.com/nrf24l01-arduino-wireless-communication/

The only real difference between my own code and the imported "lastminuteengineers" code is that I already have defined "Serial.begin(115200);" so deleted their Serial.begin in the receive section.

Now here is my compile error. It seems to me that my own "Serial.printf" may be clashing with a "#define printf Serial.printf", but I don't fully understand the error message. If I comment out the line shown as Line 179, then it complies OK with just a warning. Any help would be appreciated...

Error 01.jpg
 
Yep - if there is a line defined like:

#define printf Serial.printf

and later you yourself do something like: Serial.printf("a");

And assuming simple case where it does not rescan, the line and infinite recurse, the like then looks like:
Serial.Serial.printf("a");

Again think of #define used as simple text substitution.

In your case, what happens if you just then do printf("%06d\r\n", xxx)
 
Yeah, ran into the same error when wanting to output formatted data using Serial.printf.
Just use printf instead of Serial.printf, like Kurt suggested.

Paul
 
Status
Not open for further replies.
Back
Top