Docs

Micro-controllers, wireless transmission and database

Head

STM32 Blue Pill UART Debug via Arduino UNO using STM32CubeIDE

Prerequisites

This project assumes you have already installed STM32CubeIDE. You need to have previously done a basic blink sketch with blue-pill using STM32CubeIDE. I have made a complete video from installing STM32CubeIDE to LED blink program. You can watch it by clicking this link. https://www.youtube.com/watch?v=kXg467nVd_A

Wiring Diagram

Diagram

STM32CubeIDE Settings

Enable USART1 asynchronous

Additional code on top of STM32CubeIDE generated code

/* USER CODE BEGIN Includes */
#include <string.h>
#include <stdio.h>
/* USER CODE END Includes */

/* USER CODE BEGIN 0 */
int myNum = 2024; // Integer (whole number)
float myFloatNum = 5.98; // Floating point number
char myLetter = 'D';
uint8_t myUint = 21; // Same way for uint16_t or uint32_t
uint8_t myArray[20] = {0};
char charData[20]; // Data holder
/* USER CODE END 0 */

 /* USER CODE BEGIN WHILE */
  while (1)
  {
      HAL_UART_Transmit(&huart1, (unsigned char *)"While reached\r\n", 15, 1000);
      HAL_Delay(100);
      sprintf(charData,"Number %d\r\n",myNum);
      HAL_UART_Transmit(&huart1,(uint8_t *)charData,strlen(charData),1000);
      myNum++;
      HAL_Delay(100);
      sprintf(charData,"Number %f\r\n",myFloatNum);
      HAL_UART_Transmit(&huart1,(uint8_t *)charData,strlen(charData),1000);
      HAL_Delay(100);
      sprintf(charData,"Letter %c\r\n",myLetter);
      HAL_UART_Transmit(&huart1,(uint8_t *)charData,strlen(charData),1000);
      HAL_Delay(100);
      sprintf(charData,"Uint8_t %d\r\n",myUint);
      HAL_UART_Transmit(&huart1,(uint8_t *)charData,strlen(charData),1000);
      HAL_Delay(100);
      myArray[5]=7;
      sprintf(charData,"Array Element %d\r\n", myArray[5]);
      HAL_UART_Transmit(&huart1,(uint8_t *)charData,strlen(charData),1000);
      HAL_Delay(100);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */