Skip to content

Thermocycler G-Code Concepts

G-codes are machine-readable instructions used to control hardware. You do not need to understand or use G-codes to operate a Thermocycler with Flex or OT-2. This section is a technical resource for developers building custom applications that work with the Thermocycler.

G-Code command syntax

Thermocycler G-codes are strings starting with M followed by an integer. Arguments are formatted as letter-number combinations without separators. Each command must end with a new line character; Opentrons modules do not support multiple commands on a single line. For a complete list of codes and examples see Thermocycler Module G-Codes.

  • Syntax: MCOMMAND [ARGUMENT-KEY][ARGUMENT-VALUE] TERMINATOR
  • Examples: M115 \n or M104 S95 H120 \n

The following table explains these G-code command elements.

Element Description
MCOMMAND This is a G-code command itself. For example, sending a simple looking command like M115 \n to the Thermocycler returns its serial number, model, and firmware version.
ARGUMENT-KEY An optional key-value pair used to pass parameters to a command.

Typically, the key is a single, uppercase letter followed by its value (usually an integer). For example, sending M104 S95 H120 \n sets the Thermocycler temperature to 95 °C and holds it for 120 seconds. In this command:
  • S and H are the keys for "set temperature" and "hold time."
  • 95 and 120 are the values for °C and seconds.
TERMINATOR Every G-code sequence ends with a terminator, which is always a newline character (\n).

G-Code response syntax

Every Opentrons module returns a response after executing a command. A response will be one of the types defined below.

Response type Description
Acknowledgement An acknowledgement returns OK when the command is successful.

This response type does not echo the command code.
Response Some responses echo the command code and append OK to the response string when the command is successful. For example, successfully sending the command M119 (get the Thermocycler lid and seal motor status) would return M119 Lid: open Seal: retracted OK.

Other responses do not echo the command code and only return an acknowledgement (OK) or an error code.
Error An error indicates a command failed and does not echo the command code.

Error responses are strings formatted as ERRNNN:error, where N is an integer followed by a plain text description. For example, sending too many commands to a module too quickly might result in the response ERR004:G-code cache full.

See the Thermocycler Error Codes section for a complete list.

Connection parameters

To establish a serial USB connection, your application must specify the baud rate and identify the module using its Vendor ID (VID) and Product ID (PID).

  • Baud rate: Defines the communication speed for the module.
  • VID: Identifies the manufacturer of the integrated circuit running the module's firmware.
  • PID: Identifies the specific Thermocycler type based on its model generation.

The following table lists these required connection parameters.

Module Baud Rate VID PID
Thermocycler GEN1 115200 0x04D8 or
0x239a
0xED8C or
0x800b
Thermocycler GEN2 115200 0x0483 0xED8D

Making Good G-Code Connections

Identifying modules by their VID and PID helps you write resilient, cross-platform code. Hard coding for a specific port (e.g., COM3 for Windows or /dev/ttyUSB0 for macOS) makes code brittle. By using a library like pyserial to scan for specific VID/PID combinations, your application can dynamically find and connect to the correct Opentrons module regardless of its physical connection point.