The Greenhouse system enclosure allows the management and control of the crop ecosystem resulting in increased crop production, longer production time, enhanced product quality, and less defensive chemicals . To achieve this, the agriculture industry is bound to adopt the Internet of Things because its introduction in the agricultural sector can solve many problems for farmers . According to recent statistics, IoT systems installation in the agriculture sector is rising at a compound annual growth rate of 20 percent (20% CAGR). It is estimated in  that the number of connected devices is growing from 13 million to 225 million in the period of 10 years (2014-2024). With the current development worldwide, a lot of agricultural lands have been used in other non-agricultural areas, such as buildings, industrial sites, and other infrastructures, which will undoubtedly lower the agricultural production and have negative impacts on environments and economy in general. With this problem, the need of developing new technologies to close and cover this gap is increasing day-to-day. One solution that the community can implement is to create an agricultural system with limited land availability commonly called urban farming or urban agriculture.
Smart farming IoT platform based on edge and cloud computing was proposed in . In this work, Miguel A. Zamora-Izquierdo et al. describes the design, development, and evaluation of a technology that provides automated IoT technology to meet severe PA requirements. It is quite challenging to solve these particular problems such as Soil Fertility Management, Crop Disease, Pest Control, Irrigation and Water Management, etc. in precise monitoring of wide-scale agricultural fields. In , N. K. Nawandar and V. R. Satpute designed an IoT-based, low-cost, and intelligent module for smart irrigation systems using three modules as physical part and MQTT with HTTP Protocol for transferring information from field location to the user Daponte P. et al.in  alsoproposes an overview of the different techniques applicable to precision agricultural monitoring. The drone architecture for multispectral/thermal sensing and DTM/DSM has been discussed.
Researchers in the IoT domain must also consider the cloud platform that manages information and various IoT protocols such as MQTT, CoAP, and AMQP that are used to communicate and transmit data to the cloud as well as to the end-user in order to keep farmers informed about crop conditions from a remote location. It is expected that the technology will be evaluated further in long-term crop cycles in order to optimize activities and adapt to decision support capability, which will be provided to human operators as management solutions.
The rest of the paper is organized as follows: Section 2 describes the Background Theory and related works, Section 3 shows the Structure and Development of IoT system in the greenhouse, MQTT Protocols and its application in Greenhouse monitoring is depicted in Section 4, Greenhouse Data Acquisition and Monitoring System design was described in Section 5, Section 6 shows the Experimental results and Discussions and Finally, Conclusions are in Section 7.
2. Background Theory of IoT
The researchers defined the Internet of Things (IoT) in many different ways. In general, it is a concept based on combining information technology, sensor technology, wireless communication technology, and internet technology . In , IoT is defined as a network of physical objects and devices that are integrated with an Internet connection. Also, in , they defined IoT as a recent communication paradigm that envisions a near future in which the objects of everyday life will be fitted with sensors, microcontrollers, transceivers for digital communication, and appropriate protocol stacks that will make them able to communicate easily with one another and with the user becoming an integral part of the internet.
The Internet of Things (IoT) changed how we live, work, travel, and do business since 1999, when it was first discovered; it is marking a new industrial transformation, known as Industry 4.0, and key in the digital transformation of organizations, cities, and society as well. Figure 1 shows the roadmap to understand the essence of the Internet of Things in the past decades.
After the presentation on the application of internet-connected RFID in Procter & Gamble’s supply chain, Ashton identified a future in which computers can collect data and transform it into useful information without human intervention , which is possible with technology such as sensors and the RFID where computers can observe, interpret and understand the environment.
Figure 1. Technology roadmap for the internet of things (IoT) in last two decades. Source: https://www.nsti.org/directory/org.html?i=2218.
Although RFID’s commercial implementations have continued to draw on its barcode-like characteristics to date, RFID provides far more over the long term and aims to be a core technology for the Internet of Things. The quicker checkout is the most significant benefit of a department store using RFID .
3. Structure and Development of the Greenhouse IoT System
Smart agriculture can be represented as a farm or greenhouse fitted with smart objects; a field network enables information to be transmitted between field- installed devices and a gateway to link the smart agriculture sector to the outside world of the internet. These smart objects make it easier to communicate with farmers with real-time information to manage them. Figure 2 shows the Conceptual model of the Greenhouse IoT based Monitoring System.
IoT Architecture is a network of various elements, such as sensors, actuators, protocols, cloud servers, which make up an IoT networking system. It typically consists of distinct layers that allow system administrators to monitor and analyze the system working. Although some researchers represent it into more layers and name them accordingly based on their conceptions, in , Sethi P. et al. differentiated between 3-layers and 5-layers IoT architecture, and in  M. Burhan et al. in their comprehensive survey on IoT elements, Layered Architectures and Security Issues they compared 3-4-5 layers architecture, more than three layers can be particularly applicable in edge or fog computing IoT system, for 4-layer architecture the support layer that secure cloud computing is added whereas for 5-layer architecture, the business layer is added in order to manage data and applications, business and all profits within the system and the network layer is divide into two layers namely; the transport and processing layers. Since the system can have other particular layers between the physical and the network layers, the general architecture of the IoT system is described by three layers are physical, network, and device layers.
Figure 2. Conceptual model of the IoT based monitoring system.
3.1. Physical Layer
The physical layer of the architecture also referred to as the perception layer, consists of physical objects that include node sensors and other connected devices that remotely acquire real-time data as per the needs of the system for various cultivation functions , including edge devices that provides access to the internet and instantly transmits collected data to the cloud through Wi-Fi and lastly actuators that interact with their environment to facilitate proper physical action where it is needed within the system. There are several protocols and common technology for this layer. Some of the common protocols and standards for the physical layer include Ethernet, Zigbee , Bluetooth Low Energy (BLE) , WiMAX, IEEE 802.15.4, IEEE802.11ah, RFID, Cellular (GPRS/2G/3G/4G/5G) , LTE-MTC, CDMA and so on, all that is adapted to variable applications and network points and are used for interconnecting computers and other mobile devices within the system.
3.2. Network Layer
The network layer as the intermediary layer is the collection of all hardware and protocols that comprise all network communications, including switching and routing, protocols and translation between them, network-level security, and all to ensure the reliability of the network that takes place in the IoT system , data collected from physical layer devices need to be transferred and processed, that’s where the network layer involves in linking these devices and transfer data to other smart objects, such as servers and network devices through the intermediary. The intermediary portal is typically an internet gateway located at the edge of the connected devices, sometimes containing a proxy server. The data is gathered and often processed before being transmitted to the end-user over the internet . The network layer is subdivided into two sublayers; the packet encapsulation layer that forms the packets and the routing layer for the transmission, all with common protocols that include RPL (Routing Protocol for Low-Power and Lossy Network) , 6LoWPAN (IPv6 Low Power Personal Area Network) , CARP (Channel-Aware Routing Protocol)  and many more which allow network layer to forms the packets and performs packet transmission from source to destination.
3.3. Application Layer
The application layer is the third layer of the IoT framework. The layer that describes all applications that use IoT technologies, enabling the deployment of the IoT, assuring the communication between users and the system referred to at this moment as the Human Machine Interface (HMI) in so-called software as a Service (SaaS)   and is responsible for providing application-specific services to the user, for the implementation of a smart greenhouse where, for example, users can press the button on the app to turn on or off the fan. This layer is of considerable significance as functions such as monitoring, system management, and analytics are all implemented in this layer. The application layer consists of both the ZigBee Device Object (ZDO)  and the application support sublayer (APS) , which is a layer in Zigbee that provides an interface between network layer and application for providing the necessary services like a function call and API to the users whenever the ZigBee standard is used in the physical layer. Common Standard protocols in this layer include MQTT, AMQP, CoAP, HTTP/2, XMPP, WebSocket, and many more that provides communication to the end-user.
4. MQTT Protocols and Its Application in Greenhouse Monitoring
The smart system differs from its conventional counterpart by how the ordinary automatic system remains in off mode in the case of a failure. In contrast, the Smart system can communicate to other systems if it detects any difficulties and, if required, reports a fault to the user or instantly calls for assistance.
But any such instance of communication is only possible when there is a means of communication, a specific “language” that all the devices in a given IoT environment will share and be able to use. In the Internet of Things, the medium is established by protocols designed explicitly for connected device communication.
Some protocols allow customers to publish messages in the bus-based architecture as in Figure 3, for a specific topic that is distributed directly to subscribers of that topic where there is no centralized broker .
Hardware will be considered useless without IoT protocols in the IoT technology environment because the IoT protocols allow it to exchange information in an organized and reasonable fashion ; some of the standard IoT protocols are CoAP, AMQP, MQTT, XMPP, WebSocket, and many more.
Figure 3. Bus-based architecture for data exchanging protocols within the IoT system.
In this paper, a lightweight publish-subscribe-based messaging protocol, MQTT (Message Queuing Telemetry Transport) usage is considered,architected for service terminals at the client terminal through a central broker. MQTT is a frequently used application layer protocol for transferring data between IoT devices, and it uses a TCP/IP-based connection setup process .
MQTT brokers are considered to be the key component of any IoT framework based on MQTT since they provide several services to clients. MQTT Publisher publishes messages to the MQTT broker topic; Clients connect to this broker, which then facilitates contact between the two devices; the destination acts as an MQTT client that publishes messages and writes each log as a message; also, every device may subscribe to or register to specific topics. Whenever a client posts a message on a subscribed topic, the broker forwards the message to every subscribed client . Hence MQTT was named data-centric communication or broker-based services (Figure 4).
MQTT protocol was released by IBM in the late 1990’s and it’s now adopted by IoT Hub, a cloud service of Baidu platform for enabling security in two-way communication between smart devices and by Facebook messenger to maintain persistent connection . To ensure that all published data are smoothly received, many levels of QoS (Quality of Services) are supported ; those three levels are:
● QoS-0 (at most once): the fastest and reliable that guarantees a message is delivered at least once, but the confirmation is not received whenever the publication is sent.
● QoS-1 (at least once): guarantees that a message is sent to the receiver at least once, duplicates may be received.
● QoS-2 (exactly once): The highest, safest, and most reliable level, guarantees that the intended recipients receive each message only once with the most bandwidth-consuming, thus the slowest. Duplicates are tested to ensure that the message is sent only once. The higher the QoS level, the higher the process becomes complex.
HTTP was the most common and commonly used transfer protocol, but MQTT has rapidly gained popularity over the last few years. Developers have to pick between them wisely in the IoT systems design; Table 1 depicts the major difference between the two.
Figure 4. MQTT clients-broker, publish/subscribe model architecture.
Table 1. Major differences between MQTT protocol and HTTP protocol.
MQTT protocol has a relatively short specification for Complexity and Message Size, just CONNECT, PUBLISH, SUBSCRIBE, UNSUBSCRIBE and DISCONNECT types that are meaningful for usage. Table 2 shows the common MQTT implementation.
5. System Design
This study proposes an IoT-based Greenhouse Monitoring that contributes to the various range of agricultural greenhouse; the system not only allows intelligent monitoring of the internal climate and working conditions of the greenhouse but also enables the supervisor to control the greenhouse over the internet wherever he/she is through the interface.
In the proposed model’s architecture, the data collected experience various stages during their transition from sensors to interfaces and occasionally to actuators. These stages have a significant impact on technologies used for IoT context. These stages are divided into six main data flow phases: sensing, communication/transport, processing, storage, analysis, and actuation. Figure 5 illustrates both stages and phases in the Layered generic Architecture of the proposed system.
Using smart farming by IoT technology helps farmers minimize waste generation and improve productivity. Smart greenhouse equipped with an IoT system intelligently monitors and controls internal climate and reducing the need for human intervention.
Following are the leading hardware and software requirements:
1) Hardware Requirements
● DHT11 & DHT22 is a basic, low-cost digital multifunctional sensor that uses a capacitive sensor module and a negative temperature coefficient (NTC) thermistor to measure the surrounding air and delivers a digital signal of relative humidity and temperature relative to the output pin.
● Arduino UNO is an open-source Microchip ATmega328P based microcontroller board developed by Arduino. cc and is programmable with the Arduino IDE.
● NodeMCU ESP8266 is an open-source Lua based firmware and development board designed especially for IoT Applications; it runs on the ESP8266 Wi-Fi SOC designed by Espressif with ESP-12 module-based hardware.
Figure 5. Layered generic architecture of the proposed IoT agriculture greenhouse monitoring system.
2) Software Requirements
● The Arduino IDE (Integrated Development Environment) is a cross-platform computer application that is used to write, edit and upload programs to Arduino and other compatible boards; it is written in functions from C and C++ programming.
● ThingSpeakTM is an open-source IoT (Internet of Things) analytics platform that allows users to collect, visualize and analyze live data streams in the cloud. It forms an API (Application Programming Interface) for storing and retrieving live data from sensor Nodes using the HTTP and MQTT protocol over the internet or over the LAN (Local Area Network).
● Adafruit IO is a cloud service/platform designed to display, respond, and interact with an IoT project’s data, run it and manage it in private mode without being controlled by the user.
Experimental Setup and System Configuration
The configuration of the greenhouse Data Acquisition system consists of three parts, connecting the physical parts, configuring the ThingSpeak platform, and configuring the Adafruit IO broker and the laptop computer used for testing has the following properties; Lenovo Yoga laptop with 512 GB hard drive and 16 GB of RAM. The network bandwidth is provided by a Lenovo android Phone with 128 GB of storage and 6 GB of RAM. The network should not be a limiting factor for the research.
Connecting and configuring the system’s physical part is the easy part of the system, but where more mistakes are to be made without caution, > connecting sensor to Arduino and NodeMCU ESP8266 > connect it to the internet, the algorithm to connect it on the internet is shown in Table 3.
Table 2. Common MQTT Implementation platform.
Table 3. An algorithm to connect NodeMCU ESP8266 to Wi-Fi access point.
Configuring ThingSpeak, it’s all about visiting ThingSpeak.com; create a free MathWorks account or sign in to ThingSpeak using an existing account if you have it > Select the ThingSpeak channel you want your data to stream into; if you are new, have to create a new channel > enter the name and description > add fields then save, once created it you got the Channel ID, Author name and access control type and keys as in Figure 6.
Deploying the MQTT communication protocol was done by configuring the Adafruit IO broker and connecting it to the sensor and client > Set Adafruit IO username in the IO_USERNAME define, and Adafruit IO key in the IO_KEY define, sets up the temperature and humidity feeds, Table 4 shows the connection details of Adafruit IO MQTT broker. The Adafruit IO MQTT API only supports QoS level 0 (at most once) and QoS level 1 (at least once).
6. Experimental Results and Discussions
6.1. Without MQTT Protocol
In Figure 7, Arduino IDE’s serial monitor shows both the real-time data of temperature and relative humidity after the connection to the internet is established smoothly. Here the message is “Send to the IoT platform (ThingSpeak)”, indicate that data are being sent to the internet.
After processing the data, air temperature and humidity data for environmental parameters were sent to the ThingSpeak platform in time series cycles using the HTTP protocol. The ThingSpeak website works as a server, and NodeMCU was as the client.
Figure 8 shows the graphical output at the ThingSpeak server, which can be accessed only after signing in to the ThingSpeak website with a username and password that has been created, and the cloud provides a reliable output. With the Channel ID and Read API key, environmental parameters data can be used
Figure 6. ThingSpeak platform configuration.
Figure 7. Evolution of the output data in serial monitor.
Figure 8. Temperature and Humidity in ThingSpeak (a) temperature data vs. the time, (b) gauge showing the temperature variations, (c) temperature data vs. the time, and (d) the numerical relative humidity output.
Table 4. MQTT connection details.
for MATLAB analysis. Figure 9 shows the performances in MATLAB during the run process of data acquisition in ThingSpeak. As the system work through the internet, for unstable internet, data pause for a while and continues when the internet is stable with the big change in magnitude of temperature as in (a), all data acquired can be processed directly in MALTLAB as shown in (b) to (d).
6.2. With MQTT Protocol
From Figure 5, it is clear that the gateway and the internet lie between the controller part (in the physical layer) and interface (application layer) and become the center of the whole IoT system, all connected wirelessly. MQTT just specifies the transport, and mostly the application layer, which determines how data is handled, transferred, and possibly stored, and finally, how clients are authorized in the system.
MQTT is a perfect communication protocol to share small quantities of data between IoT devices. In this study, it is to publish temperature and humidity readings from a DHT11 sensor with the NodeMCU ESP8266 to various MQTT topics so that any device or any platform that supports MQTT as clients can subscribe to such topics and obtain real-time data readings, as shown in Figure 10.
It requires building web-based dashboards that can visualize the real-time incoming data; using Adafruit IO’s MQTT broker is a great way to connect the IoT system over the internet. From any modern web browser, dashboards enable users to visualize data and control Adafruit IO connected projects. Sensor values are sent to IO feeds as numeric values, such as 24˚C for temperature. When sent to a topic, it can be a raw number or just a string value; the format of a topic is as follow: Username/feeds/temperature and Username/feeds/humidity.
The relationship between humidity and temperature inside the greenhouse is clarified in the first chapter. The measurements’ results confirm the concept that lowering relative humidity raises the temperature of the air and vice versa. Figure 11 displays a graph of air temperature variations and relative humidity taken by a sensor in two hours and published to the broker. The comparison between the values of air temperature and relative humidity indicates how the variables are related together. For example, when considering the point at 4:26:00PM, drops in relative humidity are level correspond at the same time to the rise of air temperature level.
Figure 9. Air temperature and relative humidity data MATLAB visualizations from ThingSpeak.
Figure 10. Real-time data readings and variations temperature (a) and humidity (b) published to the client interface.
Figure 11. Comparison of temperature and humidity variations of two hours (3:06 pm-5:11 pm).
Figure 12. MQTT functional testing.
6.3. MQTT Test
MQTT protocol as an IoT communication protocol, during the workflow a user have to ensure that the communication between broker and client is reliable as shown in Figure 4, to ensure reliable communication, a test which is an MQTT Functional Testing is carried out using MQTT.fx-1.7.1 in three steps as follows: Establishing the connection and publishing a specified message, subscribe to an MQTT topic and waits for the first message to be posted and then Simulates the publisher disconnecting from the server.
Figure 12 shows the testing of MQTT’s broker functionality, the process shown from the configuration of the broker profile and address in (a), after connecting the client to broker, the action of publishing a message through a designated topic is shown in (b), and the results show that the published messages are received well by broker as shown in (c) and then the functionality log shown in (d) demonstrate that all attempts to communicate between client and broker were successful by using QoS-0 and MQTT TLS.
The climate is one of the factors that affect the growth and production of crops in the agricultural greenhouse. However, the unpredictable weather conditions arising from climate change further degrades the quality and quantity of production. Deploying IoT devices for real-time monitoring is an added value to solve the problem, looking for a long-term solution to food production in order to optimize performance and productivity. This paper presented the different IoT technologies that are applicable in a greenhouse in order to monitor the environmental parameters. A small IoT prototype was designed to develop an algorithm that acquires environmental data and publishes them to the internet through an MQTT protocol, it also makes for a simple visual interpretation of the parameters of the greenhouse’s internal climate. MQTT’s functionality makes it an ideal choice for transmitting large amounts of sensed data to analytic systems and to cloud platforms, MQTT functionality testing was carried out in this paper to ensure all data is transferred according to the used QoS. Furthermore, this management system allows users to monitor the controllers’ operation mounted within the greenhouse from afar making the farming process more practical, precise, and analytical which will improve agricultural management and production.
 Manonmani, A., Thyagarajan, T., Elango, M. and Sutha, S. (2018) Modelling and Control of Greenhouse System Using Neural Networks. Transactions of the Institute of Measurement and Control, 40, 918-929.
 Zamora-Izquierdo, M.A., Santa, J., Martínez, J.A., Martínez, V. and Skarmeta, A.F. (2019) Smart Farming IoT Platform Based on Edge and Cloud Computing. Biosystems Engineering, 177, 4-17.
 Nawandar, N.K. and Satpute, V.R. (2019) IoT Based Low Cost and Intelligent Module for Smart Irrigation System. Computers and Electronics in Agriculture, 162, 979-990.
 Daponte, P. et al., (2019) A Review on the Use of Drones for Precision Agriculture. IOP Conference Series: Earth and Environmental Science, 275, Article ID: 012022.
 Li, Z., Wang, J., Higgs, R., Zhou, L. and Yuan, W. (2017) Design of an Intelligent Management System for Agricultural Greenhouses Based on the Internet of Things. 2017 IEEE International Conference on Computational Science and Engineering (CSE) and IEEE International Conference on Embedded and Ubiquitous Computing (EUC), 2, 154-160.
 Aliev, K., Jawaid, M.M., Narejo, S., Pasero, E. and Pulatov, A. (2018) Internet of Plants Application for Smart Agriculture. International Journal of Advanced Computer Science and Applications, 9, 421-429.
 Ibarra-Esquer, J.E. González-Navarro, F.F., Flores-Rios, B.L., Burtseva, L. and Astorga-Vargas, M.A. (2017) Tracking the Evolution of the Internet of Things Concept across Different Application Domains. Sensors (Switzerland), 17, 1-24.
 Burhan, M., Rehman, R.A., Khan, B. and Kim, B.S. (2018) IoT Elements, Layered Architectures and Security Issues: A Comprehensive Survey. Sensors (Switzerland), 18, Article No. 2796.
 Antony, A.P., Leith, K., Jolley, C., Lu, J. and Sweeney, D.J. (2020) A Review of Practice and Implementation of the Internet of Things (IoT) for Smallholder Agriculture. Sustainability, 12, Article No. 3750.
 Villa-Henriksen, A., Edwards, G.T.C., Pesonen, L.A., Green, O. and Sørensen, C.A.G. (2020) Internet of Things in Arable Farming: Implementation, Applications, Challenges and Potential. Biosystems Engineering, 191, 60-84.
 Dachyar, M., Zagloel, T.Y.M. and Saragih, L.R. (2019) Knowledge Growth and Development: Internet of Things (IoT) Research, 2006-2018. Heliyon, 5, e02264.
 Basagni, S., Petrioli, C., Petroccia, R. and Spaccini, D. (2012) Channel-Aware Routing for Underwater Wireless Networks. 2012 Oceans-Yeosu, Yeosu, Korea (South), 21-24 May 2012.
 Symeonaki, E., Arvanitis, K. and Piromalis, D. (2020) A Context-Aware Middleware Cloud Approach for Integrating Precision Farming Facilities into the IoT toward Agriculture 4.0. Applied Sciences, 10, Article No. 813.
 Geng, L. and Dong, T. (2017) An Agricultural Monitoring System Based on Wireless Sensor and Depth Learning Algorithm. International Journal of Online and Biomedical Engineering, 13, 127-137.
 Haripriya, A.P. and Kulothungan, K. (2019) Secure-MQTT: An Efficient Fuzzy Logic-Based Approach to Detect DoS Attack in MQTT Protocol for Internet of Things. EURASIP Journal on Wireless Communications and Networking, 2019, Article No. 90.
 Suciu, V., Balaceanu, C.M., Anwar, M., Pasat, A., et al. (2018) Analysis of Agriculture Sensors Based on IoT. 2018 International Conference on Communications (COMM), Bucharest, Romania, 14-16 June 2018, 423-427.
 Nastase, L. (2017) Security in the Internet of Things: A Survey on Application Layer Protocols. 2017 21st International Conference on Control Systems and Computer Science (CSCS), Bucharest, Romania, 29-31 May 2017, 659-666.