ORIGINAL ARTICLE
Software Engineering for a Mini-PFAL (Plant Factory with Artificial Lighting) with IoT Interconnectivity
Ingeniería de Software para Mini-Fábrica de Plantas con Iluminación Artificial e Interconectividad IoT
Software Engineering for a Mini-PFAL (Plant Factory with Artificial Lighting) with IoT Interconnectivity
Revista Ciencias Técnicas Agropecuarias, vol. 31, no. 3, e04, 2022
Universidad Agraria de La Habana
Received: 16 October 2021
Accepted: 24 June 2022
ABSTRACT: Software engineering is a systematic approach that allows traceability of programming-oriented projects in the multiple paradigms that can be written, thus allowing the orderly planning of information flows and algorithms to reach the desired result through of the implementation of a robust and systematic methodology. On the other hand, the Indoor trend is a technological concept that has evolved with the entry of the 21st century, with the aim of promoting urban, peri-urban and rural agriculture. This concept creates agriculture anywhere from a department to a greenhouse. The present work presents the results of a research in software engineering referred to the design of a mini-PFAL, technified with multiple layers of software for the control of growth parameters in experimental lettuce crops, such as light intensity, temperature, humidity, light spectrum frequency, irrigation control, etc. The design strategies for the creation of the software architecture at its different levels are described, applying the software design methodology. The structure of the design process is ordered from the requirements analysis to the interface design, with them the final product reported is a PFAL IoT system that is interconnected via Bluetooth and WiFi with the SmartPhone, in turn via USB port to a GUI Visual Studio application, having a WareHouse data that administrates the information of the variables in a local database which manages the information on a SharePoint page that in turn, links with Access, having a Dashboard to directly control crop growth remotely, thus having an intelligent PFAL system for growing vegetable crops in vertical format.
Keywords: Plant Factory, Indoor, Internet of things, Vertical crops, Software design.
RESUMEN: La ingeniería de software permite la planeación ordenada de los flujos de información y algoritmos para llegar al resultado deseado a través de la implementación de una metodología robusta y sistemática. Por otro lado, la tendencia Indoor, es un concepto tecnológico que ha evolucionado con la entrada del siglo XXI, con el objetivo de promover la agricultura urbana, periurbana y rural, fomentando agricultura en formato vertical en cualquier parte, desde un departamento hasta un invernadero. En el trabajo se exponen los resultados de investigación de ingeniería de software para una Mini-Fábrica de Plantas con Iluminación Artificial (mini-PFAL: Plant Factory with Artificial Lighting), tecnificada con múltiples capas de software para el control de parámetros que intervienen en el crecimiento de cultivos, como son la intensidad luminosa, temperatura, humedad, espectro luminoso, ciclos de riego/día y otros. Se exponen las estrategias de diseño para la creación de la arquitectura de software en sus diferentes niveles. Aplicando la metodología de diseño de software, se ordena la estructura del proceso de diseño, desde el análisis de requerimientos hasta el diseño de interfaz. El producto final resulta un sistema PFAL IoT que se interconecta vía Bluettoth y WiFi con el SmartPhone, a su vez vía puerto USB a una aplicación GUI Visual Studio, teniendo una data WhereHosue que administra la información de las variables en una base de datos local que gestiona la información en una página SharePoint que, a su vez, vincula con Access y un Dashboard, resultando un sistema PFAL inteligente.
Palabras clave: Fabrica de Plantas, Indoor, Internet de las cosas, Cultivos verticales, Diseño software.
INTRODUCTION
The vertical farming model was proposed in 1990 by the biologist Dr. Dickson Despommier according to Chamberlain, (2007), who coined this term for the planting strategy, taking advantage of spaces to maximize crop areas. With the entry of the era of agriculture 4.0 and access to lower costs to infrastructure such as LED devices, sensors, processors, etc., vertical farming has been oriented to a term called Plant Factory with Artificial Lighting (PFAL), defined by Kozai et al. (2015) as: “Multi-crop shelf with electric lamps on each shelf , positioned vertically and that has other necessary equipment and devices, such as air conditioners, circulating fans, CO2 supply units and nutrient solutions and environmental control units. The same author states that positioning more crops vertically increases the efficiency of land use, as well as that, although fluorescent lamps have been fundamentally used in PFALs, currently light-emitting diode (LED) lamps are attracting a great attention to these uses (Kozai et al., 2016).
Automated design, ICTs, Big Data, Artificial Intelligence and all the new technological phenomena that are revolutionizing scientific and technical news are correlated with the design of PFALs, with software being more than ever, an extremely important design factor, which gives them added value both in terms of economic weight and engineering design in computer systems.
The Institute of Electrical and Electronic Engineers (IEEE) defines Software Engineering as: 1) The application of a systematic, disciplined and quantifiable approach to the development, operation and maintenance of software, that is, the application of engineering to software; 2) The study of approaches according to point 1 (IEEE, 2021).
On the other hand, Pressman (2010) breaks down software engineering into four guiding axes: Tools, Methods, Processes and Quality Commitment, where the processes are part of the project administration to generate the reports, models, writings, etc. On the other hand, the methods are the practical activities of modeling, construction, programming and tuning the project, and the tools are a link between the processes and the methods that allow the assistance of the programs that will allow the integration of the project environment.
In this way, a synergy is generated between the importance of Software Engineering and various applications in agriculture, such as Desktop Applications, Mobile Apps for Smartphones on Android and iOS systems, WebApp's, SpaceApp's, Internet services and Database managers dedicated to agriculture.
All these platforms are based on software structures and supported by multilanguages that allow them to program their operating functions. Likewise, the architectural correlation of its design is based on the correct application of Software Engineering methodologies according to Zielinski & Szmuc (2005); Pressman (2010); Serna (2010), which today is taking more ground in designing computer software for applications in agriculture in all its context.
The development of vertical agricultura according to Farminova Plant Factory (2021), green factories or the Indoor trend, is mostly concentrated in leading countries in this field, such as Canada, Japan, Taiwan, China, the United States, the Netherlands and some European countries (Tsukagoshi & Yutaka, 2016). However, Software Engineering methodologies, in the field of PFAL, are hardly published or the information is scarce. These countries lead the design, construction and research of the PFAL while other countries, such as Latin American, are entering research processes, according to Ocampo et al. (2014), to analyze their viability. It shows the backwardness of urban, peri-urban and popular agriculture, not taking advantage of the use of ICT's and other technological tools in the age of agriculture 4.0. That leads to the exercise of reflection on the importance that AgroApp's (so to name them) are taking today in the niche of modern agriculture.
This paper presents the results of an investigation that had as a general objective to design software for control and monitoring of Mini-PFAL vertical farming system, for the low-scale production of agricultural vegetables.
That system has oriented programming, hardware based on micro-controlled systems, which operate sensors and actuators. In the same way, they establish data interconnection to a PC, Graphic User Interface for monitoring the processed variables, interconnection to local databases (BD) for the protection of information and wireless interconnection via Bluetooth and WIFI.
Likewise, the following were outlined as specific objectives:
Design closed loop control algorithms for lighting and irrigation in micro-controlled systems.
Design Local-Host Database Management System (SGBD) with Internet access.
Design feedback algorithms for plant mass growth, temperature, light intensity and relative humidity.
Interconnect local DB with the Graphical User Interface (GUI), to control the vertical farming system.
Design Bluetooth wireless control with mobile application based on Android Studio.
Design WIFI connectivity for data management in a Host in the cloud.
MATERIALS AND METHODS
For the analysis of the requirements for the design of software for control and monitoring of the Mini-PFAL vertical farming system, for the low-scale production of agricultural vegetables, both the operational characteristics and the project plan and the analysis model were taken into account.
Regarding the operational characteristics, the following are considered:
High-level graphical user interface programming in Visual Basic (VB) language.
Programming of microcontrollers (MCU) for system instrumentation, with 3.5” TFT panel with 320x480 RGB resolution and TouchPad interface.
Mobile application programming in JAVA language for system control with Bluetooth connectivity.
Database design with Access manager and SQL Server and remote interconnection with SharePoint application.
Implementation of Dashboard in Power Apps for interconnection with the SharePoint service.
The project plan takes into account the tracing of system requirements under the following diagrams:
Desktop application: Flowchart, UML diagram and form proposal design.
Application of MCU's: Flowchart and pseudocode.
Mobile Application: UML diagram and form proposal design.
Databases: Entity-Relationship Diagrams.
To configure the analysis model of the system proposal, it is decided to implement a data flow diagram (DFD), collecting the information of the operational characteristics, the result of the DFD Level 0 as shown in Figure 1.
The proposed design methodology for Mini-PFAL is shown in the following diagram:
RESULTS AND DISCUSSION
System Control Operational Workflow Diagram
Workflow diagrams are tools for tracing the flow of information, placing the actors in channels divided by blocks and interconnecting the data flows, in order to represent the behavior of the system. According to Pressman (2010), “…An activity diagram is similar to a flow diagram, and uses rounded rectangles to denote a specific function of the system, arrows to represent flow through it, decision diamonds to illustrate a branching of decisions”. This same author states that: “The use cases, together with the activity and channel diagrams, are oriented to the procedure. They represent how different actors invoke specific functions (or other procedural steps) to satisfy system requirements.
In the Mini-PFAL Networking system there are four actors: User, PFAL, PC and SmartPhone.
The user is the main actor who interconnects in the first instance with the Embedded System installed in the PFAL, hence the communication between the PC and the SmartPhone is selected by the user. The following diagram (Figure 2) describes the operational form of the behavior of the information flow of the system:
Mini-PFAL System Model
Carrying out the conjunction of class-based modeling and the channel diagrams of the use case model, the mapping and structuring of the general representative diagram of the project proposal was carried out, the result can be seen in Figure 3, reflecting interface design through a Unified Modeling Language (UML) diagram.
As it can be seen, the channel diagram is divided into four sections, which brings together the analysis of requirements carried out in the preliminary project. Table 1 explains, in detail, the agents involved in the UML Model proposed for the design of the programming architecture.

Deployment Design Descriptor Format
In the Software Engineering methodology, according to Pressman (2010), the elements of the deployment design indicate the way in which the functionality of the software and the subsystems will be accommodated within the physical computing environment that will support it.
The information flow architecture, in the physical aspect, allows the traceability of the descriptor format that is presented in Figure 4:
It can be seen that, as a whole, the system is made up of four nodes, where the interconnection of the components-nodes in the information flow of the wired and wireless information processing layers can be analyzed.
Electronic Diagram of the Embedded System of the Mini-PFAL
The central core layer (Figure 5) composed of the electronic architecture, is designed through the implementation of an Atmega 2560 microcontroller Microchip (2021), which acts as information traffic control manager, operating under a scheme of master to make the request of the variables to the slaves (sensor modules, Figure 7), in addition to processing and ordering the request data and managing the COM-USB port communication (Figure 6) by means of a PL2303 driver (Prolific, 2022), bidirectional WIFI communication intercom through an Esp8266 (ESPRESSIF, 2022) via Serial, Bluetooth connectivity implementing an HC-06 Serial module Olimex (2021), and some PWM and digital control outputs for LED lighting control , irrigation and linear displacement actuators of the Mini-PFAL, which can be seen in the electronic diagram of Figure 5, which is presented below.
As it is mentioned above, the PL2303 chip manages the USB to RS232 Bridge Controller communication, in this way the PFAL manages to connect via COM port with the Visual Studio desktop application for Windows and thus, manages bidirectionally the information traffic of the control variables (°C, %RH and Lux), to be managed with the VB ODBC Open Database Connector and manage the information to the Local Database (Figure 6).
The sensor modules (slaves) communicate via RS-232 protocol with the main module (master). The request is made under the computational algorithm shown below, where the master, through its algorithm, manages the information traffic and administers it to the wired or wireless devices, depending on the connection in which the request is made (Figure 7). As the main core, the Atmega 328p is observed, which receives the request from the master via Serial, later it is interconnected via I2C to read the HTU21D and BH1750 sensors, thus collecting the variables of temperature, humidity and luminosity, to be delivered in format text to master via Serial.
Finally, the control of the embedded system converges on a 3.5” TFT LCD TouchPad with 480x320 pixels (Figure 8), which performs the function of input and output interface to feed back the bidirectional data of the control and acknowledgment of system information, through of a graphical interface that is visually attractive and easy to operate. It allows having a menu with three options: Sensors, Graphs and Settings. The TouchPad interface allows configuring, consulting in real time the operational variables of the vertical greenhouse and making graphs of temperature, humidity and luminosity with a period of 300 samples per day.
Mini-PFAL Embedded System Component Level Design
Implementing a batching process to the embedded system, a structured diagram is obtained that traces the flow behavior of the program as shown in Figure 6.
Communication with the sensors is achieved under the RS-232 protocol, interconnected in a bus-type topology network, where 12 modules are interconnected in parallel to the Vcc, GND, Tx and Rx connections. The first part of the communication request has an address header to make the request to the 12 sensor modules interconnected in the system. The coincidence address allows the temperature, humidity and luminosity variables to be requested, so that the slave returns them to the master.
Component Level Design of Slave Sensor Modules
The request described in a flow chart by the slave modules can be seen in the slave programming algorithm shown in Figure 10.
As it can be seen, the diagram checks iteratively, with the first conditional, for the presence of packets in the COM port buffer and, at that very moment, all the slaves are put on alert, due to the nature of the topology bus type, reaching the information to all the slaves, but only one of them contains the request address that debugs the second conditional. Subsequently, the data are sent to the master to be managed by the algorithm of the diagram in Figure 6, to send the data via USB, Bluetooth or WIFI, respectively, with the implementation of the corresponding class blocks.
Embedded System Interface Design
The Graphical User Interface for the main operation of the machine is based on the 480x320 TouchPad LCD control, installed on the front panel of the module (Figure 11), the user can navigate through three main menus interactively:
Final Considerations
As it has been seen, this article focuses on the application of the Software Engineering methodology, following the creation stages, namely: the requirements analysis and the design model, which, in turn, includes data design, architecture design, interface design and component level design (Mohapatra, 2010)
The stages as a whole make up the software modules that interact in the multilanguage layers to implement the solution, both hardware (applied electronic design), WebApps programming, WareHouse Data management, IoT wireless interconnectivity, local DB management and Hosting.
The detailed explanation of the Hosting, Data Warehouse IBM (2021) and GUI layers is not implemented in detail in terms of the presentation of results, leaving this work in the continuation of the presentation of research results. The important points to be developed in the present presentation are based on the interconnectivity of data, the requirements analysis, the design model and, using the diagram formats, it was possible to refer the programming strategies used for the design of the mini-PFAL system.
The operational form of the software layers in their dynamic working cohesion set can be better outlined by implementing the System Layer Architecture as shown in the diagram of Figure 12.
The interrelated synergy of the software layers that interact in the system, allows the orderly management of data traffic, from obtaining the variables to the display of information on a "Dashboard", with dynamic, graphic and refined information, with a flexible and intelligent interaction for the user, giving a technical solution for modern agriculture, where the new farmer of the 21st century becomes a subject with technical knowledge in IoT operation with smart agriculture devices, which make up knowledge and skills in the management and use of BigData, AI, RA, VA, Drones, IoT, etc.
The set of the entire project in its functionality is a presentation of the quite ambitious results model, given that it is subdivided into 7 important parts:
The explanatory and detailed set of all these aspects requires a broader publication, so that each of the functional components of the proposed Mini PFAL IoT system can be broken down part by part.
CONCLUSIONS
As a result of the software engineering research for a Mini-Factory of Plants with Artificial Lighting, the different components of the system are determined and exposed, namely:
• The information flow diagram of the control system of the Factory of Plants with artificial lighting PFAL.
• The UML system interface design model.
• The deployment diagram of the system descriptor format.
• The electronic scheme of the main control system.
• The electronic diagram of the communication system.
• The scheme of sensor modules and their intercommunication.
• The output and input interface to feed back the bidirectional data of the control and acknowledgment of system information.
• Flow diagrams (algorithms) for requesting and sending data on temperature, humidity and luminosity from the Master-Slave.
• The design of the graphical interface of the control panell.
THANKS
The results are part of the Technology Development and Transfer (DTT) project, promoted by the research programs of the General Directorate of Research and Postgraduate Studies of the Autonomous University of Chapingo (UACh), as well as the research line of "Science and Applied technology in agriculture 4.0 for rural development” belonging to the research center No. 82 CIISCINACYC, of the Department of Rural Sociology. Thanks to the cooperative Red Campesina Agroecológico Tierras del Sur S C de P de R L de C V, in Raboso, Izúcar de Matamoros, Puebla, which promotes research agreements to be able to manage resources in favor of the vanguard of the field and thus carry out technology transfer for the modernization of the Mexican countryside.
REFERENCES
CHAMBERLAIN, L.: “Skyfarming”, New York Magazine, 24, 30 de marzo de 2007, Disponible en:https://www.microchip.com/en-us/product/ATmega2560.
FARMINOVA PLANT FACTORY: The Future of Agriculture, [en línea], Cantex Group, 2021, Disponible en:http://www.farmicova.com, [Consulta: 20 de marzo de 2022].
IBM: ¿Qué es un Data Warehouse?, [en línea], IBM Db2 Warehouse, Edición Empresarial, 20 de mayo de 2021, Disponible en:https://www.ibm.com/mx-es/analytics/data-warehouse, [Consulta: 20 de junio de 2021].
IEEE: An Annotated Bibliography for ISO/IEC/IEEE 42010, [en línea], 15 de octubre de 2021, Disponible en:http://www.iso-architecture.org/ieee-1471/docs/bibliography-42010.pdf, [Consulta: 29 de junio de 2021].
KOZAI, T.; FUJIWARA, K.; RUNKLE, E.: “Why LED lighting for urban agriculture?”, En: LED lighting for urban agriculture, Ed. Springer, Singapore, pp. 3-18, 2016.
KOZAI, T.; NIU, G.; TAKAGAKI, M.: Plant factory: An indoor vertical farming system for efficient quality food, Ed. Springer, Academic ed., Singapore, 2015.
MICROCHIP: ATmega2560, [en línea], Microchip, 2021, Disponible en:https://www.microchip.com/en-us/product/ATmega2560, [Consulta: 20 de junio de 2021].
MOHAPATRA, P.K.J.: Software Engineering, Inst. New Age International, California, USA, 2010.
OCAMPO, R.A.; HERNÁNDEZ, G.L.H.; FERNÁNDEZ, V.D.; FERNÁNDEZ, V.D.; CERVANTES, B.R.: “Análisis estático de los esfuerzos y deformaciones de la estructura de un Invernadero tipo Ventila Cenital ubicado en Veracruz”, Revista Ciencias Técnicas Agropecuarias, 23(4): 10-16, 2014, ISSN: 1010-2760, e-ISSN: 2071-0054.
OLIMEX: HC Information Technology Co., Ltd. Guangzhou, [en línea], Olimex, 20 de mayo de 2021, Disponible en:https://www.olimex.com/Products/Components/RF/BLUETOOTH-SERIAL-HC-06/resources/hc06.pdf, [Consulta: 23 de junio de 2021].
PRESSMAN, R.: Ingeniería del Software Un Enfoque Práctico University of Connecticut, Ed. McGraw-Hill Interamericana, Madrid, publisher: SA, 2010.
SERNA, M.E.: “Métodos formales e Ingeniería de Software”, Revista Virtual Universidad Católica del Norte, (30): 1-26, 2010, ISSN: 0124-5821, Disponible en:https://www.redalyc.org/articulo.oa?id=194214476008, [Consulta: 21 de agosto de 2021].
TSUKAGOSHI, S.; YUTAKA, S.: Plant Factory. An Indoor Vertical Farming System for Efficient Quality Food Production, Ed. Elsevier, Current Status and Perspectives ed., vol. Chapter 3 PFAL Business and R&D in the World, 35-68 p., publisher: Academic Press: London, UK, 2016.
ZIELINSKI, K.; SZMUC, T.: Software engineering: evolution and emerging technologies, Ed. IOS Press, vol. 130, California, USA, 2005, ISBN: 1-58603-559-2.
Author notes
*Author for correspondence: Luis Tonatiuh Castellanos Serrano, e-mail: lcastellanoss@chapingo.mx
Conflict of interest declaration