eGreenhouse: Robotically positioned, low-cost, open-source CO2 analyzer and sensor device for greenhouse applications

Graphical abstract


Hardware in context
The spatial and temporal distribution of CO 2 at the earth-atmosphere interface and at the boundary layer above it is of great importance for soil, agricultural and atmospheric sciences. In general, the source of elevated CO 2 concentrations at this boundary layer depends mostly upon root respiration and soil microbial activity [2][3][4] and on atmospheric transport (diffusion, dispersion, and advection) [5][6][7][8].
Improvement of CO 2 gas concentration detection could lead to better understanding of agricultural productivity and the transport mechanisms at this critical interface. Accurate monitoring of CO 2 can improve modeling and decision-making to enhance agricultural productivity [9]. Until recently, detecting CO 2 only employed stationary sensors providing low spatial resolution [10].
The growing use of open-source hardware for research purposes creates new opportunities to bridge the gap between CO 2 detection at high resolution and affordability. In agriculture, the use of open-source hardware and sensors for CO 2 gas sensing is scarce. However, recent research has revealed the possible applications of operating such gas sensing systems for agricultural purposes. For example, the use of an open-source gas sensing device to detect CO 2 concentrations in a rectangular greenhouse (106 m Â 47 m) was proven by Roldán et al. [11]. Using a low-cost electrochemical CO 2 sensor, which is a relatively low-accuracy analog sensor, they provided a CO 2 concentration map inside a greenhouse. Their device also had temperature, relative humidity and luminosity sensors. Data from these sensors can be used for better greenhouse operation decision-making.
The aim of this work was to develop the eGreenhouse, a suite of sensors to evaluate CO 2 concentrations and dynamics using an advanced non-dispersive infrared (NDIR) CO 2 sensor inside a greenhouse. NDIR sensors are based on absorption spectroscopy and consist of a light source, a sample cavity and a detector [12]. We integrated this gas sensor together with temperature, relative humidity, and luminosity sensors, on a single logging device to gain high spatial and temporal resolution of the greenhouse environment. In addition, the device is small and transportable to allow deployment on a drone or a rail system to get location-tagged data throughout the greenhouse. The latter option was used to validate system performance.

Hardware description
The sensors used in this work are detailed in the next sections. First, the sections describe the sensors, then their integration on a single PCB, and finally operational instructions (software and data access). All sensors were chosen to: (1) provide accuracy similar to that of a laboratory sensor; (2) employ only off-the-shelf, open source sensors; (3) be low-cost compared to existing sensors; and (4) result in a lightweight system. All enclosures and fixtures were designed as 3D printable to allow broadly accessible replication.
A linear-motion actuator (HyperRail) positioned the sensor system [1]. The eGreenhouse includes two main components, the sensor package which is mounted on the HyperRail and the static hub from which the user can control the HyperRail and upload the data online (e.g., GoogleSheets) The eGreenhouse can also be used in the following settings: Mounted on a drone for large area measurements (not necessarily within greenhouses). Static measurements within caves, boreholes or underground cavities in which CO 2 concentration regimes are of interest, e.g. [13][14][15][16].
Adjacent to an open-source wind anemometer for a simple but efficient meteorological station with CO 2 readings We note that the validation data presented in section 7 was obtained using an earlier model due to specific site requirements at which the validation was done (see more information in section 7). Below we present the hardware design that is similarly configured (e.g., K30 for CO 2 and SHT31-D for temperature and relative humidity), but with some minor improvements (re-designed data logger board).

Build instructions
Here we provide building instructions for each individual part and then demonstrate prototype wiring using the Sensor PCB. Additional information, instructions and updates, such as the PCB design and connections can be found at https:// github.com/OPEnSLab-OSU/eGreenHouse/wiki (eGreenhouse tab)

eGreenhouse sensor package individual hardware components setup
All steps in this section require a soldering iron and solder. Follow typical safety protocols for soldering to prevent burns and inhalation of lead solder or flux/rosin solder: eye protection, heat resistant work surface, clamps to hold materials to be soldered, ventilation, etc.

Development board
In this step, you need the Antenna Connector, Antenna Kit, development board, and 12-pin + 16-pin male headers that came with the development board (Fig. 1).
First, solder the Antenna Connector in the designated location on the board. Fig. 2 with a yellow arrow will tell where to solder the Antenna Connector and Fig. 3 shows the soldered Antenna Connector.
Once that step is complete, solder 12-pin + 16-pin male headers (Fig. 4). Make sure that the long side of the male headers are facing down while the short side of the male headers go through the board towards the top.
Connect the Antenna Kit, except the actual plastic antenna, on the Antenna Connector. Because it is easy for the Antenna Kit to be disconnected from the Antenna Connector, secure (strain relief) the wire for the Antenna Kit to the Development Board with either electrical tape or hot glue so that it will stay in position (Fig. 5).

