I am using STM32F103C8 board and CubeMX to create the code. I have connected the M66 to STM32 to UART2 port. I try to send some commands to Quectel M66 via STM32's UART port. It receives the command but throws some junk characters. I have set the baud rate as 9600 for all UART ports. This is my code

void M66_Check()
  char *buffer = "ATI\r\n";
    char *rec_buffer = NULL;
    rec_buffer = (char*)malloc(200 * sizeof(char));
    if(HAL_UART_Transmit(&huart2,buffer,strlen(buffer),200) == HAL_OK)
        printf("AT Command sent successfully\r\n");
        printf("Not Sent\r\n");

    printf("About to print Response from M66 \r\n");



This is what I am getting...Result in Putty Any help would be greatly appreciated

2 Answers

P__J__ On

There is the only way - read the answer and parse it. Then you will know if the command was executed ok.

But your response shows that your UART is running another speed (9600) than the modem. If you have not changed anything it should be 115200 as it is default modem UART speed

Community On

I have found out the problem... I needed to transmit and receive in these formats.... I missed those (uint8_t *). To Transmit - HAL_UART_Transmit(&huart2, (uint8_t *)buffer, strlen(buffer), 100);

To Receive - HAL_UART_Receive(&huart2, (uint8_t *)rec_buffer,50,2000);

Now there is no problem and I am getting the response correctly.

Thanks for your help...