... starting to look at different sleep/wake and on-board peripheral power options for the arduino and it appears that the IDE and most of the examples make heavy use of the power and sleep libraries here: avr-libc: Modules
Within the power libary (avr-libc: <avr/power.h>: Power Reduction Management) there is a lengthy listing of all the AVR chips that are supported - the 328p is noticably absent from this list. Since this is the chip that makes up the core of my Uno and Pro mini boards, should I be concerned about this?
I'll add some broken code to this post when I get home from work, but, basically, I haven't been able to get any meaningful Serial.println data to go to the SerialMonitor after waking from sleep. ... suspect USART isn't working, but can't get it to re-start.
here's the broken code (expecting clean output to the Serial Monitor on wake, getting jibberish on button press instead):
/* test sketch based on example code from Rocket Scream.
http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/
specifically:
https://github.com/rocketscream/Low-Power/tree/master/Examples/powerDownWakeExternalInterrupt
... modified July 2012 to:
use internal pull up resistor,
change interrupt from LOW to FALLING,
power up the on-chip peripherals, and
attempt output of test mssg to pc via serial connection.
compiled using Arduino IDE 1.0.1. loaded onto 3.3 V/8 mHz arduino mini pro.
*/
// **** INCLUDES *****
#include <LowPower.h>
#include <avr/power.h>
// Use pin 2 as wake up pin
const int wakeUpPin = 2;
void wakeUp()
{
// Just a handler for the pin interrupt.
}
void setup()
{
// Configure wake up pin as input.
// This will consumes few uA of current.
pinMode(wakeUpPin, INPUT);
digitalWrite(2, HIGH);
Serial.begin(9600);
}
void loop()
{
// Allow wake up pin to trigger interrupt on falling.
attachInterrupt(0, wakeUp, FALLING);
// Enter power down state with ADC and BOD module disabled.
// Wake up when wake up pin is low.
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
detachInterrupt(0);
// Do something here
// Example: Read sensor, data logging, data transmission.
power_all_enable(); // command to restore on-chip peripheral power
// as suggested by Premeaux, Emery; Evans, Brian (2011-12-07).
// Arduino Projects to Save the World. Apress.
delay(100);
// the following pinMode and digitalWrite commands work regardless of the
// power_all_enable cmd.
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(5000); // keep light illuminated for 5 sec, so I can measure current.
digitalWrite(13, LOW);
delay(5000); // go dark for another 5 sec, so I can also measure current.
digitalWrite(13, HIGH);
delay(5000); // light back up for another 5 sec, so I can also measure current.
digitalWrite(13, LOW);
Serial.println("Do Something"); // doesn't work.
// jibberish: ÔÒÕ««-ëVHø
// sent to serial monitor each time after the second time the button pressed.
}
What's going on here?
Thoughts? Impressions? Feelings? ... share away.
Thanks.
-Matt