Getting RFM69 compatible with Arduino Mega / atmega2560

Started by norm258, January 22, 2015, 05:59:55 PM

norm258

I'm running Sketches on a Linux box.  I have tried to compile the basic node example and get this error, along with other programs I'm wanting to use.  Any pointers why would be appreciated.

I have an RFM69CW which will run on an Arduino Mega.

In file included from Node.ino:7:0:
/home/norm/sketchbook/libraries/RFM69/RFM69.h:83:68: error: 'RF69_IRQ_PIN' was not declared in this scope
     RFM69(uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, uint8_t interruptNum=RF69_IRQ_NUM) {
                                                                    ^
/home/norm/sketchbook/libraries/RFM69/RFM69.h:83:125: error: 'RF69_IRQ_NUM' was not declared in this scope
     RFM69(uint8_t slaveSelectPin=RF69_SPI_CS, uint8_t interruptPin=RF69_IRQ_PIN, bool isRFM69HW=false, uint8_t interruptNum=RF69_IRQ_NUM) {
                                                                                                                             ^
Node.ino:37:7: error: call to 'RFM69::RFM69(uint8_t, uint8_t, bool, uint8_t)' uses the default argument for parameter 2, which is not yet defined
Node.ino:37:7: error: call to 'RFM69::RFM69(uint8_t, uint8_t, bool, uint8_t)' uses the default argument for parameter 4, which is not yet defined

Felix

You need to install the RFM69 library in your arduino libraries folde
See these links for more on that:
http://lowpowerlab.com/moteino/#programming
http://lowpowerlab.com/programming

norm258

I have - This is directly from the examples using the library within Sketches too. 

-rw-rw-r-- 1 norm norm   83 Jan 20 13:18 readme.txt
drwxrwxr-x 3 norm norm 4096 Jan 20 15:27 ethercard
drwxrwxr-x 3 norm norm 4096 Jan 21 14:31 DHT
drwxrwxr-x 3 norm norm 4096 Jan 21 14:53 BH1750
drwxrwxr-x 3 norm norm 4096 Jan 22 16:55 SPIFlash
drwxrwxr-x 3 norm norm 4096 Jan 22 17:01 LowPower
drwxrwxr-x 3 norm norm 4096 Jan 22 17:55 RFM69
drwxrwxr-x 3 norm norm 4096 Jan 22 20:20 RFM12B
norm@godzilla:~/sketchbook/libraries$ ls RFM69
Examples      library.json  README.md  RFM69.h
keywords.txt  License.txt   RFM69.cpp  RFM69registers.h

norm258

I found the issue but not sure how to resolve it - I am using an Arduino Mega 2560 board so when it hits this part of the header file, it doesn't define these variables, resulting in the error.
// INT0 on AVRs should be connected to RFM69's DIO0 (ex on ATmega328 it's D2, on ATmega644/1284 it's D2)
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
  #define RF69_IRQ_PIN          2
  #define RF69_IRQ_NUM          0
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
  #define RF69_IRQ_PIN          2
  #define RF69_IRQ_NUM          2
#elif defined(__AVR_ATmega32U4__)
  #define RF69_IRQ_PIN          3
  #define RF69_IRQ_NUM          0
#endif

Felix

If defines are missing it means the lib was not targetted for that MCU and that MCU is not supported at the moment. You are welcome to add the defines and make any additions necessary and submit a pull request so we can add them to the library.

norm258

Just to quickly follow up in case anyone else with an Arduino Atmega board wants to use this module.  To make it work make the following change in RFM69.h:
Line 34
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega2560__)


The last defined is all you need to add.  I've confirmed the rest is compatible.  The only thing I haven't completely resolved yet is the SPIFlash - if you remove the manufacturer ID it seems to work but I'm not 100% convinced. 

A couple of notes.  There is an activity LED on pin 13.  SS is pin 53.

To wire it up:
MISO --> pin 50
MOSI --> pin 51
SCK --> pin 52
NSS --> pin 53

DIO0 --> pin 2.

I'm not entirely certain how to make a pull request so I will leave it to the powers that be to decide how to incorporate the details :)

Hope this helps someone.

Norm