Data logger with RTC board
As shown from the bill of materials, there is an option to use either a RTC Adalogger from Adafruit or the OPEnS Data Logger with RTC Board that was created from OPEnS Lab. We will be using the Hypnos board rather than Adalogger. If you are going to use the Hypnos board, then reference here.
For this step, you will need the Hypnos board, 12-pin + 16-pin male headers, 12-pin + 16-pin female headers, coin cell battery, and Micro SD card (Fig. 6). If you are planning to use Adalogger Adafruit as Data Logger with RTC Board, then you need Adalogger board, 12-pin + 16-pin stacking headers, coin cell battery, and Micro SD Card.
Solder the female headers on the top of the board (side with microSD slot) where it has a label of ''feather" (Fig. 7). Once female headers are soldered, then solder the male headers such that the long male headers are facing out on the bottom (side with coin cell battery holder) (Figs. 8 and 9).

CO 2 sensor
For this step, you need the K30 CO 2 Sensor and 4-pin male headers (Fig. 10). The 4-pin male headers can be created by breaking the 12-pin male header into a 4-pin male header.
Solder the 4-pin male headers on the four black dots shown by the red arrows in Fig. 11. The soldered CO 2 Sensor is shown in Figs. 12 and 13.

PowerBoost hardware
For this step, you need the PowerBoost without the USB Type-A adapter and 8-pin male headers (Fig. 14). The USB Type-A adapter will not be used in this project. The 8-pin male headers are the remaining male-pins after using the 4-pin male headers from the CO 2 Sensor.
Solder the 8-pin male headers such that the long pin will be projecting out of the bottom of the board (Fig. 15).

Lux sensor
For this step, you need Lux Sensor and 6-pin male headers (Fig. 16). You can create the 6-pin male headers from the 16pin male headers by breaking it to 6-pin male headers.
Solder the 6-pin male headers onto the PowerBoost such that the long side of the headers are on the bottom of the board (Fig. 17).

Temperature and relative humidity sensor
For this step, you need the Temperature and Relative Humidity Sensor and 7-pin male headers (Fig. 18). You can create the 7-pin male headers from the 16-pin male headers that was used for setting up the Lux Sensor by breaking it to 7-pin male headers.    Solder the 7-pin male headers onto the Temperature and Relative Humidity Sensor such that the long side of the headers are on the bottom of the board (Fig. 19).
Once this step is complete, then you are done with eGreenhouse sensor package individual hardware setup step. The next step is the assembly of the sub-systems.

eGreenhouse Sensor package connection setup
Steps in this section require a soldering iron and solder.  Once they are connected, then move to the next step. However, for the next few steps, you can disconnect them for convenience.

Connect Data Logger with RTC Board to the PCB
For this step, you need the PCB and Data Logger with RTC Board and the PCB. Fig. 22 shows the PCB front view. Make sure the PCB is facing forward.
Solder the Data Logger to RTC Board where it says ''Adafruit Feather" on the PCB such that the long male headers are facing downward. Make sure the 12-pin male headers follows the 12-pin holes, the 16-pin male headers, and 16-pin holes.   12-pin and 16-pin female headers can be soldered onto the Sensor PCB to allow future removal of the Data Logger with RTC Board unless there is a height restriction.

Connect CO 2 Sensor to the Sensor PCB
For this step, you need the Sensor PCB and CO 2 Sensor. Solder the CO 2 Sensor where it is labeled as ''K30." Make sure to match the pin labels between the CO 2 Sensor and Sensor PCB: G0 pin will be connected to GND on the PCB, G + to 5 V, RXD to RXD, and TXD to TXD. Figs. 31 and 32 show the top and bottom view after CO 2 Sensor to the Sensor PCB.
Once that step is complete, you are done with the eGreenhouse Sensor Package Setup step. For verification, connect the battery to the Development Board as shown in Fig. 33. If it lights up for both the Data Logger with the RTC Board and the Development Board, and flashing for the CO 2 Sensor, then everything is working perfectly.

Hub hardware setup
All steps in this section require a soldering iron and solder.

