veille,
ArduiNo
divers ersatz abandonnés
20160122: un essai : ArduinoproMiniPowerDown (en échec) et contournement: ArduinoSleepThenReboot
bac à sable: C:\Users\adminpo\Desktop\ARDUINO\arduino-1.0.5 - 2016\examples\Po\SleepTimer?
et C:\Users\adminpo\Desktop\ARDUINO\arduino-1.0.5 - 2016\examples\Po\SleepTimerWireReset?
20160305: un succès:
ArduinoPwrDown
lu:
différents modes (sur le processeur)
lire:
http://avratmega32.blogspot.fr/2011/07/sleep-modes-of-atmega32.html
CPU Sleep Modes
SM2 SM1 SM0 Sleep Mode
0 0 0 Idle
0 0 1 ADC Noise Reduction
0 1 0 Power-down
0 1 1 Power-save
1 0 0 Reserved
1 0 1 Reserved
1 1 0 Standby(1)
au niveau du programme:
* 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
vraisemblablement surtout des différences sur le réveil, peu sur la consommation.
voir pages sur pire: supprimer diode etc...
la suite pour mémoire
lire:
http://playground.arduino.cc/Learning/ArduinoSleepCode
http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/
par timer interne:
http://donalmorrissey.blogspot.fr/2011/11/sleeping-arduino-part-4-wake-up-via.html
exemple; la conso passe à 6.3 mA (diode éteinte, 18 diode allumée, c'est beaucoup)!
le progrmme commence par clignoter 10 fois à 10"
puis sleep par 5"
/*
* Sketch for testing sleep mode with wake up on timer.
* Donal Morrissey - 2011.
*
*/
#include <avr/sleep.h>
#include <avr/power.h>
#define LED_PIN (13)
volatile int f_timer=0;
int chauffage=20;
/***************************************************
* Name: ISR(TIMER1_OVF_vect)
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Timer1 Overflow interrupt.
*
***************************************************/
ISR(TIMER1_OVF_vect)
{
/* set the flag. */
if(f_timer == 0)
{
f_timer = 1;
}
}
/***************************************************
* Name: enterSleep
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Enters the arduino into sleep mode.
*
***************************************************/
void enterSleep(void)
{
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
/* Disable all of the unused peripherals. This will reduce power
* consumption further and, more importantly, some of these
* peripherals may generate interrupts that will wake our Arduino from
* sleep!
*/
power_adc_disable();
power_spi_disable();
power_timer0_disable();
power_timer2_disable();
power_twi_disable();
/* Now enter sleep mode. */
sleep_mode();
/* The program will continue from here after the timer timeout*/
sleep_disable(); /* First thing to do is disable sleep. */
/* Re-enable the peripherals. */
power_all_enable();
}
/***************************************************
* Name: setup
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Setup for the serial comms and the
* timer.
*
***************************************************/
void setup()
{
Serial.begin(9600);
Serial.println("[sleep watch");
Serial.println("[sleep watch");
Serial.println("[sleep watch");
Serial.println("[sleep watch");
Serial.println("[sleep watch");
Serial.println("[sleep watch");
/* Don't forget to configure the pin! */
pinMode(LED_PIN, OUTPUT);
/*** Configure the timer.***/
/* Normal timer operation.*/
TCCR1A = 0x00;
/* Clear the timer counter register.
* You can pre-load this register with a value in order to
* reduce the timeout period, say if you wanted to wake up
* ever 4.0 seconds exactly.
*/
TCNT1=0x0000;
/* Configure the prescaler for 1:1024, giving us a
* timeout of 4.09 seconds.
*/
TCCR1B = 0x05;
/* Enable the timer overlow interrupt. */
TIMSK1=0x01;
}
/***************************************************
* Name: enterSleep
*
* Returns: Nothing.
*
* Parameters: None.
*
* Description: Main application loop.
*
***************************************************/
void loop()
{
if (chauffage>0) {
chauffage=chauffage-1;
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
delay(1000);
if (chauffage==0) Serial.println("fin du clignottement");
} else if(f_timer==1)
{
f_timer = 0;
/* Toggle the LED */
digitalWrite(LED_PIN, !digitalRead(LED_PIN));
/* Re-enter sleep mode. */
enterSleep();
}
}