Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 0f7a8c3

Browse files
committed
added example + better description in src
1 parent 2580acb commit 0f7a8c3

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

Diff for: examples/Example22_PowerOff/Example22_PowerOff.ino

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
Powering off a ublox GPS module
3+
By: bjorn
4+
unsurv.org
5+
Date: July 20th, 2020
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows you how to turn off the ublox module to lower the power consumption.
10+
There are two functions: one just specifies a duration in milliseconds the other also specifies a pin on the GPS device to wake it up with.
11+
By driving a voltage from LOW to HIGH or HIGH to LOW on the chosen module pin you wake the device back up.
12+
Note: Doing so on the INT0 pin when using the regular powerOff(durationInMs) function will wake the device anyway. (tested on SAM-M8Q)
13+
Note: While powered off, you should not query the device for data or it might wake up. This can be used to wake the device but is not recommended.
14+
Works best when also putting your microcontroller to sleep.
15+
16+
Feel like supporting open source hardware?
17+
Buy a board from SparkFun!
18+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
19+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
20+
SAM-M8Q: https://www.sparkfun.com/products/15106
21+
22+
Hardware Connections:
23+
Plug a Qwiic cable into the GPS and a BlackBoard.
24+
To force the device to wake up you need to connect to a pin (for example INT0) seperately on the module.
25+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
26+
Open the serial monitor at 115200 baud to see the output
27+
*/
28+
29+
#include "SparkFun_Ublox_Arduino_Library.h" //http://librarymanager/All#SparkFun_Ublox_GPS
30+
SFE_UBLOX_GPS myGPS;
31+
32+
// define a digital pin capable of driving HIGH and LOW
33+
#define WAKEUP_PIN 5
34+
35+
// interrupt pin mapping
36+
#define GPS_RX 0
37+
#define GPS_INT0 1
38+
#define GPS_INT1 2
39+
#define GPS_SPI_CS 3
40+
41+
42+
void wakeUp() {
43+
44+
Serial.print("-- waking up module via pin " + String(WAKEUP_PIN));
45+
Serial.println(" on your microcontroller --");
46+
47+
digitalWrite(WAKEUP_PIN, LOW);
48+
delay(1000);
49+
digitalWrite(WAKEUP_PIN, HIGH);
50+
delay(1000);
51+
digitalWrite(WAKEUP_PIN, LOW);
52+
}
53+
54+
55+
void setup() {
56+
57+
pinMode(WAKEUP_PIN, OUTPUT);
58+
59+
Serial.begin(115200);
60+
while (!Serial); //Wait for user to open terminal
61+
Serial.println("SparkFun Ublox Example");
62+
63+
Wire.begin();
64+
65+
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
66+
{
67+
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
68+
while (1);
69+
}
70+
71+
// Powering off for 20s, you should see the power consumption drop.
72+
Serial.println("-- Powering off module for 20s --");
73+
74+
myGPS.powerOff(20000);
75+
// myGPS.powerOffWithInterrupt(20000, GPS_INT0);
76+
77+
delay(10000);
78+
79+
// After 10 seconds wake the device via the specified pin on your microcontroller and module.
80+
wakeUp();
81+
}
82+
83+
void loop() {
84+
//Do nothing
85+
}

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2571,8 +2571,8 @@ uint8_t SFE_UBLOX_GPS::getPowerSaveMode(uint16_t maxWait)
25712571

25722572
// Powers off the GPS device for a given duration to reduce power consumption.
25732573
// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up!
2574-
// returns true if command has not failed
2575-
// returns false if command has not been acknowledged or maxWait = 0
2574+
// Returns true if command has not been not acknowledged.
2575+
// Returns false if command has not been acknowledged or maxWait = 0.
25762576
boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
25772577
{
25782578
// use durationInMs = 0 for infinite duration
@@ -2610,10 +2610,10 @@ boolean SFE_UBLOX_GPS::powerOff(uint32_t durationInMs, uint16_t maxWait)
26102610

26112611
// Powers off the GPS device for a given duration to reduce power consumption.
26122612
// While powered off it can be woken up by creating a falling or rising voltage edge on the specified pin.
2613-
// NOTE: The GPS seems to detect small voltage edges on the interrupt pin. Works best when Microcontroller is in deepsleep.
2613+
// NOTE: The GPS seems to be sensitve to signals on the pins while powered off. Works best when Microcontroller is in deepsleep.
26142614
// NOTE: Querying the device before the duration is complete, for example by "getLatitude()" will wake it up!
2615-
// returns true if command has not failed
2616-
// returns false if command has not been acknowledged or maxWait = 0
2615+
// Returns true if command has not been not acknowledged.
2616+
// Returns false if command has not been acknowledged or maxWait = 0.
26172617
boolean SFE_UBLOX_GPS::powerOffWithInterrupt(uint32_t durationInMs, uint8_t wakeupPin, boolean forceWhileUsb, uint16_t maxWait)
26182618
{
26192619
// use durationInMs = 0 for infinite duration

0 commit comments

Comments
 (0)