Development Board
In this step, you need the Antenna Connector, Antenna Kit, Development Board, and 12-pin + 16-pin female headers (Fig. 34).
First solder 12-pin + 16-pin female headers to the Development Board such that the socket side is on the top of the board (Figs. 35 and 36).
Once that step is complete, then solder the Antenna Connector to the bottom side of the Development Board (Fig. 37). Once that step is complete, then connect the Antenna Kit, except the actual plastic antenna, on the Antenna Connector. Because it is easy to be disconnect, either add electrical tape or hot glue so that it will be in position (Fig. 38).                    (Fig. 41).
Once that is done, you are completely done with the Build Instructions.     Fig. 42 for location of the option.
Once you select Add Library, you will get a pop shown in Fig. 43. From the menus on the top left of the window, search both Control5P and Arduino (Firmate) and install both.   In the Code folder, which is under the Design folder, you can find a folder named Dependencies. In that folder, copy the AccelStepper folder and paste it in Document -> Arduino -> libraries such as Fig. 44. Each system setup might vary the location of the folder; therefore, please check where the Arduino -> libraries is located.
Once you complete this setup, then you are set up with the Arduino IDE software. Note: when you open the Arduino IDE, you will get the following message in Fig. 45. You can simply ignore that.

eGreenhouse Sensor package
There are two different versions of eGH_Sensor_Package code to use. If you are using Adalogger from Adafruit as the Data Logger with the RTC Board, then open the folder called Non Hypnos eGH_Sensor_Package.
If you follow the build instructions using the OPEnS Data Logger with RTC Board, then open the folder called Hypnos eGH_Sensor_Package.
In the code folder, go to Hypnos eGH_Sensor_Package folder. Then inside that folder there will be another folder called eGH_Sensor_Package. In that folder, open eGH_Sensor_Package.ino file, and you will see code as in Fig. 46.
In that screen, select Tools -> Board -> Loom SAMD Boards -> Loomified Feather M0 (Fig. 47) [10,false]. The 10 is indicating the time zone, which it is currently set up as PDT. You can change the time zone by referring here. For example, if you are in Eastern Standard Time, it will be 5 rather than 10, which will be [5,false].
Once you change the config.h file, then click upload using the arrow pointing to the right (Fig. 49). Wait until it gets the message shown in Fig. 50. Once the message appears as ''CPU Reset", then it has uploaded properly, and is ready to use.

Before for setting up the Hub
For this step, you will need Ethernet cable that must be connected to an open Ethernet port. At the same time, you will need your own Mac Address. Make sure the Mac Address is in decimal (not hexadecimal).

GoogleSheets setup
First, create a new GoogleSheets in either your personal drive or an organization drive. Once it is created, go to Tools -> Script editor (Fig. 51). Once you select Script editor, then you will get a new tab (Fig. 52).
Inside the Code file, go to the folder called GoogleSheets. Inside, you will have Spreadsheet.gs. Open that file with any text editor or simply notepad (Fig. 53) In this file, copy everything and paste that in the Script editor. Before you paste it to the Script editor, make sure it is empty (Fig. 54).
Once you save it, you will get this pop up (Fig. 55). You can name the project as you prefer. Once that is complete, then go to Publish -> Deploy as web app. . . (Fig. 56).
In there, change the option Who has access to the app from Only myself to Anyone, even anonymous. (Fig. 57). Once you change the option, then select the blue button Deploy. There will be some permission review when you select that option. Make sure you authorize with your google account.
Then you will get a pop up that is like Fig. 58. Copy the URL that is provided in the pop up and save on notepad. Once you save it in a separate location, then you can close the Script editor. Going back to your GoogleSheets, there is an URL for that GoogleSheets. Copy that and save it in the same location where you save your other URL. But make sure which one is which. These URLs will be used for the next step. For example, this will be what will look in your notepad after saving both URLs. (Fig. 59).

Upload to Hub code on device
Within the main project folder, open the Hub folder. In that folder, only open Hub.ino. Once you open it, you will get the screen in Fig. 60.
If you have previously selected the board, it should set as default. If not, then change the board to Loomified Feather M0 like Fig. 47.   Once that is complete, then connect the Hub to the computer with Micro USB Cable. It should recognize the board. Then go to Tools -> Port and see if there an option to select. If there is no option, try either a different cable or reconnect it. It should be as in Fig. 61. Also, writing down the port number just for the Hub will be useful for later.
Once the computer recognizes the board, go to config.h file (Fig. 62).
You can see that there are some parts that are commented or in <> (e.g., Fig. 62, line 7). For the Mac address, enter them in decimal. For example, it will be formatted as [1,542,241,65,23] (Fig. 63, line 7). Note that this Mac address is a fake one.
For the < your-script-id>, it will be replaced with the URL from the Script editor. In this example, it will be AKfycbyRTgyVAms4SBZaVxhs-CpaaegEvKzoXVe5f25BmC24TOi22NGj           Last, <your-sheet-id > will be from the second URL, which it is from the Sheet. In this example, it will be 1d3rCuDdrkpgpAtmhliu1TahRSahZNXzFIIxbkoMGCuA (Fig. 63, line 8).
Once you make the changes in the config.h file, save it and click upload using the arrow pointing to the right (Fig. 64). Wait until it gets the message shown in Fig. 65. Once you get this message as ''CPU Reset", then it uploaded properly and is ready to use.   Once that is complete, then connect the Hyper to the computer with Micro USB Cable. It should recognize the board. Then go to Tools -> Port and see if there is an option to select (Fig. 67). If there is no option, try either a different cable or reconnect it.
Once the computer recognizes the board, then click upload using the arrow pointing to the right (Fig. 68). Wait until it gets the message shown in Fig. 69. Once you get this message as ''CPU Reset", then it has uploaded properly and is ready to use.

