Communication UART Entre Raspberry Pi 4 Et Stm32F401RE

by Orange Digital Center in Circuits > Microcontrollers

9 Views, 0 Favorites, 0 Comments

Communication UART Entre Raspberry Pi 4 Et Stm32F401RE

415yLfgnVLL.jpg

This project was developed within the Orange Digital Center Morocco , a space dedicated to fostering innovation, creativity, and rapid prototyping. At the FabLab, individuals and teams have access to state-of-the-art tools, including 3D printers, laser cutters, and a variety of electronic and mechanical resources. The center provides a collaborative environment where innovators, entrepreneurs, and students can transform their ideas into tangible products. By focusing on sustainable and impactful solutions .

UART (Universal Asynchronous Receiver Transmitter) communication is one of the simplest and most effective ways to exchange serial data between two microcontrollers or between a microcontroller and an embedded computer like the Raspberry Pi. This article details the setup of UART communication between a Raspberry Pi 4 and an STM32F401RE board using the STM32 HAL library and Python on the Pi.

Supplies

Raspberry Pi 4

STM32F401RE (Nucleo-64)

Fils Dupont

Adaptateur USB vers UART

Logiciel STM32CubeIDE

Creating the Project in STM32CubeIDE

Fichier 1

UART Configuration on STM32 (via STM32CubeIDE)

Fichier 2

Modify the Main.c File

Après la génération du code C, il faut remplacer le fichier main.c par le fichier main.c joint ici.

Downloads

Serial Interface Configuration on the Raspberry Pi

In the terminal, type :

sudo raspi-config

Using the arrow keys on your keyboard:

Go to "Interface Options" (or "Interfacing Options" on some versions)

Select "Serial Port"

You will see two successive questions:

  1. "Would you like a login shell to be accessible over serial?"
  2. Answer "No" (otherwise the port will be used by the console).
  3. "Would you like the serial port hardware to be enabled?"
  4. Answer "Yes"

Then, restart the Raspberry Pi.

sudo reboot

Run the Uart.py Script

lancer le script uart.py

Downloads