Python Serial Communication — ELI5
Remember passing notes in class? You write a message on a piece of paper, fold it up, and hand it to the person next to you. They unfold it, read it, write a reply, fold it back up, and pass it back. One note at a time, back and forth.
Serial communication is how your computer passes notes to gadgets like Arduino boards, GPS receivers, barcode scanners, and 3D printers. Instead of paper, the notes travel through a USB cable. Instead of words, the messages are streams of letters and numbers sent one character at a time — that is why it is called “serial,” because everything goes in a series, one after another.
When you plug an Arduino into your computer with a USB cable, the computer creates a little mailbox for it. On Windows, the mailbox has a name like COM3. On Mac and Linux, it looks like /dev/ttyUSB0. Python can open that mailbox and start passing notes.
Your Python code writes “turn on the LED” to the mailbox. The Arduino reads it and flips the switch. The Arduino writes back “LED is on.” Your Python code reads the reply. That is the entire conversation.
The speed of the note-passing is called the baud rate. Both sides need to agree on the speed — if your computer sends notes at 9600 words per minute but the Arduino is listening at 115200 words per minute, neither side can read the other’s messages. It is like trying to have a conversation where one person whispers and the other shouts.
One thing to remember: Serial communication is the simplest way for Python to talk to hardware gadgets — send text through a cable, one character at a time, and listen for a reply.
See Also
- Python Behavior Trees Robotics How robots make decisions using a tree-shaped rulebook that keeps them organized, like a flowchart that tells a robot what to do in every situation.
- Python Bluetooth Ble How Python connects to fitness trackers, smart locks, and wireless sensors using the invisible radio signals all around you.
- Python Circuitpython Hardware Why CircuitPython makes wiring up LEDs, sensors, and motors as easy as plugging in a USB drive.
- Python Computer Vision Autonomous How self-driving cars use cameras and Python to see the road, spot pedestrians, read signs, and understand traffic — like giving a car human eyes and a brain.
- Python Home Assistant Automation How Python turns your home into a smart home that reacts to you automatically, like a helpful invisible butler.