Introduction
This experiment is about controlling something bigger than the chip itself can safely handle directly. We'll wire up a relay module and switch it on or off using the exact same UART menu style we built back in Experiment 2, type 1, the relay clicks on; type 2, it clicks off. It's a small demo, but the underlying idea (a tiny microcontroller safely controlling something much more powerful) is exactly how a car's ECU switches on a fuel pump or how a smart-home hub turns on a light socket.
2. Scope
We'll look at why relays exist in the first place, wire up a GPIO pin to control one, and reuse the print_str()/read_line() helper functions from Experiment 2 rather than rebuilding them from scratch, which is a nice little lesson in itself: once you've built a solid piece of reusable code, you don't need to reinvent it every time.
3. Prerequisite
3.1 Hardware
-
STM32 Nucleo-F070RB development board
-
A 5V single-channel relay module
-
Breadboard and jumper wires
-
Micro-USB cable
-
PC with PuTTY
3.2 Software
-
STM32CubeMX (standalone)
-
STM32CubeIDE
-
ST-LINK USB driver
-
PuTTY, or an equivalent serial terminal app
Community Q&A
0 questionsAsk questions and get answers from our community and staff moderators.
No questions yet — be the first to start the conversation!
Ask a Question
Please log in to ask a question or post a reply.
Login to Participate