I'm currently working on a distance sensor with stm32f103cbt6 which transmits data serially using UART. I used HAL_UART_Receive function to receive the data but I cannot see any data on Serial Monitor. Moreover, the sensor works fine with Arduino.
This is the code snippet of the uart receive function.
while (1)
{
HAL_UART_Receive(&huart1, (uint8_t*)RxBuff, strlen(RxBuff), HAL_MAX_DELAY);
sprintf(txBuffer, "distance: %s\n", RxBuff);
HAL_UART_Transmit(&huart1, (uint8_t *)txBuffer, strlen(txBuffer), HAL_MAX_DELAY);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(100);
}
I also tried changing the data types of variables but nothing happened.
char txBuffer[txBuff];
char RxBuff[RxBuff_size];
uint8_t distance[1024];
Any help or guidance to this issue would be highly appreciated. Thanks in advance.