ESP32 Bit Pirate home
  • Python
  • Intermediate
  • 10 min
  • Python

Recipe · Intermediate · Python

How to automate hardware checks from Python

Use serial automation from a Python script when a CLI workflow becomes repetitive or needs to run from a computer.

Terminal shell showing a command prompt.
Python is useful once a command sequence is stable enough to automate.
Step 1

Commands

Run the automation script on the computer. The script opens the ESP32 Bit Pirate serial port, sends normal CLI commands such as help, then reads the replies.

Result

What it means

A host script can drive the same serial CLI you tested manually, which is useful for repeated scans, test fixtures and logging.

Troubleshooting

  • Close Web Serial or PuTTY before opening the port from Python.
  • Use the same baud rate as the CLI.
  • Add timeouts and log raw replies when parsing.

Next steps

  • Try the same workflow on a known safe pin or target.
  • Save the useful command as a note or alias.
  • Move to the protocol-specific recipe once the basics work.

Python serial automation FAQ

When is desktop Python better than aliases or repeat?

Use Python when you need loops with decisions, logging to files, parsing responses, timeouts or test reports. Use aliases and repeat for simple command shortcuts inside the firmware.

What does the BitPirate class handle?

It abstracts the serial connection and exposes helpers such as auto_connect, start, change_mode, send, wait, receive and receive_all for scripts.

How should I make automation reliable?

Start each script by clearing the session, selecting the expected mode, using explicit timeouts, and saving raw output before adding complex parsing.

Go deeper