This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to send AT commands using Keil

Hi,

I am using HC-05 bluetooth module and STM32F407. I have to enter AT Command Mode and send some AT Commands. Normally, i do it pressing button on the module. But i have to enter AT Command Mode using only software. I can enter AT Command Mode, but i can't send any AT Commands to module. I tried to change the name of the module but it didn't work.

Here is my try. Where is my mistake?

/* USER CODE BEGIN PV */
uint8_t data[50];
/* USER CODE END PV */
static void MX_USART3_UART_Init(void)
{
sprintf(data,"AT+NAME=charles \n\r");
HAL_UART_Transmit(&huart3, (uint8_t *)data, strlen(data), 2000);
}

Parents
  • >>Where is my mistake?

    Perhaps some place else..

    There is a lot of other code involved in getting the interface and peripheral set up, and some expectations about baud rates, connectivity and responses.

    Not good with embedded? Try connecting to a PC terminal via a USB-to-CMOS Serial adapter and walk through the sequences and interactions so you understand them properly.

    Does the HC05 expect <CR> <LF> or just <CR>, have you even got the order correct in your string? Remember also sprintf() returns the length.

    HAL_UART_Transmit(&huart3, (uint8_t *)data, sprintf(data,"AT+NAME=charles\r\n"), 2000);

    What response do you get from the radio? If you leave the output side connected to the USB-to-CMOS Serial adapter you could watch on the PC.

    How do other people approach debugging these things? Using scopes or logic analyzers? Understanding what the expectations of the hardware are, and meeting them.

Reply
  • >>Where is my mistake?

    Perhaps some place else..

    There is a lot of other code involved in getting the interface and peripheral set up, and some expectations about baud rates, connectivity and responses.

    Not good with embedded? Try connecting to a PC terminal via a USB-to-CMOS Serial adapter and walk through the sequences and interactions so you understand them properly.

    Does the HC05 expect <CR> <LF> or just <CR>, have you even got the order correct in your string? Remember also sprintf() returns the length.

    HAL_UART_Transmit(&huart3, (uint8_t *)data, sprintf(data,"AT+NAME=charles\r\n"), 2000);

    What response do you get from the radio? If you leave the output side connected to the USB-to-CMOS Serial adapter you could watch on the PC.

    How do other people approach debugging these things? Using scopes or logic analyzers? Understanding what the expectations of the hardware are, and meeting them.

Children