Author Topic: Moteino Power-Down Code  (Read 3891 times)

evh

  • NewMember
  • *
  • Posts: 17
Moteino Power-Down Code
« on: April 13, 2015, 05:28:40 PM »

I just got some Moteinos with RFM69HW.

I can't get low power/sleep mode to work.  Is there a sketch somewhere which demostrates how to power down everything on this board, including the Flash, RTC, uP, and Radio?  With the lowpower.h library and the radio.sleep(), I am still above 1000uA.

I found a sketch that does this for the RFM12 .... but nothing for the HW and the latest version of Moteino . 

Thanks!


evh

  • NewMember
  • *
  • Posts: 17
Re: Moteino Power-Down Code
« Reply #1 on: April 13, 2015, 07:00:49 PM »
I just got it down to 17uA.  The sketch is attached below.

PROBLEM:  I am running with two 1.5v Alkaline, for 3v total.

If I hook the batteries via Vin and the regulator, then I get about 120mA draw.  Which is obviously, horrible.

If I hood the batteries to the 3.3v pin, I get about 120uA draw.  Which is 100 times better, but still terrible for battery use.

If I hook to 3.3v and unsolder the voltage regulator chip, the draw goes to 17uA, which is OK.  But this is a bummer, since it means that I must unsolder the regulator chip for each unit.  But then the board cannot be reprogrammed if necessary.  An awkward fix would be to do a new boardwith a jumper to connect or disconnect the regulator chip.  Or am I missing something?

Here is the sketch:

Code: [Select]
// Sample RFM69 sender/node sketch, with ACK and optional encryption
// Sends periodic messages of increasing length to gateway (id=1)
// It also looks for an onboard FLASH chip, if present
// Library and code by Felix Rusu - felix@lowpowerlab.com
// Get the RFM69 and SPIFlash library at: https://github.com/LowPowerLab/

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

#define NODEID        13    //unique for each node on same network
#define NETWORKID     100  //the same on all nodes that talk to each other
#define GATEWAYID     1
//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!
#ifdef __AVR_ATmega1284P__
  #define LED           15 // Moteino MEGAs have LEDs on D15
  #define FLASH_SS      23 // and FLASH SS on D23
#else
  #define LED           9 // Moteinos have LEDs on D9
  #define FLASH_SS      8 // and FLASH SS on D8
#endif

#define SERIAL_BAUD   1200

int temp_address = 72;
SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)
RFM69 radio;

void setup() {
  //Serial.begin(9600);
  //Create a Wire Object
  Wire.begin();

  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  //radio.setFrequency(919000000); //set frequency to some custom frequency
  char buff[50];
  sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
 
  if (flash.initialize())
  {
    Serial.print("SPI Flash Init OK ... UniqueID (MAC): ");
    flash.readUniqueId();
    for (byte i=0;i<8;i++)
    {
      Serial.print(flash.UNIQUEID[i], HEX);
      Serial.print(' ');
    }
    Serial.println();
  }
  else
    Serial.println("SPI Flash Init FAIL! (is chip present?)");
}

long lastPeriod = 0;
void loop() {

     char out_temp[30]="test";
     char inbuffer[20];
     int loopcounter=0;
 
     
   
    radio.send(GATEWAYID, out_temp, 12 );
    radio.sleep();
    flash.sleep();
    //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF,SPI_OFF, USART0_OFF, TWI_OFF); //  1.36mA
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}





« Last Edit: April 13, 2015, 08:40:35 PM by Felix »

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Power-Down Code
« Reply #2 on: April 13, 2015, 08:14:19 PM »
I think you can plan on +19uA overhead if you use the Moteino onboard regulator and, as you've observed, you need a Vin voltage at or above 3.7V to work reliably.  I switch the fuses on the Moteino to operate on internal 8MHz clock, operate at 3.0V nominal, and remove the Vr (it's easy to remove and you get Felix to supply you with 'free' VRs that you can use elsewhere!  ;D ) if I care about power consumption (on about 50% of my motes).  There is a thread that discusses this, see https://lowpowerlab.com/forum/index.php/topic,695.0.html

Also, I use Sleep_n0m1 library rather than the Lowpower library as it's able to give me the easiest and lowest power consumption control.

Tom
« Last Edit: April 13, 2015, 08:18:39 PM by TomWS »

evh

  • NewMember
  • *
  • Posts: 17
Re: Moteino Power-Down Code
« Reply #3 on: April 14, 2015, 01:51:25 AM »

Thanks for your response.

QUESTION:  Are you saying that the uP won't run properly on 3V unless the clock is taken to 8Mhz?

I was thinking of replacing the regulator with a 2.8v or 2.5v unit, so reprogramming would be possible.


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Moteino Power-Down Code
« Reply #4 on: April 14, 2015, 08:08:35 AM »
16mhz at 2.5v you are realllly pushing it. You will at least have to go down to 8mhz at that voltage.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Power-Down Code
« Reply #5 on: April 14, 2015, 09:39:32 AM »

Thanks for your response.

QUESTION:  Are you saying that the uP won't run properly on 3V unless the clock is taken to 8Mhz?
That is what the datasheet says.  I have had issues running 16MHz at voltages 'near' (ie just less than) 3V at the processors, but I've also had issues running at full voltage  ;)  I can't attest which is cause and which is effect.  However, I trust the datasheet and since I want to run reliably at 3V because it's a convenient voltage, I DO drop the frequency to 8MHz.
I was thinking of replacing the regulator with a 2.8v or 2.5v unit, so reprogramming would be possible.
I do not know what you mean by this statement.  What 'reprogramming' are you referring to?

Also, don't fall into the trap of diminishing returns, this processor and radio, when running at 3V, no VR, and sleeping will give you literally years of battery life.

Tom

evh

  • NewMember
  • *
  • Posts: 17
Re: Moteino Power-Down Code
« Reply #6 on: April 17, 2015, 06:56:41 PM »

OK,  my discovery is that there is a problem with running on 3v i.e. 2 alkaline cells.

So, I got 3-cell battery holders and am now running on 4.5v, and using the on-board voltage regulator.  This solves the problems, and I am drawing 19uA. 

Thanks for everyone's suggestions.