The DigiX > DigiX Support

nRF24L01+ / RF24 not working?

(1/7) > >>

PeterF:
Hi,

Was trying to get the nRF24L01+ module working as I already have a couple of these running around the house as part of a weather station project. I already had the RF24 and MiRF libraries installed, so I used the modified  RF24 radio(53,52); command as specified in the wiki, but it didn't work. So I thought it must be my libaries, so I moved them out as to use the versions included with DigiX. No change. When I compiled the RF24\GettingStared example without any changes, I got this error :


--- Code: ---In file included from GettingStarted.pde:22:
/printf.h: In function 'void printf_begin()':
printf.h:30: error: 'fdevopen' was not declared in this scope
--- End code ---

I comment out the offending line, as I thought it's probably something that worked with the AVRs, but not with the SAM architecture. No problem, just means the printf calls in the main code  won't output anything. At least it would compile.

I then get the following errors from the RF24 library?!? I *did* change the hardware\arduino folder to hardware\digix, but the error was occuring before I made that change.


--- Code: ---Arduino: 1.5.3 (Windows NT (unknown)), Board: "Digistump DigiX"

D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::csn(int)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:24: error: 'SPI_CLOCK_DIV4' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::print_status(uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:188: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:193: error: 'printf_P' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::print_observe_tx(uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:204: error: 'printf_P' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::print_byte_register(const char*, uint8_t, uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:212: error: 'printf_P' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::print_address_register(const char*, uint8_t, uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:223: error: 'printf_P' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::printDetails()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:325: error: 'printf_P' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::begin()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:382: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::startListening()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:398: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::powerDown()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:429: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::powerUp()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:436: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'bool RF24::write(const void*, uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:468: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::startWrite(const void*, uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:510: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'bool RF24::available(uint8_t*)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:552: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'bool RF24::read(void*, uint8_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:585: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::whatHappened(bool&, bool&, bool&)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:594: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::openReadingPipe(uint8_t, uint64_t)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:652: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::enableDynamicPayloads()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:671: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::enableAckPayload()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:700: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::setAutoAck(uint8_t, bool)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:770: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:774: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::setPALevel(rf24_pa_dbm_e)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:799: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'rf24_pa_dbm_e RF24::getPALevel()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:832: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'bool RF24::setDataRate(rf24_datarate_e)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:864: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'rf24_datarate_e RF24::getDataRate()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:907: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::setCRCLength(rf24_crclength_e)':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:933: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'rf24_crclength_e RF24::getCRCLength()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:957: error: '_BV' was not declared in this scope
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp: In member function 'void RF24::disableCRC()':
D:\Dropbox\Programming\Ardiuno\hardware\digix\sam\libraries\RF24\RF24.cpp:974: error: '_BV' was not declared in this scope
--- End code ---

Any ideas? I'm happy to poke, prod and break things :)

Cheers,
Peter

PeterF:
Just an info update.

After a hour or so more of searching, changing code, and getting it to work, I came across a forum post of someone else who had also just got it working, and posted his changes. It appears to be an Arduino Due related issue, so naturally impacts on the DigiX.

For his github changelog that details the changes: https://github.com/mcrosson/RF24/commit/ac05a9d8f755dcc7ff12b7e08021f62c0b5f3543

I made one extra change, to printf so I can continue to use it with the AVR microcontrollers:


changed line 30 of printf.h from

--- Code: ---fdevopen( &serial_putc, 0 );
--- End code ---

to


--- Code: ---#if !defined(__arm__)
fdevopen( &serial_putc, 0 );
#endif
--- End code ---

There are no compile errors, but printf and associated functions seem to not work at all, so printDetails() isn't working, and scanner example isn't working.

The nRF24L01+ *did* receive some data whilst I was stomping around in the RF24 code, but seems to have stopped receiving now. Will post when I know more.

digistump:
print.h issue fixed in newest release http://digistump.com/wiki/digix/tutorials/software

PeterF:

Tried the latest v04 of the DigiX addons, no change on the scanner example compiling - still doesn't work on Arduino 1.5.4. Thanks for renaming the hardware folder thou :).


Finally had some time and awake enough brain cells to debug this gremlin further, and finally got it working (although not a neatly as I'd like). Anyway, here are the changes..


Add the following to rf24_config.h (could add to any of the rf24 files - .h, .cpp, but rf24_config.h contains all the environment specific 'fidely' bits):



--- Code: ---//ARM specific code


#ifdef __arm__
#define SPI_CLOCK_DIV4 21
#define _BV(bit) (1 << (bit))
#define printf_P printf
#endif
--- End code ---


Add to sketch in question or printf.h:



--- Code: ---  int kkprintf(char *format, ...)  {
  int n;
  char buf[128];
  va_list args;
  va_start (args, format);
  vsnprintf(buf, sizeof(buf), format, args); // does not overrun sizeof(buf) including null terminator
  va_end (args);
  // the below assumes that the new data will fit into the I/O buffer. If not, Serial may drop it.
  // if Serial had a get free buffer count, we could delay and retry. Such does exist at the device class level, but not at this level.
  n = strlen(buf) - Serial.print(buf); // move chars to I/O buffer, freeing up local buf
  return n; // number of chars unable to fit in device I/O buffer (see bug notice above)
}
--- End code ---


Make sure you change calls to printf() in sketch code to kkprintf().


I now how a DigiX board running the scanner example using the on-board nRF24L01+ module, telling me my wifi router is using the high end of the low end of the 2.4Ghz spectrum :)



digistump:
Erg - I guess I really totally shipped the wrong version of this library - I had a version all pre=modified that I meant to ship - I'll look for it and make sure it makes the next release - but basically I did what @pferrick did.

Navigation

[0] Message Index

[#] Next page

Go to full version