
Digital Twin
The digital twin's purpose is to simulate and predict plant growth based on data taken from the real system. To do this, we will implement environmental sensors and a depth camera that communicate with the FarmBot through ROS2.
01
Install Ubuntu 22.04
To run ROS2, you will need a PC running on the operating system Ubuntu version 22.04. Ubuntu 22.04 is an operating system based on Linux, which is an alternative to common operating systems such as Windows or iOS.
​
To set a PC up with Ubuntu 22.04, you will need a cleared PC and USB drive (any data on either will be deleted!). Since we are using our PC solely for our FarmBot, we used a BeeLink Mini-PC Mini S. [ADD LINK] Any empty USB will work the same, but it must have a capacity of at least 8 GB.​
​

​A tutorial on how to set up a Mini-PC with Ubuntu is here: installing Ubuntu on Beelink Mini PC. This process should be the same if starting out with Windows on your PC. For other initial operating systems, the only difference would be using
instead of Rufus to create the bootable USB drive.
02
Python Packages

The PC with Ubuntu 22.04 should automatically have Python version 3.10.12 installed. Follow these steps to install the necessary Python packages for I2GROW:
​
​Open the terminal: Ctrl+Alt+T
The terminal is your control center on Ubuntu. You will use the terminal to install software, download files, and run code. To send commands through the terminal, type them after the colored prompt that should have your PC's name in it and click enter. Allow a few seconds after each line to ensure your commend runs properly.
​
To check what python version you have installed, in the terminal, type​
python3 --version
The terminal should return the following: Python 3.10.12
​
To ensure you have pip for python3, which is the package installer, type
sudo apt update
sudo apt install python3-pip
​
Then confirm
pip3 --version
​
And upgrade
python3 -m pip install --upgrade pip setuptools
Finally, to install the required packages,
pip3 install -r requirements.txt​​
03
Install ROS2

To install ROS2 with the required packages, you will learn to use GitHub, which is a popular platform for creating and sharing open-source code. The following GitHub repository has all the required steps that are specific to this project. Scroll past the files to where it says README and follow the steps in sections 1 and 2.
​
Project I2GROW Repository: https://github.com/maybornegit/ros_farmbot
​
04
Cameras & Sensors


WEBCAM
The webcam provides an overview of your hydroponic plants as a live video on the graphical user interface.
​
Models:
Any basic webcam will work.
​
Testing:
To test your webcam on its own first, connect it via USB to your PC and, in the terminal, run
sudo apt update
sudo apt install v4l-utils cheese
This will install the viewer for your webcam.
Then, check if your system detects the webcam by running
v4l2-ctl --list-devices
The list should contain your webcam with its associated video device (like /dev/video0 or /dev/v4l/by-id/...)
Now, you can open a video stream for your device by typing
cheese
​
Configure:
To connect the webcam to our ROS2 system, find the video device path by typing
ls -l /dev/v4l/by-id
The output should be something like this:
usb-046d_Logitech_Webcam_C270_ABCDEFG-video-index0 -> ../../video0
which tells you your webcam's ID.
​
Now, in the config file, on line [LINE], add your webcam path, which will look something like this:
/dev/v4l/by-id/usb-046d_Logitech_Webcam_C270_ABCDEFG-video-index0
​
​
​
ARANET SENSOR
The Aranet sensor measures environmental conditions such as CO2 concentration, temperature, relative humidity, and atmospheric pressure. This data can be used to explain trends in the plant's growth over time.
​
Models:
Aranet4 Air Quality Monitor
​
Configure:
When you first aquire your sensor, download the Aranet Home App on a mobile device and follow these steps to initialize the sensor:
​
​
To connect the sensor to our system, first, we need to manually install Intel Bluetooth firmware. To do this, run
cd /lib/firmware/intel
sudo wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/intel/ibt-0040-1050.ddc
in the terminal.
Then, reboot your system:
sudo reboot
In the terminal, type
bluetoothctl
to enter the bluetooth control interface. The prompt will change to something like: [bluetooth]#
​
To ensure that bluetooth is on, type
power on
​
To scan for nearby devices, run
scan on
The output will list all devices nearby and look something like this:
[NEW] Device DB:96:37:12:34:56 Aranet4 123456
[NEW] Device XX:XX:XX:XX:XX:XX Some Other Device
You're looking for a device whose MAC address starts with DB:96:37, which is the Organizationally Unique Identifier (OUI) for Aranet4 devices.
​
Once you have found the MAC address, type
scan off
and then
exit
to exit the bluetooth control terminal.
​
To the configuration file, add the entire MAC address (something like DB:96:37:12:34:56) to line [LINE].
​
​
​​
​​
INTEL REALSENSE DEPTH CAMERA
​The depth camera is able to capture 3D image data of the plants for the system to make accurate weight estimates.
​
Models:
Any Intel RealSense Depth Camera will work.
​
Testing:
To open RealSense's software, first, we need to add the official Realsense APT repo:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6B0FC61
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo jammy main"
sudo apt update
Then, install the SDK and tools:
sudo apt install librealsense2-utils librealsense2-dev librealsense2-dkms
Now, with the camera plugged in to USB, you should be able to run
realsense-viewer
This will open the software. You can toggle between 2D and 3D to view what the camera sees on your screen.
​
Configuration:
Plug the camera into the PC via USB. The system will automatically recognize it. To attach the camera physically to the end of the robotic arm, you will need to print an adapter. For the model D455, which is what we used, you can 3D print this adapter directly. For other models, when their dimensions on RealSense's webpage and alter this adapter to fit your model.
​​​​
​
Adapter Model File:
​
​
​
​
​​
APOGEE PAR SENSOR
This sensor measures the light intensity at each plant
coordinate, which is used to predict growth over time.
​ Models:
The system uses this sensor. However, the light sensor is not required. If the lighting at your system is constant (for example grow lights instead of variable sunlight), you can use any basic light sensor to manually take data and record it in a text file for the program to access instead. Adding data to this file is detailed in the code tutorial video at the bottom of this page.
​
Configuration:
This sensor will be recognized automatically by the system if it is plugged in to the PC. If you do not have this sensor, as mentioned, you can manually hard code light intensity values in millimoles into the code as described in the video below.​
​
​
​​​​​
​
An Overview of the lines that need to be added to the configuration file to connect sensors, as well as edits that need to be made to the code to match your specific system are detailed in this video.
​
​
​
​
​
​
​
​
​
​
​
​
​
The steps are also listed in the GitHub repository for i2grow: https://github.com/maybornegit/ros_farmbot
​
If you have slightly different models for the sensors and cameras, no worries! The guide is general to a wide range of similar models. GitHub also has copilot integrated, which can help you ensure that you are taking the right steps for your specific components. Look for the Copilot AI icon in the top right corner and be as specific as possible with your prompts.

