GreenLab, an IoT-Based Small-Scale Smart Greenhouse

: In an era of connectivity, the Internet of Things introduces smart solutions for smart and sustainable agriculture, bringing alternatives to overcome the food crisis. Among these solutions, smart greenhouses support crop and vegetable agriculture regardless of season and cultivated area by carefully controlling and managing parameters like temperature, air and soil humidity, and light. Smart technologies have proven to be successful tools for increasing agricultural production at both the macro and micro levels, which is an important step in streamlining small-scale agriculture. This paper presents an experimental Internet of Things-based small-scale greenhouse prototype as a proof of concept for the benefits of merging smart sensing, connectivity, IoT, and mobile-based applications, for growing cultures. Our proposed solution is cost-friendly and includes a photovoltaic panel and a buffer battery for reducing energy consumption costs, while also assuring functionality during night and cloudy weather and a mobile application for easy data visualization and monitoring of the greenhouse.


Introduction
With the development of the Internet of Things (IoT), new emerging technologies become more accessible to developers providing, among others, solutions for smart and sustainable agriculture and bringing alternatives to global problems such as the food crisis.With the help of IoT, smart technologies and data analysis can be used to face challenges like climate change, poor soil, and lack of labor [1].
Water, energy, and food are resources that are inevitably connected.Climate often plays a decisive role in food production as well.A major impact on one resource implies major imbalances in the other two.Taking into account the fact that, for the normal development of the human body, an almost daily intake of fresh fruits and vegetables is necessary and taking into account the irregularity or blockage of imports, the problem of the lack of fresh fruits/vegetables, the problem of import substitution remains a pressing problem in many countries.
One solution, which is already successfully applied, is the creation of greenhouses and mini/micro greenhouses, which allow the cultivation of vegetables and fruits and thus eliminate expensive imports.Smart greenhouses allow farmers to grow desired crops with minimal human interference.Climatic conditions such as temperature, air humidity, brightness, and soil moisture are continuously monitored inside a mini-house with the help of a sensor system.Variations in indoor environment conditions automatically lead to their correction using heating/cooling, irrigation/drying, and lighting systems to maintain optimal conditions for plant growth.
The development of interconnected intelligent systems can generate opportunities to effectively address the challenges of food shortages and fluctuating supply chains.
Current research shows how IoT technologies are explored and used in smart greenhouses [1].The most notable research trends consist of network architectures [2,3], advanced controlling techniques [4,5], energy efficiency [6], interoperability [7], advanced techniques for data acquisition [8] and security challenges [9].In [8], the most notable technologies with the greatest potential were identified to include cloud, fog and edge computing, embedded systems, communications protocols like LoRa, ZigBee, GPRS, and different interfaces like API, H2M, and M2M.All of these are parts of modern IoT architecture.
Besides the advantages, the IoT-based solutions are still facing several challenges regarding the need of to standardize IoT infrastructure in the agricultural sector, technological challenges regarding connectivity in developing countries, and the need to align corporate farming practices with global patterns [8].
This paper presents an experimental Internet of Things-based small-scale greenhouse prototype as a proof of concept for the benefits of merging smart sensing, connectivity, IoT, and mobile-based applications, for growing cultures.Our proposed solution includes a photovoltaic panel and a buffer battery for reducing energy consumption costs, while also assuring functionality during night and cloudy weather, and a mobile application for easy data visualization and monitoring of the greenhouse.
This paper is structured in five sections.The first section, called the Introduction, describes the field of research and places our solution in the broad context of IoT-based greenhouses, continuing with the second section, Related Work, which describes the state of the art in this field.The proposed solution is described in the third section, called the GreenLab Project.Data readings are presented and discussed in the Results section.The paper ends by summarizing the main conclusions in a dedicated section.
The main contributions presented in this paper are as follows: • Design and implementation of smart IoT-based solution for a small-scale smart greenhouse; • Design, integration, and usage of a hybrid powering system consisting of a solar panel and a buffer battery; • Design and implementation of the software for different layers of the IoT architecture; • Design of an accessible usage and maintenance protocol; • Data gathering and analysis regarding the functionality of our proposed solution.

Related Work
With the appearance of the IoT concept, new smart sensing, controlling, and communication technologies have been immediately integrated into smart farming solutions.
An interesting smart greenhouse model at a small scale is presented in [10].During the study, the dependence of plant growth on the parameters of the micro-climate was determined.Plants are living organisms, for which, when building greenhouses, we must take into account the maintenance of their health and adaptability to external conditions.Optimizing the conditions for growing vegetable crops in the greenhouse's soil depends on the level of technical equipment that ensures operations such as heating, lighting, watering, feeding, and plant care [10].
Smart greenhouse environmental control systems using sensor networks are becoming more widespread and sophisticated.These systems collect data about the environment in which the plants are grown and how they grow in order to obtain the highest possible productivity and the best possible quality of vegetables and fruits.It is difficult for system users without farming experience to properly configure and control the parameters of multiple devices.In [11], an intelligent greenhouse environmental control system based on the algorithm "sliding window-based support vector regression" (SW-SVR) is described.The proposed system performs prediction control based on accurate predictions in realtime.SW-SVR is a new machine learning algorithm for time series data prediction.The automatic prediction model periodically adapts to the current environment, anticipating the evolution of data over time with high accuracy and low computational complexity [11].Using cloud services for agriculture reduces the burden of numerous devices to be installed in environments with high temperatures and increased humidity.Thus, the usage of integrated predictive analytics as a cloud service is an alternative for reducing the number of sensors while also providing parameter analysis and forecasting services [12].
Besides parameter monitoring and control, the use of Wireless Power Transmission (WPT) can solve a thorny problem in smart greenhouses, i.e., powering sensors located in different parts of the greenhouse, often hard to reach for classic wiring through wires for power supply.An interesting method is presented in [13].The monitoring area in a smart greenhouse is large, and a large number of sensor nodes are needed to form a complete and relevant monitoring network.Information such as temperature inside the greenhouse, air humidity, soil moisture, and also lighting can be collected through dedicated sensors for an automatic monitoring of all relevant parameters.In this context, the energy charging of sensors via wireless using mobile wireless charging devices is important for a smart greenhouse.This implicitly also leads to a reduction in the initial costs of the smart greenhouse and a reduction in the human resources specialized in the maintenance of the power systems.Another interesting model is presented in [14].To solve the problem of sensor charging, the authors propose the "enclose-loop" sensor using wireless power technology.The energy transfer efficiency for the magnetic resonance coupling method and its relationship with the transferred energy power are analyzed.Another paper proposes an innovative use of the uniform magnetic field in a large space to charge the sensors in the intelligent greenhouse wirelessly, leading to the avoidance of the disadvantages of cable charging [15].
A smart greenhouse needs a lot of energy to carry out all technological processes.A solution to reduce energy consumption from the grid is to install photovoltaic panels with additional capabilities to track the maximum power of the sun's rays so that as much solar energy as possible is taken for the operation of the mini-greenhouse.Photovoltaic systems can be classified into two categories: stand-alone systems and grid-connected systems.In autonomous systems, the solar energy produced is adjusted to the required energy.If the energy produced cannot meet the energy needs at a given time, an additional storage system (battery) is used.If the photovoltaic system is connected to other resources (diesel or wind generators), then it is called a hybrid photovoltaic system.Regarding photovoltaic systems for IoT-based greenhouses, several solutions were proposed in the literature [15][16][17].The last solution includes also a mobile application with integrated cloud services for monitoring the photovoltaic system status.
Other solutions, like the ones presented in [18,19], are based on the concept of "MIT's Personal Food Computer" [20].A brief comparison of the solutions presented in this section is available in Table 1, where the "✓" symbol represents the presence of the feature named in each column, and "X" represents the absence of it.Realization of wireless charging in an intelligent greenhouse with orthogonal coil system uniform magnetic field Wireless power supply technology for the uniform magnetic field of intelligent greenhouse sensors Fuzzy Maximum Power Point Tracking (MPPT) controller for photovoltaic system on mini greenhouse An Automated Greenhouse Monitoring and Controlling System using Sensors and Solar Power A Smart Photovoltaic System with the Internet of Things: A Case Study of the Smart Agricultural Greenhouse Personal Food Computer: A new device for controlled-environment agriculture "Food Computer"-A Demo Platform for the Internet of Things Education

