I create a project to monitor the temperature and humidity of my room. And send the data to pachube.com. The sampling period is 1 minute. The used hardwares are Arduino Mega 1280 + Ethernet shield + Sensor DHT11 + Sensor AM2311. The system is running 7 X 24h.
I want to reduce the power consumption as more as possible. The system only detects and uploads the data every one minute and most of the time it is idle. Is it possible to cut off the power to the Ethernet shield and the sensors when the system don't need to detect temperature or upload data to pachube? Is there any way to make the arduino itself consume less power when it is idle?
"Arduino uses digital pins 10, 11, 12, and 13 (SPI) to communicate with the W5100 on the ethernet shield. "
I don't know if the chip has any kind of power down commands that you can send to it.
CrossRoads:
You can put the arduino into power down sleep mode, save on power.
Thanks CrossRoads.
How to put the arduino into the sleep mode? Is there any library support it? Or where can I get the sample code?
How much of the difference of the power consumption between the normal mode and sleep mode?
Difference -really depends how much you have going on.
I imagine you'd get more power savings by using an efficient offboard 5v switching regulator vs the onboard linear regulator, maybe do the same for 3.3V for the shield?
You can browse the Playground for Sleep Library.
I used this stuff to make an RF remote go to sleep, but it used an external hardware interrupt to wake up.
You could perhaps add an external low power 555 circuit in stable mode to wake up with occasionally.
Or an RTC chip like DS1307 that has 1 Hz square wave output, use as trigger to wake up.
Read the time, if 1 minute not elapsed, go back to sleep ...
#include <avr/sleep.h> // powerdown library
#include <avr/interrupt.h> // interrupts library
int sleep_flag = 0; // flag to tell us to go sleep
//***************************************************
// * Name: pin2Interrupt, "ISR" to run when interrupted in Sleep Mode
void pin2Interrupt()
{
/* This brings us back from sleep. */
}
//***************************************************
// * Name: enterSleep
void enterSleep()
{
/* Setup pin2 as an interrupt and attach handler. */
attachInterrupt(0, pin2Interrupt, LOW);
delay(50); // need this?
/* the sleep modes
SLEEP_MODE_IDLE - the least power savings
SLEEP_MODE_ADC
SLEEP_MODE_PWR_SAVE
SLEEP_MODE_STANDBY
SLEEP_MODE_PWR_DOWN - the most power savings
*/
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // setting up for sleep ...
sleep_enable(); // setting up for sleep ...
// <<<<<<<<<<<<<<<< March 2, 2011 - added some more power down stuff >>>>>>>>>>>>>>>>
// Disable ADC
ADCSRA &= ~(1 << ADEN);
// Power down functions
PRR = 0xFF;
// <<<<<<<<<<<<<<<<< end of new March 2 stuff >>>>>>>>>>>>>>>>>>>>>>>
sleep_mode(); // now goes to Sleep and waits for the interrupt
/* The program will continue from here after the interrupt. */
detachInterrupt(0); //disable interrupts while we get ready to read the keypad
// <<<<<<<<<<<<<<<< March 2, 2011 - added some more power down stuff >>>>>>>>>>>>>>>>
// Power up functions
PRR = 0x00;
// <<<<<<<<<<<<<<<<< end of new March 2 stuff >>>>>>>>>>>>>>>>>>>>>>>
/* First thing to do is disable sleep. */
sleep_disable();
// then go to the void Loop()
}
// set up the pins as Inputs, Outputs, etc.
void setup()
{
/* Setup the pin directions, write inputs High to turn on internal pullups */
pinMode(pin2, INPUT); // our sleep interrupt pin
digitalWrite(pin2, HIGH);
}
// Main loop for reading the keypad and sending the button pushed out
// (with a unique address to be added eventually by reading 0-F from currently unused pins)
void loop()
{
if (sleep_flag == 1){ // check if we should go to sleep
sleep_flag=0; // clear for next time awake
enterSleep(); // call Sleep function to put us out
// THE PROGRAM CONTINUEs FROM HERE after waking up in enterSleep()
}
// do whatever you do while awake
// and when done, set sleep_flag = 0;
} // end of void loop