This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Receiving data from GPS L80 with nrf52832 via UART

I am trying to receive data from GPS L80 with the nrf52832 board but I am not able to receive anything. I connected the Rx of nrf52832 with GPS and vice versa. I also connected the grounds of both these devices together. I am hereby attaching my code , Please help me regarding the same.

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "app_uart.h"
#include "app_error.h"
#include "nrf_delay.h"
#include "nrf.h"
#include "bsp.h"
#include "nrf_uart.h"

NRF_UART_Type uart1;

#define uart1_rx NRF_GPIO_PIN_MAP(0,22)
#define uart1_tx NRF_GPIO_PIN_MAP(0,23)

int main(void)
{
    nrf_uart_enable(&uart1);
    nrf_uart_txrx_pins_set(&uart1, 6, 8);
    nrf_uart_baudrate_set(&uart1,NRF_UART_BAUDRATE_115200);

char UART_RX_BUF[256];
int i=0;
    while (i<256)
    {   
        
        UART_RX_BUF[i] = nrf_uart_rxd_get(&uart1);
        i++;
    }

}

Parents
  • Hi,

    You do not assign any useful value to uart1. You should rather pass the existing symbol of NRF_UART_Type that is defined in nrf52.h: NRF_UART0.

    Best regards,
    Jørgen

  • Hi sir,

    I executed it and now it is working fine, but now I am trying to communicate with GPS L80 by trying to send its PMTK commands. I converted the command into a string so that  nrf52832 controller transmits the whole string at a time and the GPS can execute the command but I am not able to send the whole string at one time, I am using the ble_app_uart code please can you help me? I am attaching the code.

    Regards

    #define MCU_TX 23
    #define MCU_RX 24
    int main(void)
    {
    uint8_t rxBuff[10];
        char txBuff[]="$PMTK225,4*2F<CR><LF>";
        app_uart_flush();
        while (true)
        {
        for(int i=0;i<22;i++){
            while (app_uart_put(txBuff[i]) != NRF_SUCCESS);
            }
            nrf_delay_ms(2000);
             }
             }

  • I am not able to send the whole string at one time

    Why not - what prevents you ?

    What were you expecting to happen?

    What is actually happening?

    Have you stepped through your code in the debugger to see what's going on?

    In particular, what do you think this is going to do:

    while (app_uart_put(txBuff[i]) != NRF_SUCCESS);

    I don't think your command string is correct:

    char txBuff[]="$PMTK225,4*2F<CR><LF>";

    Instead of "<CR><LF>" I think you mean "\r\n" ... ?

  • Yes sir you are right, I am giving the command  "$PMTK225,4*2F\r\n" , this command is supposed to send the GPS L80 module in the backup mode, i.e., it should stop transmitting anything. But I think  that by using this code "while (app_uart_put(txBuff[i]) != NRF_SUCCESS);" I am not able to send the command. This statement should send the string char by char to the GPS until the controller returns NRF_SUCCESS which indicates that the whole string is sent and the GPS should go in backup mode, but it's not happening and the GPS is showing no response. What should I do sir?

  • I am giving the command  "$PMTK225,4*2F\r\n"

    That is not what the code you posted had!

    I think  that by using this code "while (app_uart_put(txBuff[i]) != NRF_SUCCESS);" I am not able to send the command.

    So what actually happens?

    What do you see coming from the UART when you run the code?

    Have you stepped the code in the debugger to see what is actually going on?

Reply Children
No Data
Related