Skip to content

Connecting a micro controller with a PC is simple when using google protocol buffers. This example shows you how you could communicate over UART in a structured manner. Embedded Proto is used to generate the embedded code while regular protoc code is used for the python desktop script. Commands are send from the PC to the micro controller. The c…

Notifications You must be signed in to change notification settings

Embedded-AMS/EmbeddedProto_Example_STM32_UART

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt text

Copyrights 2020-2024 Embedded AMS B.V. Hoorn, www.EmbeddedAMS.nl, info@EmbeddedAMS.nl

Looking for a more elaborate description of this example? Please visit: https://embeddedproto.com/a-simple-uart-example-with-embedded-proto/

Introduction

This repository hosts example code for Embedded Proto, the embedded implementation of Google Protocol Buffers. It is a simple example showing how a micro controller and desktop pc can communicate over UART. Command messages are send from a desktop script over an UART comport to the MCU.

alt text

This example mimics a fun fair game. Move the claw around and see if you can catch the price!

alt text

This example makes use of a NUCLEO-F446RE board made by ST Microelectronics. This board holds an ARM Cortex-M4. To build the source code and program the hardware STM32CubeIDE has been used.

The desktop program is a simple terminal python script. You can use the keys as stated when you start the application to move around and grab your price.

Installation

  1. Install STM32CubeIDE if you have not already.
  2. Install the dependencies required by Embedded Proto. They are listed here.
  3. Checkout this example repository including the submodule of Embedded Proto: git clone --recursive https://github.com/Embedded-AMS/EmbeddedProto_Example_STM32_UART.git.
  4. Setup the environment required for Embedded Proto and the desktop script by running the setup script: python setup.py.

The setup script already does it for you but you can regenerate the source code using the python setup.py --generate parameter. This is required when you have changed the *.proto file.

Running the code

Connect the NUCLEO via the usb programmer and use STM32CubeIDE to build and program the micro controller on it. Next find out which comport has been allocated for the NUCLEO. In the example code below it was ttyACM0. Next go to the desktop folder, activate the virtual environment and run the script.

On Linux:

cd desktop
source venv/bin/activate
python3 main.py --com /dev/ttyACM0

On Windows PowerShell:

cd desktop
.\venv\Script\Activate.ps1
python main.py --com COM1

Have fun!

About

Connecting a micro controller with a PC is simple when using google protocol buffers. This example shows you how you could communicate over UART in a structured manner. Embedded Proto is used to generate the embedded code while regular protoc code is used for the python desktop script. Commands are send from the PC to the micro controller. The c…

Topics

Resources

Stars

Watchers

Forks

Languages