GreenLab Project
A solution for smart farming in the form of a mini smart greenhouse that continuously monitors factors such as temperature, air humidity, brightness, and soil moisture is proposed next.In order to reduce energy consumption costs, a photovoltaic panel and a buffer battery are incorporated into the system, coupled with a mobile application to facilitate easy data visualization and monitoring of the greenhouse.
This research follows the waterfall model of the system development life cycle as a research methodology.The required steps are the requirements, system design, implementation, testing, and maintenance.

Requirements
This research focused on developing a proof-of-concept for an IoT-based small-scale smart greenhouse, relatively easy to implement and easy to use by non-technical personnel.In this process, we have identified and established the following requirements:

•
The greenhouse should be small-scale, no larger than 40 × 40 × 40 cm; • The processor used and the development board should be low-cost, accessible, easy to program, and well documented; • The solution should include sensors for temperature, humidity, light, and actuators for irrigation, air heating, and cooling; • The system should be powered from an accessible green source (i.e., to use solar energy); • The solution should provide connectivity to the Internet; • The solution should contain an easy-to-use mobile application for monitoring the greenhouse environment's relevant parameters.

System Design
As a solution, we propose an IoT-based small-scale smart greenhouse called GreenLab, powered by a photovoltaic panel and a mobile application for monitoring the environmental parameters.The solution respects the IoT layered architecture approach and includes layers for perception, communication, and the application.Figure 1 presents the block diagram of the perception layer of GreenLab.The diagram consists of the Arduino MEGA 2560 R3 development board with an ATmega2560 microcontroller, an 8-channel relay module, an ultrasonic distance sensor to measure the water level in the container, a capacitive soil moisture sensor, a gas sensor, a light sensor, an air temperature and humidity sensor, an Ethernet module connected to a phpMyAdmin database, a solar panel, a battery (with its charger), a submersible water pump, an auto heater, two fans, LED matrices and the greenhouse itself.GreenLab is powered mainly by the energy obtained from the solar panel.Taking into account the cloudy days or that there is a day-night cycle, a buffer battery has been connected to provide the energy to supply all the components of the mini-greenhouse which is charged mainly from the solar panel.Secondary/alternatively, a charger is connected to the main battery, only in case of need.The functional block diagram with the supply of the component blocks from the renewable energy source (solar panel) and alternatively from the network is presented in Figure 2.

Hardware Design
The GreenLab hardware system consists of a power supply solution, a communication module, and a control system containing three main blocks: the irrigation block, the lighting control block, and the ventilation and heating control block.
In Figure 3, there is the wiring diagram of the control system.Figure 4 presents the block diagram of irrigation control.It consists of the Arduino MEGA 2560 R3 (ATmega2560 microcontroller) board, the ultrasonic distance sensor to measure the water level in the container, the capacitive soil moisture sensor, and the 8-channel relay module which controls the water pump used to water the soil.
Figure 5 presents the block diagram of lighting control.It consists of the Arduino MEGA 2560 R3 (ATmega2560 microcontroller) board, the light sensor to detect whether there is day or night, the 8-channel relay module which controls the LED matrices used to illuminate the greenhouse.
Figure 6 presents the block diagram of the ventilation and heating system composed of the MEGA 2560 R3 development board, the block of the relay, the air temperature and humidity sensor the auto heather, and two fans mounted on the same level, thus one introduces air in the greenhouse and the other evacuates it.

Software Design
Following the same IoT layered architecture approach for the software design, we have chosen three layers, containing the perception layer, the network layer, and the application layer [21].A schematic of the proposed architecture is presented in Figure 7.The perception layer which is responsible for the system-environment interaction provides functionalities such as data acquisition from the sensors and control modules for the actuators as it can be seen in Figure 8.The main environment parameters to be controlled are the temperature, the ambient light, and the soil moisture, which are monitored through sensors, and their level is adjusted through actuators like fans, LEDs, and water pumps.Next, we will present the flowchart for each main control system module based on the sensors' readings.For the irrigation module, the flowchart is depicted in Figure 9.When the soil moisture sensor detects that the soil has reached the dryness threshold, the board closes the relay that controls the submersible pump.It draws water from the container and through a pipe and moistens the soil.This operation is interrupted by opening the assigned relay in the relay block in one of the following situations:

