Adafruit Ultimate GPS sendCommand

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Silhouette
 
Posts: 2
Joined: Mon May 07, 2018 3:31 pm

Adafruit Ultimate GPS sendCommand

Post by Silhouette »

EDIT: Solved, Problem was with not sending "\r\n" at the end of the sentence
I'm trying to control Adafruit Ultimate GPS through STM32F407, there is an official Arduino [Library][1] and this library has a **sendCommand()** function. I'm trying to implement this sendCommand() function in Keil using HAL library

Code: Select all

   // arduino command for setting antenna off
    GPS.sendCommand("$PGCMD,33,0*6D\n");
In keil I wrote these lines

Code: Select all

uint8_t Tx_Buffer[100];
    int size;

    // Turn off antenna update nuisance data
    size = sprintf(Tx_Buffer,"$PGCMD,33,0*6D\n");
    HAL_UART_Transmit(&huart1, Tx_Buffer, size, 100);
    HAL_Delay(100);

    // Set the update speed
    size = sprintf(Tx_Buffer,"$PMTK220,500*2B");
    HAL_UART_Transmit(&huart1, Tx_Buffer, size, 100);
    HAL_Delay(100);
    
    // Request RMC and GGA sentences only
    size = sprintf(Tx_Buffer,"$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\n");	
    HAL_UART_Transmit(&huart1, Tx_Buffer ,size, 100);
    HAL_Delay(1000);
However, it seems that I am not changing anyting because it is still giving data in defaults settings. UART Baudrate is 9600 (Transmit and receive)

Can you help me with the C code? Thanks in advance.

[1]: https://github.com/adafruit/Adafruit_GP ... it_GPS.cpp
Last edited by Silhouette on Tue May 08, 2018 1:06 am, edited 1 time in total.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit Ultimate GPS sendCommand

Post by adafruit_support_mike »

The GPS module doesn't recognize a command until it sees an "\r\n" line terminator. It looks like you're only sending "\n".

User avatar
Silhouette
 
Posts: 2
Joined: Mon May 07, 2018 3:31 pm

Re: Adafruit Ultimate GPS sendCommand

Post by Silhouette »

Thank you for your answer. I have tried sending it with \n\r many times which I believe is wrong, silly me I haven't thought of changing the order to \r\n. It is working now, thanks again.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit Ultimate GPS sendCommand

Post by adafruit_support_mike »

Glad to hear that did it. Happy hacking!

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”