Skip to content

Commit 580a587

Browse files
authored
Merge pull request #1 from sparkfun/AssetTracker_v11
Merging branch AssetTracker_v11
2 parents df2a0e6 + e6c0bab commit 580a587

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

examples/SARA-R5_Example1_GNSS_GPRMC/SARA-R5_Example1_GNSS_GPRMC.ino

+3-26
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ SARA_R5 mySARA;
4040
// Change the pin number if required.
4141
//SARA_R5 mySARA(34);
4242

43-
// If you're using the MicroMod Asset Tracker then we need to define which pin controls the active antenna power for the GNSS.
44-
// If you're using the MicroMod Artemis Processor Board, the pin name is G6 which is connected to pin D14.
45-
// Change the pin number if required.
46-
//const int antennaPowerEnablePin = 14; // Uncomment this line to define the pin number for the antenna power enable
47-
const int antennaPowerEnablePin = -1; // Uncomment this line if your board does not have an antenna power enable
48-
4943
PositionData gps;
5044
SpeedData spd;
5145
ClockData clk;
@@ -86,7 +80,9 @@ void setup()
8680
}
8781

8882
// Enable power for the GNSS active antenna
89-
enableGNSSAntennaPower();
83+
// On the MicroMod Asset Tracker, the SARA GPIO2 pin is used to control power for the antenna.
84+
// We need to pull GPIO2 (Pin 23) high to enable the power.
85+
mySARA.setGpioMode(mySARA.GPIO2, mySARA.GPIO_OUTPUT, 1);
9086

9187
// From the u-blox SARA-R5 Positioning Implementation Application Note UBX-20012413 - R01
9288
// To enable the PPS output we need to:
@@ -147,22 +143,3 @@ void printGPS(void)
147143
Serial.println("Mode: " + String(gps.mode));
148144
Serial.println();
149145
}
150-
151-
// Disable power for the GNSS active antenna
152-
void disableGNSSAntennaPower()
153-
{
154-
if (antennaPowerEnablePin >= 0)
155-
{
156-
pinMode(antennaPowerEnablePin, OUTPUT);
157-
digitalWrite(antennaPowerEnablePin, LOW);
158-
}
159-
}
160-
// Enable power for the GNSS active antenna
161-
void enableGNSSAntennaPower()
162-
{
163-
if (antennaPowerEnablePin >= 0)
164-
{
165-
pinMode(antennaPowerEnablePin, OUTPUT);
166-
digitalWrite(antennaPowerEnablePin, HIGH);
167-
}
168-
}

src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -1896,16 +1896,20 @@ SARA_R5_error_t SARA_R5::setFlowControl(SARA_R5_flow_control_t value)
18961896
}
18971897

18981898
SARA_R5_error_t SARA_R5::setGpioMode(SARA_R5_gpio_t gpio,
1899-
SARA_R5_gpio_mode_t mode)
1899+
SARA_R5_gpio_mode_t mode, int value)
19001900
{
19011901
SARA_R5_error_t err;
19021902
char *command;
19031903

19041904
// Example command: AT+UGPIOC=16,2
1905-
command = sara_r5_calloc_char(strlen(SARA_R5_COMMAND_GPIO) + 7);
1905+
// Example command: AT+UGPIOC=23,0,1
1906+
command = sara_r5_calloc_char(strlen(SARA_R5_COMMAND_GPIO) + 10);
19061907
if (command == NULL)
19071908
return SARA_R5_ERROR_OUT_OF_MEMORY;
1908-
sprintf(command, "%s=%d,%d", SARA_R5_COMMAND_GPIO, gpio, mode);
1909+
if (mode == GPIO_OUTPUT)
1910+
sprintf(command, "%s=%d,%d,%d", SARA_R5_COMMAND_GPIO, gpio, mode, value);
1911+
else
1912+
sprintf(command, "%s=%d,%d", SARA_R5_COMMAND_GPIO, gpio, mode);
19091913

19101914
err = sendCommandWithResponse(command, SARA_R5_RESPONSE_OK,
19111915
NULL, SARA_R5_10_SEC_TIMEOUT);

src/SparkFun_u-blox_SARA-R5_Arduino_Library.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ class SARA_R5 : public Print
587587
KHZ_32768_OUT = 32,
588588
PAD_DISABLED = 255
589589
} SARA_R5_gpio_mode_t;
590-
SARA_R5_error_t setGpioMode(SARA_R5_gpio_t gpio, SARA_R5_gpio_mode_t mode);
590+
SARA_R5_error_t setGpioMode(SARA_R5_gpio_t gpio, SARA_R5_gpio_mode_t mode, int value = 0);
591591
SARA_R5_gpio_mode_t getGpioMode(SARA_R5_gpio_t gpio);
592592

593593
// IP Transport Layer

0 commit comments

Comments
 (0)