MoteinoMEGA (ATmega1284p) and LowPower library support [FIXED]

Started by daemach, September 10, 2014, 10:57:18 AM

daemach

I'm trying to compile a low power sketch and I'm getting the following error from the low power library:  "Please ensure chosen MCU is either 328P, 32U4 or 2560."

Does this library not work with the 1284p?

Felix

Perhaps not, I may need to look into it, fork it to my own github repo and add 1284p support. I imagine it can't be that complex of a change.

Felix

Ok, it is now forked and 1284P support added. Replace your current LowPower lib with this new one:
https://github.com/LowPowerLab/LowPower

Tested on a MoteinoMEGA with FLASH and RFM69HW. The sample code below should get you around 15uA when sleeping the FLASH and RFM transceiver. Without those installed (bare atmega1284P, nothing else drawing power) you should be in sub microamp range.

#include <LowPower.h> //get it here: https://github.com/LowPowerLab/LowPower
#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>      //get it here: https://github.com/lowpowerlab/spiflash
#include <SPIFlash.h>

#define NODEID        7    //unique for each node on same network
#define NETWORKID     100  //the same on all nodes that talk to each other
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#define FREQUENCY     RF69_433MHZ
//#define FREQUENCY     RF69_868MHZ
#define FREQUENCY     RF69_915MHZ
#define ENCRYPTKEY    "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!

RFM69 radio;
SPIFlash flash(23, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)

void setup()
{
  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  radio.sleep();
  
  if (flash.initialize())
  {
    flash.sleep();
  }
}

void loop() 
{
  //sleep 2 seconds, then wakeup 2 seconds
  LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF);
  delay(2000);
}


I haven't had a chance to test this lib when I released the MEGA since all my low power applications are for Moteino regulars.
But thanks for pointing this out!