Skip to content

Merging branch AssetTracker_v11 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ SARA_R5 mySARA;
// Change the pin number if required.
//SARA_R5 mySARA(34);

// If you're using the MicroMod Asset Tracker then we need to define which pin controls the active antenna power for the GNSS.
// If you're using the MicroMod Artemis Processor Board, the pin name is G6 which is connected to pin D14.
// Change the pin number if required.
//const int antennaPowerEnablePin = 14; // Uncomment this line to define the pin number for the antenna power enable
const int antennaPowerEnablePin = -1; // Uncomment this line if your board does not have an antenna power enable

PositionData gps;
SpeedData spd;
ClockData clk;
Expand Down Expand Up @@ -86,7 +80,9 @@ void setup()
}

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

// From the u-blox SARA-R5 Positioning Implementation Application Note UBX-20012413 - R01
// To enable the PPS output we need to:
Expand Down Expand Up @@ -147,22 +143,3 @@ void printGPS(void)
Serial.println("Mode: " + String(gps.mode));
Serial.println();
}

// Disable power for the GNSS active antenna
void disableGNSSAntennaPower()
{
if (antennaPowerEnablePin >= 0)
{
pinMode(antennaPowerEnablePin, OUTPUT);
digitalWrite(antennaPowerEnablePin, LOW);
}
}
// Enable power for the GNSS active antenna
void enableGNSSAntennaPower()
{
if (antennaPowerEnablePin >= 0)
{
pinMode(antennaPowerEnablePin, OUTPUT);
digitalWrite(antennaPowerEnablePin, HIGH);
}
}
10 changes: 7 additions & 3 deletions src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1878,16 +1878,20 @@ SARA_R5_error_t SARA_R5::setBaud(unsigned long baud)
}

SARA_R5_error_t SARA_R5::setGpioMode(SARA_R5_gpio_t gpio,
SARA_R5_gpio_mode_t mode)
SARA_R5_gpio_mode_t mode, int value)
{
SARA_R5_error_t err;
char *command;

// Example command: AT+UGPIOC=16,2
command = sara_r5_calloc_char(strlen(SARA_R5_COMMAND_GPIO) + 7);
// Example command: AT+UGPIOC=23,0,1
command = sara_r5_calloc_char(strlen(SARA_R5_COMMAND_GPIO) + 10);
if (command == NULL)
return SARA_R5_ERROR_OUT_OF_MEMORY;
sprintf(command, "%s=%d,%d", SARA_R5_COMMAND_GPIO, gpio, mode);
if (mode == GPIO_OUTPUT)
sprintf(command, "%s=%d,%d,%d", SARA_R5_COMMAND_GPIO, gpio, mode, value);
else
sprintf(command, "%s=%d,%d", SARA_R5_COMMAND_GPIO, gpio, mode);

err = sendCommandWithResponse(command, SARA_R5_RESPONSE_OK,
NULL, SARA_R5_10_SEC_TIMEOUT);
Expand Down
2 changes: 1 addition & 1 deletion src/SparkFun_u-blox_SARA-R5_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ class SARA_R5 : public Print
KHZ_32768_OUT = 32,
PAD_DISABLED = 255
} SARA_R5_gpio_mode_t;
SARA_R5_error_t setGpioMode(SARA_R5_gpio_t gpio, SARA_R5_gpio_mode_t mode);
SARA_R5_error_t setGpioMode(SARA_R5_gpio_t gpio, SARA_R5_gpio_mode_t mode, int value = 0);
SARA_R5_gpio_mode_t getGpioMode(SARA_R5_gpio_t gpio);

// IP Transport Layer
Expand Down