Skip to main content
Torqheart
← Foundations

Programming

Sending commands over serial

Serial sends data one bit at a time at an agreed speed (the baud rate). Every byte carries a start and a stop bit, so a longer message costs time by a simple formula.

See it first

Try it

Send time against message length

05101550100150200Message length (byte)ms
t = bytes × 10 / baud
A 20-byte command
1.74 ms
Twice the bytes, twice the time. Raise the baud and the line flattens.

One step at a time

Step by step

Sending commands over serial

Step 1 of 5

Agree on a speed

Both sides set the same baud, or they read garbage.

In words

At 115200 baud, 8N1, each byte takes 10 bits: about 11,520 bytes a second. A 20-byte command takes about 1.7 ms.

Text commands are easy to read and debug, but longer. Work that must be fast usually switches to shorter binary messages, with a checksum to catch corruption.

The formula

t = bytes × 10 / baud

Where you meet this in a robot

In the ESP32 workshop the firmware is flashed once; after that, code or Blockly on the web sends commands and parameters to the board over serial.