Sequences
Drag-and-drop programming for your FarmBot my.farmbot.io/app/sequences
Sequence building
The web app is a platform designed to give you unlimited control over how you use your FarmBot and therefore how you grow your food. Because nobody wants to sit on their computer all day controlling their FarmBot manually, we have designed several features to help you automate your farming operation.
The sequence builder allows you to combine the most basic operations of FarmBot into more complex actions composed of many different steps. When a sequence is initiated, FarmBot will execute all of the steps in the sequence one after the other until it is done.
Sequence commands (aka ‘steps’)
These are the basic operations we can use in sequences that FarmBot can execute:
- Move Absolute - Moves the device to an absolute coordinate position at any speed. This is useful for moving to tool, plant, and home locations.
- Move Relative - Moves the device a specific distance in any direction at any speed, relative from the last position. This is useful for movements after a absolute movement to a dynamically loaded location. Eg: Moving in a square relative to a plant after the device moved absolutely to the plant.
- Write Pin - Writes a value to any pin on the Arduino. This is used for operating tools that use peripherals, such as the vacuum pump and water valve.
- Read Pin - Reads the value from any pin on the Arduino. This is used for tool verification and sensors.
- Wait - Causes a delay before executing the next operation in the sequence. This could be used to water for a certain amount of time.
can be used as a variable for FarmBot's current x axis position (`y` and `z` can also be used).
can be used to write the current value of pin 13 (pins 0 through 69 can also be used).
- Sends a message to the web app. This is useful for error and success notifications and debugging. - Find Home - Perform a homing operation to set zero for one axis or all axes.
- If Statement - Executes another sequence if a condition is true. This is useful for error detection and smarter, condition based farming.
- Execute Sequence - Use existing sequences as steps in a new, larger sequence. This technique allows you to re-use smaller sequences in different combinations to create far more complex sequences that are easier to modify, manage, and mashup. You can then use the individual sequences in other ways without having to recreate them each time.
- Run Farmware - Run the
plant-detection
farmware. Support for other farmwares coming soon. - Take Photo - Takes a picture with a USB webcam or the Raspberry Pi camera (select your camera in the Device widget) and sends it to the web app.
While using the web app, hover over the ?
icon in a sequence step to view usage information.
Building a sequence
The general overview of creating a sequence is:
- In the Sequences panel, click
- In the Sequence Editor panel, enter a name for your sequence and assign it a color
- Drag and drop blocks from the Commands panel into the Sequence Editor panel
- For each operation, enter in your desired parameter values. Some parameters such as speed can use default values for your device and do not need to be entered in every time.
- Reorder, copy, and delete operations as needed
- Click
In the next sections, several sequences are built as examples.
Create a tool mounting sequence
Let’s create a sequence to mount the watering nozzle as an example.
First, add the watering tool to the toolbay and follow the Tools instructions to add it to the web app.
Navigate to the Sequences page of the web app, and press the
button in the right column to add a new sequence.You will see the new sequence appear in the sequence editor in the middle column.
Give the sequence a descriptive name.
Begin the sequence with a movement to home. Add a Move Absolute step by clicking Move Absolute in the commands (left) column. You may also click and drag the command into your sequence.
Next, add a step to move above the tool we want mounted, in this case, the watering nozzle. Add another Move Absolute command as we did in the last step, or press the copy icon () in the existing step (second icon from the right in the step’s info bar).
Select the Watering Nozzle
(added in the tools page) in the Import Coordinates From
dropdown.
We want to move to the location directly above the tool before descending down to connect to the tool, so we’ll add a 100
mm Z-Offset.
Next we’ll want FarmBot to descend directly down to make contact with the tool. Add another Move Absolute
command and select the Watering Nozzle
in the Import Coordinates From
dropdown as before. This time, there will not be an offset.
At this point, FarmBot’s UTM would be attached to the tool in the toolbay. The next step will be to pull the tool out of the toolbay. Add another Move Absolute command and select the Watering Nozzle
as the coordinates, this time adding a 100
mm X-Offset.
That’s it! Now press the
button.To recap, the steps are move to home, move directly above the tool, descend directly down to make contact with the tool, and move the tool out of the toolbay. Now you can use this sequence any time you would like to use the watering tool!
Don’t forget to
before pressing to test your new sequence!Your turn
Now that you’ve created a tool mounting sequence, try creating a sequence to return the tool to the toolbay.
Create a watering sequence
Now that we’ve created a sequence to mount the watering tool, we can create a sequence to use the tool. As an example, we have a Spinach plant at coordinates (100, 200, -600)
that we would like to water.
- Mount the Watering Tool - Mount the watering nozzle by using the Execute Sequence step and selecting the
Mount Watering Tool
sequence created in the previous section. - Move to 100mm above the Spinach plant - Move the watering nozzle above the plant to be watered (
(100, 200, -600)
in this example) by making use of the Z-Offset input in the Move Absolute step. - Open the solenoid valve to start the flow of water - Add a Write Pin step to write
Pin 10
with a value of1
(The pin number should correspond to the pin you have attached the solenoid valve to on the RAMPS board. See the peripherals widget instructions in order to test valve operation.) - Wait - Use the Wait step to continue watering the Spinach plant for 4000 milliseconds (4 seconds).
- Cose the solenoid valve - Use another Write Pin step to write
Pin 10
with a value of0
, turning off the flow of water.
Press the
button and then at the top of the page to sync your new sequence with the device, and press to try out your new sequence!Alternative watering sequence methods
The watering steps in the sequence shown above can be made into their own sequence, which increases re-usability and makes it easier to make changes to the watering action.
Then, the new water dispensing sequence can be added by using an Execute Sequence step after movement to each plant location.
As you can see in this sequence, we have imported coordinates from plant locations in the Move Absolute step. These plant locations are defined in the Farm Designer.
As always, don’t forget to
and before pressing to test the sequence!