Power 02: Deep sleep mode
This example shows how to set Waspmote in a low-power consumption mode waking up using the RTC.

Required Materials

1 x Waspmote 1 x MiniUSB wire 1 x Battery

Notes

This example can be executed in Waspmote v12 and Waspmote v15

Code

1
/*
2
* ------ [PWR_2] Setting Deep Sleep Mode --------
3
*
4
* Explanation: This example shows how to set Waspmote in a low-power
5
* consumption mode waking up using the RTC
6
*
7
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
8
* http://www.libelium.com
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the GNU General Public License
21
* along with this program. If not, see .
22
*
23
* Version: 3.0
24
* Design: David Gascon
25
* Implementation: Marcos Yarza
26
*/
27
28
void setup()
29
{
30
USB.ON();
31
USB.println(F("PWR_2 example"));
32
}
33
34
void loop()
35
{
36
USB.println(F("enter deep sleep"));
37
// Go to sleep disconnecting all switches and modules
38
// After 10 seconds, Waspmote wakes up thanks to the RTC Alarm
39
PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);
40
41
USB.ON();
42
USB.println(F("\nwake up"));
43
44
// After wake up check interruption source
45
if( intFlag & RTC_INT )
46
{
47
// clear interruption flag
48
intFlag &= ~(RTC_INT);
49
50
USB.println(F("---------------------"));
51
USB.println(F("RTC INT captured"));
52
USB.println(F("---------------------"));
53
Utils.blinkLEDs(300);
54
Utils.blinkLEDs(300);
55
Utils.blinkLEDs(300);
56
}
57
}
Copied!

Output

1
H#
2
PWR_2 example
3
enter deep sleep
4
wake up
5
---------------------
6
RTC INT captured
7
---------------------
8
enter deep sleep
9
wake up
10
---------------------
11
RTC INT captured
12
---------------------
13
enter deep sleep
Copied!
Last modified 1yr ago