Loading firmware on microcontroller
In the design file, open the GUI folder. Inside that folder, only open the GUI.pde file (Fig. 70). In the code, change the port number for the Hub Board where it is written ''String port = ''COM5"". You just need to change the number (Fig. 71, line 38). We note that Mac ports show up as USBmodem#### instead of COM# (Windows).
Once that is set, connect the Hub board to the computer and click the green arrow button on the top left (Fig. 72). Then you will get this interface as shown Fig. 73.
In the application, you can move the position of the HyperRail, the velocity, the radius (not relevant in the eGreenhouse application), and the duration or number of loops. All the text inputs only take integers. As shown in the GUI, there is a timer for the CO 2 sensor warm up time. This timer is included because the CO 2 sensor needs at least 6 min warmup time to get accurate measurements. If the eGreenhouse sensor package was running for more than 6 min, this time can be ignored. On the bottom right, you can see the console log. If the user selects one of the four buttons, it will print out if it transmits  to the HyperRail board or not. If not, the failed transmission will be displayed. Once you have successful transmission, you are set to control the HyperRail and measure the eGreenhouse sensor package if both boards are on.

Validation and characterization
System validation was performed in a full-scale deployment of the eGreenhouse on a 25-meter HyperRail at the North Willamette Research and Extension Center, OR, USA (Fig. 74). The project was conducted in a 30 m (L) Â 3 m (W) Â 2. 5 m (H) naturally lit, steel framed hoop house (also known as a cold frame). The house was covered with polyethylene plastic, which was rated for 90% light transmissivity. The house was naturally ventilated by raising the plastic on the sidewalls 1 m on both sides of the 30 m length. Due to this specific site requirements, in this eGreenhouse setup we used  a nRF radio instead of the LoRa radio with all other key sensors being the same (K30 for CO 2 and SHT31-D for temperature and relative humidity). Data was sent via nRF across three nodes spanning over 25 m (0, 12.5, and 25 m). The HyperDrive hub [1] drove the sensor package along the rail and sent requests for specified sensors at any spatial interval. Upon receipt of these data, the hub sent the data bundles to a third node at the extension office (~100 m from the greenhouse) with ethernet connectivity. The data was uploaded to Google Sheets, in addition to the onboard SD card logging. Data from the eGreenhouse was compared to data from a nearby meteorological station located~200 m from the greenhouse. Data from six consecutive days are presented in Fig. 75. Temperature and relative humidity measured by the eGreenhouse followed the expected trend of higher temperature and lower relative humidity during daytime compared to nighttime (Fig. 75-a and b). Within the greenhouse, temperatures were higher by~20°C than the outside temperature during daytime due to the greenhouse effect. No significant spatial differences were found between the three nodes of 0, 12, and 25 m. During nighttime, temperature and relative humidity within the greenhouse were the same as atmospheric values.
CO 2 values ranged between~400 (atmospheric concentration) and~550 ppm, with higher values during nighttime (Fig. 75-c). This is expected because throughout the night the plants respire (CO 2 is emitted to the greenhouse atmosphere) and photosynthesis, the process by which plants use sunlight and CO 2 to synthesize food, is suppressed.  The light values within the greenhouse followed the daily solar cycle (Fig. 75-d). Lux values increased with sunrise until reaching sensor saturation each day around noontime and then decreasing after sunset to 0 lux. Light values showed higher spatial distribution than other tested parameters. This is demonstrated by the differences of lux values within the green-    house between 0, 12.5, and 25 m (Fig. 76). This is most likely due to changes in local shading at each node or as a result of the dynamic cloud movements. The only exception to the daily trend was in the last day (06/05/2019) where light values fluctuated throughout the day without reaching saturation. This day was the cloudiest day of the week, causing lower radiation as measured also by the temperature sensor ( Fig. 75-a). We note that additional settings and versions of the eGreenhouse are described in the OPEnS lab website (http://www.open-sensing.org/) and GitHub page (https://github.com/OPEnSLab-OSU/ eGreenhouse).

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.