Acc 08: Sleep to wake mode
This example shows how to manage the sleep to wake mode.

Required Materials

1 x Waspmote 1 x MiniUSB wire

Notes

This example can be executed in Waspmote v12 and Waspmote v15

Code

1
/*
2
* ------ [ACC_8] Waspmote Accelerometer sleep to wake Example--------
3
*
4
* Explanation: This example shows how to manage the sleep to wake
5
* mode
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 <http://www.gnu.org/licenses/>.
22
*
23
* Version: 3.0
24
* Design: David Gascón
25
* Implementation: Marcos Yarza
26
*/
27
28
long previous = 0;
29
30
void setup()
31
{
32
ACC.ON();
33
USB.ON(); // starts using the serial port
34
USB.println(F("ACC_08 example"));
35
}
36
37
void loop()
38
{
39
ACC.ON();
40
USB.println(F("\r\nAccelerometer ON"));
41
ACC.setMode(ACC_LOW_POWER_5);
42
ACC.setFF();
43
USB.println("Free Fall interrupt configured");
44
USB.println(F("Accelerometer mode: ACC_LOW_POWER_5"));
45
46
// Sleep to Wake activation
47
ACC.setSleepToWake();
48
USB.println("Sleep to Wake mode configured");
49
50
PWR.sleep(ALL_OFF);
51
52
if( intFlag & ACC_INT )
53
{
54
// unset the Sleep to Wake
55
ACC.unSetSleepToWake();
56
// clear the accelerometer interrupt flag on the general interrupt vector
57
intFlag &= ~(ACC_INT);
58
// read the acceleration source register
59
delay(200);
60
USB.ON();
61
USB.println(F("++++++++++++++++++++++++++++++++++"));
62
USB.println(F("++ Free Fall interrupt detected ++"));
63
USB.println(F("++++++++++++++++++++++++++++++++++"));
64
}
65
delay(2000);
66
}
Copied!

Output

1
H#
2
ACC_08 example
3
4
Accelerometer ON
5
Free Fall interrupt configured
6
Accelerometer mode: ACC_LOW_POWER_5
7
Sleep to Wake mode configured
8
9
Accelerometer ON
10
Free Fall interrupt configured
11
Accelerometer mode: ACC_LOW_POWER_5
12
Sleep to Wake mode configured
Copied!
Last modified 1yr ago