Hi everyone!
I am using an Arduino MICRO in my project. My goal is it to power the Arduino with a LiPo about 2 weeks. Which does not seem unrealistically...
The same LiPo will also power a small sensor and a SIM 800L Module.
It is all working and I could run the system well over 14h. In this test I did not use any sleep modes, just delay() for idle time. I have read that delay is a "busy waiting" and does need the same amount of power like any other computation on the Arduino.
Now I try to implement the sleep modes, but I fail with the wake up.
This is my code, which is working
#include <avr/wdt.h>
#include <avr/sleep.h>
#include <avr/power.h>
const int ledPin = 13;
const int resetPin = 12;
int cycles = 0;
volatile int i_am_in_sleep = 0;
void setup()
{
pinMode(ledPin,OUTPUT);
digitalWrite(ledPin,LOW);
digitalWrite(resetPin, HIGH);
pinMode(resetPin,OUTPUT);
i_am_in_sleep = 0;
watchdogSetup();
}
void watchdogSetup(void){
cli(); // disable all interrupts
wdt_reset();
WDTCSR |= (1<<WDCE) | (1<<WDE);
WDTCSR = (1<<WDIE) | (0<<WDE) | (1<<WDP3); // 4s / no interrupt, system reset
sei();
}
void loop()
{
delay(500);
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
delay(2000); //after blink you have 2secs to for upload
digitalWrite(ledPin,HIGH);
delay(100);
digitalWrite(ledPin,LOW);
i_am_in_sleep = 1;
delay(500);
while(i_am_in_sleep > 0)
{
enter_sleep();
}
i_am_in_sleep = 0;
}
void enter_sleep(void)
/* Arduino schlafen legen */
{
sleep_enable();
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_cpu();
}
void hardwarereset()
{
digitalWrite(resetPin, LOW);
delay(300);
digitalWrite(resetPin, HIGH);
delay(300);
}
ISR(WDT_vect)
{
cycles += 1;
Serial.println("wake up?");
if(i_am_in_sleep> 0)
{
if(cycles>3)
{
Serial.println("yess! And reset");
delay(500);
cycles = 0;
hardwarereset();
}
else
{
Serial.println("not yet...");
delay(500);
}
}
else
{
Serial.println("not sleeping...");
}
}
I have PIN 12 (digital i/o) connected with 1kOhm to Reset-Pin (RS).
Also a LED is connected at PIN 13 and it blinks two times shortly, when the board is awake.
After the two blinks the board goes into SLEEP_MODE_IDLE.
From the watchdog I get a interrupt every 4secs and when I get the fourth interrupt I do a hardreset via PIN 13. This is all fine.
My problem:
Whatever other SLEEP_MODE I use, the wake up fails.
I want to use
SLEEP_MODE_PWR_DOWN
but I get no interrupt from the watchdog.
All info about sleep modes I find is with Arduino UNO, but I have a MICRO, which has a different ATMega processor. Maybe that is the problem?
-
Did anyone have luck with the Arduino MICRO and other sleep modes than IDLE?
-
I read about external Real Time Clocks to trigger a reset of the Arduino. Are there any cheap and simple solutions to achieve about 10min to 2h wake-up cycles?
-
Should I pick a different Arduino? Which one would offer the deeper sleep modes? I am very happy with the size of the micro. The Uno is too large. But what about the Mini or ProMini? Unfortunatly Mini and Pro Mini do not have a USB connection for programming. I have a FTDI 232 adapter but never used it... i hope its not complicated...