Executes g-code like commands over a serial line to move the FarmBot and operate its peripherals. GitHub repository.
The firmware runs on an Arduino microcontroller and is written in C++. The firmware is usually flashed to the Arduino via FarmBot OS.
Internally used commands
The commands and responses on this page are used for communication between FarmBot OS and the FarmBot Arduino Firmware. Outside of that internal communication, commands on this page can only be sent by disconnecting the Arduino from the Raspberry Pi and connecting a USB cable from a computer directly to the Arduino.
FarmBot OS communication via Farmware and the Message Broker consists of higher-level CeleryScript commands, not the commands listed on this page.
Commands are sent to the Arduino using the command code and number, any arguments (separated by spaces), and a CR/NL (
For example, to set parameter number
1, you would send
F22 P101 V1\r\n, where
F22 is the write parameter command,
P101 is the parameter argument,
V1 is the value argument, and
\r\n is the CR/NL.
For this example, the firmware will respond with (comments excluded):
R08 *F22 P101 V1* // the command received (echo) R01 Q0 // command started R21 P101 V1 Q0 // report parameter 101 value: 1 R02 Q0 // command finished successfully
Q at the end of the responses designates the command queue number.
Q + a number can be appended to any command sent and the responses will include the same
Q number provided.
Commands that can be sent begin with
F. Responses and status reports received from the Arduino begin with
|General command responses|
|R03||Finished with error|
|Idle and status responses||Description|
|R88||Config not approved (use
|F09||Reset emergency stop (unlock)|
|R81: report endstops||XA: end stop 1 (0/1)
XB: end stop 2 (0/1)
|YA: end stop 1 (0/1)
YB: end stop 2 (0/1)
|ZA: end stop 1 (0/1)
ZB: end stop 2 (0/1)
|R82: current position (mm)||X||Y||Z|
|R84: encoder position (mm)||X||Y||Z|
|R85: encoder position (edges)||X||Y||Z|
|R05: axis state||X0: idle
X1: starting motor
X5: stopping motor
Y1: starting motor
Y5: stopping motor
Z1: starting motor
Z5: stopping motor
|G00: Move to location||X||Y||Z|
default: max speed
// Move to (0, 0, 0) at normal speed G0 // Move to (100, 200, 300) at normal speed G00 X100 Y200 Z300 // Move to (100, 200, 300) at specified axis speeds G00 X100 Y200 Z300 A400 B500 Z600
|G28||Move each axis to home (zero) in order: Z, Y, X|
Finds zero for an axis. Requires the use of encoders or end-stops. For more information, see Calibration and Homing.
|Find home (zero)||X||Y||Z|
|Response: Homing complete||R11||R12||R13|
Measures an axis length and then finds zero for that axis. Requires the use of encoders or end-stops. For more information, see Calibration and Homing.
Sets zero for an axis. For more information, see Calibration and Homing.
|F84||X1: set to zero
X0: don’t set to zero
|Y1: set to zero
Y0: don’t set to zero
|Z1: set to zero
Z0: don’t set to zero
|Write pin||F41||P||V (0-1 digital, 0-255 analog)||
|Set pin input/output mode||F43||P||
|Set servo angle
(only pins 4, 5, 6, and 11)
|Response (report pin value)||R41||P||V (0-1 digital, 0-1023 analog)|
For Arduino and Farmduino board pin assignments, see src/pins.h.