Python for Lab Automation and Instrument Control

Python for the lab: guides to control instruments (DAQ cards, Arduino, cameras), acquire data with threads, store it in HDF5, and build lab software.

Python is an excellent language for automating experiments. It talks to almost any instrument, it has the best tools for analysing data, and you can grow a quick script into a reliable program for the whole lab. This page collects every guide on Python for the Lab, ordered roughly in the way a lab project develops: from talking to a device, to acquiring data without blocking, to storing it, to sharing the code with colleagues.

If you prefer to follow a single, complete project from start to finish, that is what the Python for the Lab book covers. For research groups, there are also hands-on workshops.

Controlling instruments with Python

Most lab devices communicate through a serial port, USB, or the network. Once you understand the pattern (send a command, read the answer, convert it to useful units), every new device becomes easier.

Acquiring data without blocking: threads, processes and messaging

An experiment often needs to do several things at once: acquire, display, and save. These articles show how to do it without freezing the program.

Building a user interface

Storing experimental data

Turning scripts into lab software

Code that controls an experiment lives for years and is used by people who did not write it. These guides help you organize it.

Learn it all in one project

The Python for the Lab book follows a single project from the first command sent to a device to a complete program with a user interface, written with the best practices discussed above. The workshops cover the same material in three days, on site, for research groups and companies.