cancel
Showing results for 
Search instead for 
Did you mean: 

UART doesn't receive data from HC-06

Xenon02
Senior

Hello ! 
My STM board is STM32-L073RZ. 

I've had a lot of problem with HC-06, tried to somehow send the command "AT" or "AT\r\n", but I didn't get anything back. The bluetooth wasn't connected to any device because the diode was blinking. 

- I tried changing the Baund Rate from 9600 to higher it didn't work.
- I've tried to add Pull up on TX,RX (I've read maybe it doesn't have internal so I've added but it didn't work) : 

Xenon02_0-1704552517089.png

- I've even took off the voltage divider and it didn't work, It was added from the start like in this example : 

Xenon02_1-1704552588281.png

Here is the code : 

  char response[100] = "";

  while (1)
  {
	  // Send AT command to HC-06
	      char atCommand[] = "AT\r\n";
	      HAL_UART_Transmit(&huart2, (uint8_t *)atCommand, sizeof(atCommand)-1, 500);

	      // Add a delay to allow time for the HC-06 to process the command
	      HAL_Delay(1000);

	      // Handle the response from HC-06 (you may need to implement a function to receive and process data)
	      // For simplicity, you can use a blocking receive function like HAL_UART_Receive.

	      // Example of receiving response
	      HAL_UART_Receive(&huart2, (uint8_t *)response, sizeof(response)-1, 500);
	      response[sizeof(response)-1] = '\0'; // Null-terminate the string
	      printf("%s --\n", response);
	      // Process or print the received response as needed
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

 
I also thought that Arduino didn't add pull up for the HC-06 but maybe they have always turned on ? So I have to add pull up for STM32, I did but it still didn't work. I was expecting and "OK" response instead I had "--" and the response array was empty. 

I don't know where is the error. 

10 REPLIES 10

I found the solution and as you said I had to change just the UART. 

Although I do have 4 questions if it's possible to get answers ? :

- A got very confused on reading the schematic of how this boards works like : 

Xenon02_0-1704572635809.png

Xenon02_1-1704572659180.png


I tried to understand how UART2 works exactly which is PA2 and PA3. The thing is they are connected from the first picture to TX and RX and the D0 and D1 are disconnected. So it means I can use the ST connectors/Morpho connectors as the UART ? Without changing anything ? And what is the difference in STLK_RX and STLK_TX (isn't it that I can use any RX and TX for my STlink ?) .

- About the picture because the second picture is the same part as the first picture ? Dunno because the second picture doesn't have label of what it is. 

- I don't understand what is happening here, there is TMS and JTMS and they are wierdly connected like what ?

Xenon02_2-1704573242561.png

- Last *** question does those yellow brakets like "MCO" or "RX" or "STLK_RX" are they connected to a device or is it just to say what I can connect to them ? Like "MCO" so I can connect MCO to it or "TCK on picture above" is that I can connect TCK to it ?