•
The soil moisture detection sensor tells the development board that the soil is sufficiently moist; • A preset number ( 5) of seconds has elapsed since the relay closed; • The ultrasonic distance sensor tells the plate that there is no more water in the container (the distance from the sensor to the float in the vessel is more than 10 cm and the water level is below the suction mouth of the pump).For the lighting module, the flowchart is depicted in Figure 10.The light sensor detects the difference between day and night (the absence of light) and communicates the status to the microcontroller which turns on or off the LED matrices according to the day/night functioning mode.
For the ventilation and heating module, the flowchart is depicted in Figures 11 and 12.The control of the fans is carried out by turning on or off the relays in the following situations:

•
The gas sensor detects an amount of gas above a defined threshold; • The temperature sensor detects a temperature above/below a defined threshold.
The network layer provides the communication between the perception and the application layers.The application layer offers the possibility to visualize and monitor the data acquired by the perception layer.A mobile application is responsible for visualizing the evolution of each parameter, by using 24 h or 7-day data records and for direct control of the actuators, by providing a manual command mode of operation for the system.As basic security measures, authentication and authorization roles were defined and implemented.In Figure 13, there is a caption of the graphical user interface for the manual commands for an authenticated user with control rights.Following the schematics and the requirements from the previous sections, we have implemented a prototype of the greenhouse with the following dimensions 40 × 30 × 22 cm, to which we have added all the components from the schematics in Figure 3, reaching a total cost under USD 200.The main hardware components used by this solution are as follows: Each component, its cost, and its functionality are described in Tables 2-5.Pictures of the obtained prototype can be seen in Figures 14 and 15.

Software
Each software component was implemented following the software design described in the previous sections:

•
The perception layer functionalities were implemented on the embedded platform as C functions through the Platform IO framework.

•
The network layer implements the connection between the mobile application and the database where sensor data records are stored.It was implemented using the Axios library for CRUD (Create-Read-Update-Delete) operations over the HTTP communication protocol.

•
The application layer consists of a mobile application written in React Native (Expo), in Typescript.The front-end of the mobile application was developed using the Expo platform, Javascript, and JSX (a JavaScript extension developed over React Native) and the back-end used XAMPP, PHP, and MySQL for the connection to a PhpMyAdmin database.
A more detailed schematic can be seen in Figure 16.

Testing of the Setup
The system was tested and validated in laboratory conditions.The tests concentrated on the monitoring and control process for the main environment parameters described in the previous sections.During the system validation, data were gathered from all the sensors for several weeks.The following figures (Figures 17-22) represent samples of data obtained regarding each parameter monitoring.At the system level, several plants were monitored during growth for three weeks (see Figure 23).

Maintenance
For verification and maintenance, a protocol was defined and proposed.Its objective is to ensure the proper functioning and longevity of the equipment and systems through regular verification and maintenance activities.This protocol applies to all equipment and systems within the mini greenhouse that require periodic verification and maintenance.Procedures: 1. Planning: (a) Identify equipment and systems requiring verification and maintenance.(b) Establish a schedule for conducting verifications and maintenance tasks.

Preventive verification:
(a) Conduct visual inspections of equipment to detect signs of damage.(b) Test the functionality of systems to ensure they work correctly.

Conclusions
GreenLab project is a proof of concept for an IoT-based small-scale smart greenhouse.Its architecture respects the multi-level IoT architecture.
By using different IoT technologies, we have succeeded in implementing a modular, low-cost, simple-to-use and control greenhouse.By respecting the IoT layered approach, we have provided a modular and flexible solution from both hardware and software points of view.

Figure 1 .
Figure 1.Block diagram of the perception layer of GreenLab.

Figure 2 .
Figure 2. Block diagram with the supply components from the battery (battery charger) and the solar panel.

Figure 13 .
Figure 13.Graphical User Interface of the mobile application.

Figure 17
Figure17presents the evolution of the air temperature during 24 h and 7 days, respectively.The plots are a direct capture of the mobile application display.In a similar manner, Figures18-22present the evolution of the other parameters.At the system level, several plants were monitored during growth for three weeks (see Figure23).
or defects identified during preventive verification.(b) Diagnose the root causes of problems and determine the solutions.4. Implementation of maintenance measures: (a) Perform repairs or replacement work as needed.(b) Test equipment or systems after maintenance to verify proper functioning.

Table 2 .
Power harvesting and storage components.

Table 3 .
Processing and communications components.