Next Article in Journal
Secure Networking with Software-Defined Reconfigurable Intelligent Surfaces
Next Article in Special Issue
Pedestrian Localization with Stride-Wise Error Estimation and Compensation by Fusion of UWB and IMU Data
Previous Article in Journal
Improving the Accuracy of a Biohybrid for Environmental Monitoring
Previous Article in Special Issue
Algorithms for Vision-Based Quality Control of Circularly Symmetric Components
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

A Smart Agricultural System Based on PLC and a Cloud Computing Web Application Using LoRa and LoRaWan

1
Department of Computer Science Engineering, SIGL-Lab, ENSA, University Abdelmalek Essaadi, Tetouan 93153, Morocco
2
Department of Electronic Engineering, ETSE, University Valencia, Av. Universitat, 46100 Burjassot, Spain
3
Qatar Scientific Club, Fabrication Lab, Doha 9769, Qatar
4
Department of Señales y Comunicaciones, University of Las Palmas de Gran Canaria, 35001 Las Palmas, Spain
*
Author to whom correspondence should be addressed.
Sensors 2023, 23(5), 2725; https://doi.org/10.3390/s23052725
Submission received: 3 February 2023 / Revised: 23 February 2023 / Accepted: 28 February 2023 / Published: 2 March 2023

Abstract

:
The increasing challenges of agricultural processes and the growing demand for food globally are driving the industrial agriculture sector to adopt the concept of ‘smart farming’. Smart farming systems, with their real-time management and high level of automation, can greatly improve productivity, food safety, and efficiency in the agri-food supply chain. This paper presents a customized smart farming system that uses a low-cost, low-power, and wide-range wireless sensor network based on Internet of Things (IoT) and Long Range (LoRa) technologies. In this system, LoRa connectivity is integrated with existing Programmable Logic Controllers (PLCs), which are commonly used in industry and farming to control multiple processes, devices, and machinery through the Simatic I O T 2040 . The system also includes a newly developed web-based monitoring application hosted on a cloud server, which processes data collected from the farm environment and allows for remote visualization and control of all connected devices. A Telegram bot is included for automated communication with users through this mobile messaging app. The proposed network structure has been tested, and the path loss in the wireless LoRa is evaluated.

1. Introduction

The fourth industrial revolution, commonly known as “Industry 4.0”, has emerged as a hot topic of research and discussion among industry and academia, especially in the fields of management and engineering [1,2]. Industry 4.0 refers to a new industrial paradigm that encompasses various technologies like Artificial Intelligence (AI), Augmented Reality (AR), big data, remote sensing, and the Internet of Things (IoT) that play a crucial role in increasing productivity and reducing costs across different industries including the agricultural sector [3,4,5]. The integration of Industry 4.0 with agriculture has led to the emergence of smart agricultural and farming systems.
In agriculture, relying on traditional farming methods to meet the growing demand for food is no longer sufficient. The production process of planting, sowing, reaping, irrigation and cultivation must now respect certain climatic conditions, such as air temperature, humidity, and precipitation. These conditions affect the spread of pests and diseases, which cause significant losses in global food production [6]. In fact, around 40% of global food production is lost due to pests and diseases infecting the plants [3]. In addition, over-irrigation and leakages in water channels result in the wastage of around 20% of water reserved for agricultural activities due to many reasons such as leakages and line-losses in the waterway channels and the over-irrigation [7].
To address these issues, smart agricultural and farming systems that integrate IoT and communication models are being introduced. These systems automate farm operations in a collaborative and intelligent manner, improving the reliability of crop production management. They provide better control of planting conditions and natural resource utilization without human interaction. The smart farm environment enables decision making by gathering information from different sensors and analyzing it according to needs. The automation of certain processes using IoT sensors, communicating devices, control units, and computers replaces manual work schedules and improves production. As smart farming systems help the interoperability of multiple heterogeneous devices, information sharing and processing is important for controlling the operations of the farm. Multiple sensors are deployed in the smart farm such as humidity and temperature sensors forming a Wireless Sensor Network (WSN). These sensors collect the environment information and send it to the server where data are processed. To deploy a large-scale WSN, Low-Power Wide-Area Network (LPWAN) technologies such as LTE, SigFox and LoRa are better suited due to their wide transmission range, scalability and low power consumption [8,9]. LoRa technology is among the most commonly used technologies in smart farming, owing to its long range and low power consumption, as well as its use of a free-licence band (863 to 870 MHz in Europe) [10] which allows transmitting data over several kilometres in rural areas without expensive infrastructure or cellular connectivity. LoRa devices also have low power requirements, meaning they can operate on battery power for years, making them ideal for remote and hard-to-reach areas of a farm. Additionally, LoRa devices are relatively inexpensive, making them a cost-effective solution for smart farming applications. They are easy to install and configure, and can be integrated with a wide range of sensors and devices.
This paper presents a novel approach to integrating LoRaWAN communication with traditional Programmable Logic Controllers (PLCs), which have long been used in agriculture for automating various processes and controlling machinery. The proposed system facilitates the creation of smart farms by enabling the integration of LoRa connectivity with the existing automated processes that have been in use for decades, without the need for replacing the old control systems. To accomplish this integration, the proposed system employs a LoRa shield on a Simatic I O T 2040 , which communicates with the existing PLC using the Modbus-TCP protocol. The resulting system allows us to control the operation of farming machines like water pumps and collects data from different sensor nodes located throughout the farm. A cloud server is utilized for data processing, offering a secure, flexible, and scalable web-based platform that provides a user-friendly interface for remotely managing all the devices in the smart farm system.
This innovative approach has the potential to significantly benefit the agriculture industry. By incorporating LoRa connectivity into the existing PLCs, the system can leverage previously automated processes and thus reduce the need for expensive replacement of old control systems. The remote management capabilities can help reduce labor costs and increase productivity. In addition, the real-time monitoring of climatic conditions, such as temperature and humidity, can assist in detecting and preventing the spread of pests and diseases, thereby contributing to the overall improvement of global food production.

2. Literature Review

Certainly, recent studies have highlighted the growing interest in using LoRa technology for smart farming applications. Placidi et al. demonstrated in [11] the use of a LoRa-based soil moisture monitoring system for precision agriculture in smart cities. Another study of Boursianis et al. published in [12] investigated the development of a smart irrigation system for precision agriculture based on LoRaWAN technology. Another study presented by Behjati et al. in [13] explored the use of drones towards large-scale livestock monitoring in rural farms. Widianto et al. in [14] presented a Systematic Review of Current Trends in Artificial Intelligence for Smart Farming to Enhance Crop Yield. Jiang et al. [15] proposed a fully customized low-cost and low power smart farming network structure enabled by LoRa and ANT radios. Yoon et al. [16] proposed a smart farm based on LoRa & MQTT. In [17], Escolar et al. proposed a LoRa-based network of energy-harvesting devices for smart farming. Kodali et al. [18] described a smart irrigation system based on LoRa technology. Furthermore Ramli et al. [19] presented an adaptive network mechanism for a smart farm system by using LoRaWAN and IEEE 802.11ac protocols. These studies demonstrate the growing interest in using LoRa technology for smart farming applications and the potential benefits that it can offer.

3. Material, Methods and Experimental Tests

A smart farm can be defined as a new type of automated farming system using IoT infrastructure. Our proposed system consists of four main parts: the end-node sensors, an IoT LoRaWan gateway, the control equipment, a cloud server hosting a web-based platform for control and monitoring, and a bot for a Telegram messaging application in mobile devices. In this section, we present a brief overview of LoRa and LoRaWan, and then we describe the proposed smart farm system.

3.1. LoRa and LoRaWan Overview

LoRa and LoRaWAN are global de facto standards of Low-Power Wide Area Networks (LPWANs), with LoRa being the physical layer and LoRaWAN the Media Access Control (MAC) layer. LoRaWAN is an open specification developed by the LoRa Alliance [20]. LoRa technology is based on Chirp Spread Spectrum (CSS) modulation, which offers high sensitivity for the receiver and robustness against data corruption through the use of forward error correction messages [21]. LoRa uses unlicensed radio spectrum in the Industrial, Scientific, and Medical (ISM) band, specifically the 863–870 MHz range in Europe. The communication range and robustness of LoRa signals are affected by various parameters such as transmission power, Spreading Factor (SF), which is the ratio between the data symbol rate and chirp rate, and Code Rate (CR), which is the forward error correction rate that affects packet transmission airtime and bandwidth [22]. LoRa modulation uses six orthogonal Spreading Factors, ranging from 7 to 12, with a trade-off between a higher data rate and a longer range or lower power consumption. Lower SF results in faster chirps, higher data transmission rates, shorter active times for the radio transceivers, and longer battery life. However, like any technology, LoRa has its disadvantages. One of the main drawbacks is its limited bandwidth, which can result in slow data transfer rates. LoRa’s data rate is also fixed, which can be a problem when trying to transmit large amounts of data. Additionally, LoRa suffers from interference issues, as it operates in an unlicensed spectrum that is shared with other wireless technologies. This can cause communication problems, particularly in urban environments with high levels of radio frequency activity. Table 1 summarizes the pros and cons of the LoRa technology:
The network of LoRa uses encryption, integrity and authentication and it is secured with two security layers [23]:
  • Network layer: an AES-128 secret key named network session key (NwkSKey) is shared between the end-device and the network server for authentication.
  • Application layer: an AES-128 secret key named application session key (AppSKey) protects the payload transmission between end-devices and the application server.
In general, the architecture of a LoRa-based network consists of a hierarchical topology, formed by LoRa nodes, gateways network servers, and application servers. The devices can transmit the data to the gateways which belong to the same LoRaWan network. However, all gateways within the range of a LoRa node can receive messages and the duplications (when existing) will be filtrated in the network server responsible of processing the incoming packets.

3.2. Smart Farm Infrastructure

The proposed smart farm system consists of two main networks as described in Figure 1:
  • The monitoring network (Farm): a wireless network of different LoRa sensors distributed over the farm to collect to the required information such as moisture and airflow sensors.
  • The control network (Warehouse): The reaped vegetables and fruits are stored in the warehouse. Controlling the climatic conditions of this place is a must, thus it is equipped with different environmental sensors (i.e., temperature sensor). The warehouse contains all the control equipment such as air conditioner and irrigation water pump. These devices are controlled with a PLC.
The LoRa sensors scattered in the farm send the sensed information (pH, moisture, air flow, temperature, etc.) to the LoRa gateway. The gateway is connected to the internet and it is responsible for forwarding the sensor data to the cloud server to be further analyzed and stored in the database. The gateway is also responsible of receiving the control commands from the server and forward them to the PLC located in the warehouse. These commands can be manually instructed by the user through the web-based platform or automatically executed if the sensed received data require an action (e.g., the PLC will activate the water pump if the soil needs more water). The automatic commands can be set and configured by the user in the web platform by defining the target device and the threshold values that trigger the actuating device. For better communication coverage, the LoRa gateway should be placed in a high altitude and all the LoRa end-nodes have to be distributed properly.
In IoT, a gateway acts as a bridge between devices and the cloud or server. The gateway is responsible for collecting data from sensors and devices, processing it, and sending it to the cloud or server for storage and analysis. Here are some of the gateway protocols used in IoT such as MQTT, CoAP, HTTP and DDS [24]. In the case of LoRaWan technology, the gateway uses the LoRaWAN protocol, which is responsible for managing the communication between the end devices and the LoRa gateway, as well as providing security, data encryption, and authentication. It also provides the network architecture that enables communication over long distances with minimal power consumption, making it ideal for IoT applications. In order to establish the LoRa communication in our system, we used the ”WiMOD LoRa Lite Gateway“ from IMST. The warehouse contains the PLC to control the devices in the farm such as the water pump. This PLC should be wirelessly connected via LoRa so it can establish a connection with the gateway to receive the commands from the cloud server. To achieve this, we have connected the Simatic I O T 2040 from Siemens [25] to a regular S7 Siemens PLC via Modbus TCP. The LoRa Wimod Arduino shield board from IMST is inserted in the Simatic I O T 2040 as additional communication board, serving as LoRa end-node in the same way as other LoRa end-node sensors in the farm (e.g., Mote II board or custom-made LoRa end-nodes). This solution makes it possible to connect existing PLCs to the LoRa network. The devices used in our test bench are illustrated in Figure 2. The inputs/outputs of the devices of the farm are simulated with the SIMATIC Step7 software and controlled with the S7 Siemens PLC.
The Siemens Simatic I O T 2040 operates with Yocto Linux and it can be easily expanded with Arduino shields in a compact industrial design. The applications can be easily programmed using Node-Red visual programming tool as described in Figure 3a. The WiMOD Shield is a expansion board that enables users of Arduino-compatible boards to use WiMOD radio modules based on LoRa. The Shield includes everything that is needed for connecting a WiMOD module to an Arduino board by using the W i M O D L o R A W A N library. The shield offers two UART connections, able to communicate with the I O T 2040 main board. The LoRa communication shield can be programmed using the Arduino IDE software as described in Figure 3b, and then writing the code directly to the I O T 2040 using a USB cable thanks to the Intel Galileo firmware which should be added to the Arduino IDE first. In the NodeRed dashboard, we have added the “node-red-node-arduino” package in order to read the LoRa payloads exchanged between the I O T 2040 and the gateway through the LoRa shield board. The “node-red-contrib-s7” package is used to read/write commands to the Siemens S7 PLC via Modbus-TCP (any other PLC can also be connected using standard Modbus-TCP wired communication). A part of the Arduino code and the NodeRed scheme of the smart farm are represented in Figure 3.
The PLC in the warehouse controls the following elements:
  • Water pump and associated valves: controls the amount of water needed for irrigation.
  • Air conditioner and fans for ventilation and air quality, maintaining an adequate level of temperature and humidity to preserve food products.
  • Intrusion alarms.
  • Lighting: on/off programming for presence simulation and night activity.
  • LoRa Temperature sensor.
  • LoRa Humidity sensor.
The Siemens S7 PLC is controlled using the I O T 2040 via Modbus-TCP, which also exchanges commands and data with the LoRa gateway. The rest of sensors installed in the farm act as LoRa end-nodes and directly communicate with the LoRa gateway.
In this system, a bot was used to integrate Telegram instant messaging using Telegram Bot API in both the I O T 2040 and the web application. The Telegram bot was made by registering to @ b o t f a t h e r (https://telegram.me/BotFather accessed on 2 February 2023). There are steps that must be completed in @ b o t f a t h e r , such as creating a bot name, bot username, and command with command /newbot. A bot token was used to communicate with our system via Telegram once the bot was created.
The first integration of the Telegram bot with the I O T 2040 was done by installing the NodeRed package “node-red-contrib-telegrambot”. This integration aims to receive direct control commands from users, for example, turning on the lights. The Telegram node was programmed with a JSON code to define several commands and their actions. Thus, the user can send his command via telegram, the I O T 2040 will analyse the request, make it, and send a confirmation message to the user.
The second integration of the Telegram bot is done with the web application described in Section 5 using the Telegram Bot API—PHP SDK [26]. This integration is done using the same token as the I O T 2040 in order to use the same telegram bot for both integrations. The aim of this second integration is to analyse the user requests related to the database (e.g., request the last irrigation water usage, request the time that the lights were switched off, etc.), or the request related to the sensor nodes in order to receive the instant measured value of a sensor without waiting the duty cycle time needed to send the last measured value to the database.
In this work, The Things Network (TTN) is used for LoRaWan communication. The LoRa end-nodes and gateways based on LoRaWan standards can exchange data using the TTN for free since it is an open source infrastructure [27]. Nowadays, many users around the world have registered thousands of gateways in the TTN platform to broaden the network in a collaborative way. The users can connect their IoT LoRa devices to the already existing gateways in the TTN network. Also, establishing a connection with a private server is also possible if a user wants to use his own specific platform.

3.3. Experimental Test

The experimental test was conducted throughout a farmland in Valencia city, Spain. In this test, we used a LoRa Mote II from IMST as end-node, which incorporates an accelerometer, an altimeter, a temperature sensor and a GPS module. The LoRa gateway was located in the balcony of an apartment, in the 6th floor, with an altitude of 24 m, approximately.
The configuration used for the LoRa end-node device was:
  • LoRa Class: Class A
  • Frequency: 867.1–868.5 MHz
  • Bandwidth size: 125 kHz
  • Spreading Factor (SF): 7
  • Coding Rate: fixed = 4/5
  • Transmitting Power: +14 dB
  • Transmitting Antenna gain: +2 dB
  • Receiving Antenna gain: +2 dB
The LoRa end-node was placed in several locations with different distances from the gateway. From each transmit location, 10 messages were exchanged between the end-node and the gateway. The location of the LoRa gateway and the different measurement positions (P1 to P11) are represented in Figure 4. The Spreading Factor (SF) was fixed in 7 in order to reach the maximum distance. However, in similar applications it is preferred not to fix the SF and set Adaptive Data Rate (ADR) mechanism for optimizing data rates, airtime and power consumption, and consequently improve the range and capacity of the network.
The Received Packets Percentage (RPP) was calculated in each location as described in Equation (1), where NACK denotes the number of packets with ‘Acknowledgement’ signal received, and NAP denotes the number of all transmitted packets.
R P P [ % ] = 100 × N A C K N A P
Studying Path Loss (PL) is important because it helps to understand how the strength of a LoRa signal decreases as it travels through the environment. This information is useful for predicting the range of a LoRa network and for designing efficient communication systems. By understanding the factors that contribute to LoRa path loss, such as the type of environment, the distance between the transmitter and receiver, and the frequency of the signal. Modeling the PL predict the reduction in power of a signal as it propagates through a medium, and it can help for better distribution of the end-nodes and identify potential issues with a LoRa network and suggest ways to improve its performance.
The Large-Scale Fading (LSF) is characterized by its Path Loss parameter (PL). The PL has been evaluated in outdoor environments on the basis of the measured RSSI and signal-to-noise ratio (SNR) using Equation (2) [28], where P t is the transmission power G t and G r are the gains of the transmitting and receiving antennas, respectively.
P L = P t + G t + G r + 10 × log 10 ( 1 + 1 S N R ) R S S I
The ratio between the received power P r and the transmitted power P t in a free space environment is given by the Friis law (Equation (3)), where G t and G r are the gains of the transmitter and the receiver, respectively; λ is the wave length, and d is the distance between the receiver and the transmitter.
P r P t = G t G r ( λ 4 π d ) 2
For a non-free space environment, a path loss exponent γ and a reference distance are introduced. Then, Equation (3) becomes Equation (4).
P r P t = G t G r ( λ 4 π ) 2 × 1 d 0 γ × ( d 0 d ) γ
Using the first-order fit [29], PL can be estimated by modelling the experimental PL. Then, the Estimated Path Loss (EPL) can be obtained by Equation (5).
E P L = P L 0 + 10 × γ × l o g 10 ( d d 0 )
The P L 0 in microcellular systems is the PL intercept at a reference distance d 0 , typically ranging from 1 m to 100 m. In this paper, we consider d 0 = 1 m. The path loss exponent γ can be estimated by analyzing the measurement results of the propagation environment. This can be done by fitting a model to the measured data and extracting the relevant parameters, including the path loss exponent. The specific method used may vary based on the type of propagation environment and the information available [30]. Typically, in free-space, gamma is 2. In urban environments, it ranges from 2.7 to 3.5, while in building environments, it can vary from 1.6 to 6 based on building structure, materials, and obstacles [23]. There may be a difference between the actual path loss ( P L ) and estimated path loss ( E P L ) due to shadow fading deviation, as shown in Equation (6). When presenting PL data, there are several statistical measures that can be used to provide a more complete picture of the data. Some of the most commonly used statistical measures include Mean, Standard deviation and Range. The statistical measures and the EPL parameters are represented in Table 2.
σ S F = s t d ( P L E P L )

4. Results and Discussion

In the previous test, measurement points with RPP below 50% are ignored. The Received Signal Strength Indicator (RSSI), the signal-to-noise ratio (SNR) and the percentage of the received packets (RPP) corresponding to each measurement point are represented in Table 3.
The RSSI and SNR variation as a function of the distance are illustrated in Figure 5. As seen, the RSSI decreases as the distance increases. The first packet loss was at position P6 (550 m); from position P5 and above, the RSSI decreased under −90 dBm. Concerning SNR, it followed a similar trend: the SNR value stayed above 0 dB until P9 (720 m) and then, it decreased to −4 dB at P11 (795 m). The lowest rate was registered at P8 (640 m), whereas at P11 (795 m) the received packets reached 60%. This test shows that distances under 500 m can guarantee successful communication between end-nodes and the gateway.
Using the experimentally collected data of Table 3, the PL was calculated using the Equation (2). The results are compared with the Estimated Path Loss (EPL) along with the Free-Space Path Loss (FSPL) model and are illustrated in Figure 6. These results shows he proposed model to estimate the path loss appears to be more valid as the distance increases. For distances shorter than 70m, the proposed model shows instability that mainly return to the shadowing effects [28]. Packets with a PL lower than 126 dB can be received. As would be expected, the free space model FSPL shows the lowest attenuation.
As a result, the PL model parameters are typically only valid in specific environments, frequency ranges, and antenna configurations. Thus, for similar condition to our experimental test, the proposed PL estimation model can be applied in the design of a LoRa mesh network in a farm to improve the energy efficiency and reliability over existing LoRa systems. LoRa is designed to operate at very low power levels, which is one of the reasons why it is able to achieve long-range communication. However, this also means that the signal is more susceptible to interference and noise as it propagates through the environment, which can cause a sudden and significant increase in PL. The LoRa signal may encounter a variety of environmental factors that can cause a sudden increase in path loss, such as obstacles (e.g., buildings, trees) and interference from other wireless devices. These factors can cause the signal to be absorbed, scattered, or reflected in different directions, resulting in a significant increase in PL.
The transmission range of LoRa in agriculture is an important factor to consider when implementing smart farming solutions. The range of LoRa depends on various factors, such as the frequency used, transmission power, terrain, and obstacles present. In general, LoRa has been found to have a transmission range of several kilometers in rural areas and up to several hundred meters in urban environments. This range is suitable for most smart farming applications, which typically cover a large area [31]. However, in some cases, the transmission range of LoRa may need to be extended to cover a larger area. This can be achieved by using multiple LoRa gateways, which act as intermediate nodes between the end devices and the central control system. LoRa gateways can receive and forward messages over long distances, thereby extending the transmission range of the end devices.
Recent studies have demonstrated the potential of LoRa for smart farming [31,32]. These studies have highlighted the use of LoRaWAN for remote monitoring of large agricultural areas [32], as well as the development of systems based on LoRa for monitoring the agricultural sector [33]. Additionally, Semtech’s LoRa technology has been used to show significant improvements in smart agriculture use cases, such as a 50% water savings [34].
In conclusion, LoRa is a promising technology for smart farming applications. It offers long-range, low-power communication that can enable the collection of data from various sensors and devices over a wide area, making it an ideal solution for precision agriculture.

5. Web-Based Monitoring Platform

The presented smart farm system requires a tailored application to customize the control and analysis of data and provide more flexibility in its management. To meet this need, we have developed a personalized web application called ‘Mi granja (My Farm)’, using the Laravel framework [35] for back-end operations and a MySQL database. We decided to implement a relational database due to its ability to provide easier management and maintenance of data quality and integrity over time. This is due to features such as data consistency, query flexibility, transaction support, and scalability, which can be beneficial for the long-term sustainability and robustness of the application. Alternatively, a non-relational database could also be utilized for this purpose. The front-end of the web application is developed using the Bootstrap framework, which implements a responsive design that is supported by multiple screen sizes. The web application allows users to easily access and analyze the data collected by the sensor nodes, as well as remotely control the machines connected to the PLC. It also provides a user-friendly interface for configuring the system settings and defining custom alerts and notifications. The web application is hosted on a cloud server, enabling users to access it from anywhere with an internet connection.
In Laravel, the Model-View-Controller (MVC) architecture is used to separate the application logic from the presentation layer. The work process of the MVC architecture. Routing is the process of accepting a request and directing it to the appropriate controller is described in Figure 7. Route model binding provides a convenient way to automatically inject the model instances directly into your routes. Controllers are responsible for handling user requests and retrieving or storing data in the database through Models which are used also to pass this data off to a view. Implicit route model binding is a smart feature in Laravel that can resolve Eloquent models defined in routes or controller actions and whose values are passed as parameters to controller methods. In this work, the database is running MySQL to store the data in the different tables and the user interface is based on Bootstrap framework and Angular Js that consist of a set of Cascading Style Sheets (CSS) classes and JavaScript functions, providing a responsive design supporting different screen sizes. The interface includes a navigation system and a graphical content displayed in the form of charts and tables to display historical data. The open-source library CanvaJs was used to create the charts. The platform also allow users to export data in different formats for further analysis by off-line software tools.
The LoRa gateway communicates with the TTN server, which will forward the received payloads directly to our cloud server to be stored in the database, so that it can be visualized and monitored from the user interface. The user commands also take the same path: they are transmitted to the TTN server and then forwarded to the LoRa gateway, which will finally communicate with the LoRa end-node. The web application allows different users to create their accounts, each user can register several networks corresponding to his associated farms (multiples farms can be managed from the same web interface), and each network (each farm, in fact) contains a number of connected devices. In order to register a device in the network, the user should register this device in the TTN server first, and then register it in the dashboard page of the web application using its identifier, because all the data go through the TTN LoRaWan network before receiving/sending it to our cloud server.
The home page and dashboard of the web application is illustrated in Figure 8. On the dashboard, the user can define multiple parameters related to each LoRa end-node, such as maximum and minimum values for specific devices. If the received value is outside the defined range, the user will receive an alert notification via email and Telegram. These notification and alert messages can be customized in the dashboard. The data collected by the sensor nodes can be viewed in the form of tables and charts and can be downloaded as an Excel or CSV file for manual and advanced analysis if needed. The web application also has the flexibility to easily add additional features thanks to its MVC design based on the Laravel framework. Overall, the web application provides a comprehensive and user-friendly interface for managing and analyzing the data collected by the smart farm system.
The web application is hosted in a cloud server and its main features are:
  • Scalable design, light weight and fast response.
  • Strong security thanks to the MVC design and authentication system.
  • Multi-device experience: users can access to the web application from various devices.
  • Instant messaging: users receive notifications via email and Telegram.
  • Different charts and graphs for Data visualisation.
  • Organized data storage and easy searching.
  • Export data for advanced analyses as Excel and CSV files.

6. Conclusions

This paper outlines the development of a comprehensive IoT system for a smart farm. The system aims to improve food product storage by monitoring and regulating humidity and temperature levels. It also enables remote monitoring and control of various devices through a web-based application, automating tasks such as irrigation and temperature adjustments.
The developed web application is designed to simplify the process of creating and managing IoT networks. It provides users with the ability to add devices and access to data analysis and downloading features. The use of the MVC design pattern makes the application easy to modify and update, ensuring scalability and the ability to add new features as needed. The responsive design of the app makes it accessible on different screen sizes, ensuring a seamless user experience on any device. The low server resource consumption allows the app to support a large number of concurrent users, making it ideal for managing multiple sensor networks. The introduction of new additions to the traditional LoRa IoT network infrastructure, such as the LoRa link for exchanging data with automation PLCs commonly found in farms and the Telegram link for direct messaging with users via popular messaging apps, further enhances the functionality of the system.
The general illustration of the presented system is described in Figure 9 [3]. The smart agricultural system utilizes LoRa end-node sensors scattered throughout the farm to collect data about the environment. The sensors transmit this data to a LoRaWAN gateway, which then sends it to a cloud server for analysis. The system also includes a Programmable Logic Controller (PLC) that is connected to various machines in the warehouse, such as water pumps and lights. The IoT2040 is connected to the PLC via Modbus-TCP and programmed with Node-RED. Users can access the system through a web-based monitoring application, which allows for remote control of the warehouse machines through the IoT2040. Additionally, users can send commands and requests via a Telegram bot. The cloud server analyzes the received information and stores useful data.
To conclude, the proposed infrastructure represents a smart solution for farmers to integrate the IoT in their already existed farming systems which mainly are relying on a regular PLC. Currently, we are working on the development of some Artificial Intelligence (AI) data analysis tools that can be added to the presented systems for better farm management.

Author Contributions

Conceptualization, M.S., O.A. and A.R.-M.; methodology, M.S., O.A. and A.R.-M.; software, M.S. and M.B.; validation, O.A. and A.R.-M.; formal analysis, M.S., M.B., B.A.A. and I.A.; investigation, M.S.; resources, M.S. and M.B.; data curation, I.A., B.A.A. and J.E.G.; writing—original draft preparation, M.S., O.A. and A.R.-M.; writing—review and editing, M.S., O.A., J.R.-A. and A.R.-M.; visualization, M.Z.C. and J.E.G.; supervision, O.A. and A.R.-M.; project administration, O.A. and A.R.-M. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Not applicable.

Conflicts of Interest

The authors declare no conflict of interest.

Abbreviations

The following abbreviations are used in this manuscript:
PLCProgrammable Logic Controllers
IoTInternet of Things
ARAugmented Reality
AIArtificial Intelligence
WSNWireless Sensor Network
LPWANLow-power wide-area network
CRCode Rate
SFSpreading Factor
CSSChirp Spread Spectrum
NwkSKeyNetwork session key
AppSKeyApplication session key
UARTUniversal asynchronous receiver-transmitter
TTNThe Things Network
ADRAdaptive Data Rate
RPPReceived Packets Percentage
RSSIReceived Signal Strength Indicator
SNRSignal-to-noise ratio
PLPath Loss
EPLEstimated Path Loss
FSPLFree-space Path Loss
LSFLarge-Scale Fading
MVCModel-View-Controller

References

  1. Wang, B. The future of manufacturing: A new perspective. Engineering 2018, 4, 722–728. [Google Scholar] [CrossRef]
  2. Kamble, S.S.; Gunasekaran, A.; Gawankar, S.A. Sustainable Industry 4.0 framework: A systematic literature review identifying the current trends and future perspectives. Process Saf. Environ. Prot. 2018, 117, 408–425. [Google Scholar] [CrossRef]
  3. Saban, M.; Aghzout, O.; Rosado-Muñoz, A. Deployment of a LoRa-based Network and Web Monitoring Application for a Smart Farm. In Proceedings of the 2022 IEEE International Workshop on Metrology for Industry 4.0 & IoT (MetroInd4.0&IoT), Trento, Italy, 7–9 June 2022; pp. 424–427. [Google Scholar] [CrossRef]
  4. Cardillo, E.; Caddemi, A. Feasibility study to preserve the health of an industry 4.0 worker: A radar system for monitoring the sitting-time. In Proceedings of the 2019 II Workshop on Metrology for Industry 4.0 and IoT (MetroInd4. 0&IoT), Naples, Italy, 4–6 June 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 254–258. [Google Scholar]
  5. Pace, P.; Aloi, G.; Gravina, R.; Caliciuri, G.; Fortino, G.; Liotta, A. An edge-based architecture to support efficient applications for healthcare industry 4.0. IEEE Trans. Ind. Infor. 2018, 15, 481–489. [Google Scholar] [CrossRef] [Green Version]
  6. Varandas, L.; Faria, J.; Gaspar, P.D.; Aguiar, M.L. Low-cost IoT remote sensor mesh for large-scale orchard monitorization. J. Sens. Actuator Netw. 2020, 9, 44. [Google Scholar] [CrossRef]
  7. Gondchawar, N.; Kawitkar, R. IoT based smart agriculture. Int. J. Adv. Res. Comput. Commun. Eng. 2016, 5, 838–842. [Google Scholar]
  8. Sanchez-Iborra, R.; Cano, M.D. State of the art in LP-WAN solutions for industrial IoT services. Sensors 2016, 16, 708. [Google Scholar] [CrossRef]
  9. García-García, L.; Jiménez, J.M.; Abdullah, M.T.A.; Lloret, J. Wireless technologies for IoT in smart cities. Netw. Protoc. Algorithms 2018, 10, 23–64. [Google Scholar] [CrossRef] [Green Version]
  10. Ingabire, W.; Larijani, H.; Gibson, R.M.; Qureshi, A.U.H. Outdoor Node Localization Using Random Neural Networks for Large-Scale Urban IoT LoRa Networks. Algorithms 2021, 14, 307. [Google Scholar] [CrossRef]
  11. Placidi, P.; Morbidelli, R.; Fortunati, D.; Papini, N.; Gobbi, F.; Scorzoni, A. Monitoring soil and ambient parameters in the iot precision agriculture scenario: An original modeling approach dedicated to low-cost soil water content sensors. Sensors 2021, 21, 5110. [Google Scholar] [CrossRef] [PubMed]
  12. Boursianis, A.D.; Papadopoulou, M.S.; Gotsis, A.; Wan, S.; Sarigiannidis, P.; Nikolaidis, S.; Goudos, S.K. Smart irrigation system for precision agriculture—The AREThOU5A IoT platform. IEEE Sensors J. 2020, 21, 17539–17547. [Google Scholar] [CrossRef]
  13. Behjati, M.; Mohd Noh, A.B.; Alobaidy, H.A.; Zulkifley, M.A.; Nordin, R.; Abdullah, N.F. LoRa communications as an enabler for internet of drones towards large-scale livestock monitoring in rural farms. Sensors 2021, 21, 5044. [Google Scholar] [CrossRef] [PubMed]
  14. Widianto, M.H.; Ardimansyah, M.I.; Pohan, H.I.; Hermanus, D.R. A Systematic Review of Current Trends in Artificial Intelligence for Smart Farming to Enhance Crop Yield. J. Robot. Control. (JRC) 2022, 3, 269–278. [Google Scholar] [CrossRef]
  15. Jiang, X.; Waimin, J.F.; Jiang, H.; Mousoulis, C.; Raghunathan, N.; Rahimi, R.; Peroulis, D. Wireless Sensor Network Utilizing Flexible Nitrate Sensors for Smart Farming. In Proceedings of the 2019 IEEE Sensors, Sophia Antipolis, France, 11–13 March 2019; pp. 1–4. [Google Scholar] [CrossRef]
  16. Yoon, H.W.; Kim, D.J.; Lee, M.; Weon, C.; Smith, A. L & M Farm: A Smart Farm based on LoRa & MQTT. In Proceedings of the 2020 International Conference on Omni-Layer Intelligent Systems (COINS), Barcelona, Spain, 31 August–2 September 2020; pp. 1–6. [Google Scholar] [CrossRef]
  17. Escolar, S.; Rincón, F.; del Toro, X.; Barba, J.; Villanueva, F.J.; Santofimia, M.J.; Villa, D.; López, J.C. The PLATINO Experience: A LoRa-based Network of Energy-Harvesting Devices for Smart Farming. In Proceedings of the 2019 XXXIV Conference on Design of Circuits and Integrated Systems (DCIS), Bilbao, Spain, 20–22 November 2019; pp. 1–6. [Google Scholar] [CrossRef]
  18. Kodali, R.K.; Kuthada, M.S.; Yogi Borra, Y.K. LoRa Based Smart Irrigation System. In Proceedings of the 2018 4th International Conference on Computing Communication and Automation (ICCCA), Greater Noida, India, 14–15 December 2018; pp. 1–5. [Google Scholar] [CrossRef]
  19. Ramli, M.R.; Daely, P.T.; Kim, D.S.; Lee, J.M. IoT-based adaptive network mechanism for reliable smart farm system. Comput. Electron. Agric. 2020, 170, 105287. [Google Scholar] [CrossRef]
  20. Vangelista12, L.; Zanella, A.; Zorzi12, M. Long-range IoT technologies: The dawn of LoRa TM. In Proceedings of the 2015 1st EAI International Conference on Future Access Enablers of Ubiquitous and Intelligent Infrastructures (EAI), Ohrid, North Macedonia, 23–25 September 2015. [Google Scholar]
  21. Guibene, W.; Nowack, J.; Chalikias, N.; Fitzgibbon, K.; Kelly, M.; Prendergast, D. Evaluation of LPWAN technologies for smart cities: River monitoring use-case. In Proceedings of the 2017 IEEE Wireless Communications and Networking Conference Workshops (WCNCW), San Francisco, CA, USA, 19–22 March 2017; IEEE: Piscataway, NJ, USA, 2017; pp. 1–5. [Google Scholar]
  22. Saban, M.; Aghzout, O.; Medus, L.D.; Rosado, A. Experimental Analysis of IoT Networks Based on LoRa/LoRaWAN under Indoor and Outdoor Environments: Performance and Limitations. In Proceedings of the 4th IFAC Conference on Embedded Systems, Computational Intelligence and Telematics in Control CESCIT 2021, Valenciennes, France, 5–7 July 2021; IFAC-PapersOnLine. Volume 54, pp. 159–164. [Google Scholar] [CrossRef]
  23. Saban, M.; Casans-Berga, S.; García-Gil, R.; Navarro-Antón, A.E.; Aghzout, O.; Rosado-Muñoz, A. Sensing Wood Moisture in Heritage and Wooden Buildings: A New Sensing Unit with an Integrated LoRa-based Monitoring System. IEEE Internet Things J. 2022, 9, 25409–25423. [Google Scholar] [CrossRef]
  24. Ramírez, P.L.G.; Taha, M.; Lloret, J.; Tomás, J. An intelligent algorithm for resource sharing and self-management of wireless-IoT-gateway. IEEE Access 2019, 8, 3159–3170. [Google Scholar] [CrossRef]
  25. Siemens. SIMATIC IOT2000. Available online: https://new.siemens.com/global/en/products/automation/pc-based/iot-gateways/iot2000.html (accessed on 10 November 2022).
  26. API, T.B. Telegram Bot SDK. Available online: https://telegram-bot-sdk.readme.io/docs (accessed on 29 December 2022).
  27. Barro, P.A.; Zennaro, M.; Pietrosemoli, E. TLTN—The local things network: On the design of a LoRaWAN gateway with autonomous servers for disconnected communities. In Proceedings of the 2019 Wireless Days (WD), Manchester, UK, 24–26 April 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 1–4. [Google Scholar]
  28. Bianco, G.M.; Giuliano, R.; Marrocco, G.; Mazzenga, F.; Mejia-Aguilar, A. LoRa System for Search and Rescue: Path-Loss Models and Procedures in Mountain Scenarios. IEEE Internet Things J. 2020, 8, 1985–1999. [Google Scholar] [CrossRef]
  29. Ameloot, T.; Van Torre, P.; Rogier, H. Indoor body-to-body LoRa link characterization. In Proceedings of the 2019 IEEE-APS Topical Conference on Antennas and Propagation in Wireless Communications (APWC), Granada, Spain, 9–13 September 2019; IEEE: Piscataway, NJ, USA, 2019; pp. 042–047. [Google Scholar]
  30. Wojcicki, P.; Zientarski, T.; Charytanowicz, M.; Lukasik, E. Estimation of the Path-Loss Exponent by Bayesian Filtering Method. Sensors 2021, 21, 1934. [Google Scholar] [CrossRef] [PubMed]
  31. Pagano, A.; Croce, D.; Tinnirello, I.; Vitale, G. A Survey on LoRa for Smart Agriculture: Current Trends and Future Perspectives. IEEE Internet Things J. 2023, 10, 3664–3679. [Google Scholar] [CrossRef]
  32. Ahmed, M.A.; Gallardo, J.L.; Zuniga, M.D.; Pedraza, M.A.; Carvajal, G.; Jara, N.; Carvajal, R. LoRa Based IoT Platform for Remote Monitoring of Large-Scale Agriculture Farms in Chile. Sensors 2022, 22, 2824. [Google Scholar] [CrossRef] [PubMed]
  33. Rivera Guzmán, E.F.; Mañay Chochos, E.D.; Chiliquinga Malliquinga, M.D.; Baldeón Egas, P.F.; Toasa Guachi, R.M. LoRa Network-Based System for Monitoring the Agricultural Sector in Andean Areas: Case Study Ecuador. Sensors 2022, 22, 6743. [Google Scholar] [CrossRef] [PubMed]
  34. Semtech. Smart Agriculture with LoRa Technology. Available online: https://www.semtech.com/lora/lora-applications/smart-agriculture (accessed on 22 February 2023).
  35. Olanrewaju, R.F.; Islam, T.; Ali, N. An empirical study of the evolution of php mvc framework. In Advanced Computer and Communication Engineering Technology; Springer: Berlin/Heidelberg, Germany, 2015; pp. 399–410. [Google Scholar]
Figure 1. Smart farm system architecture overview. The farm is connected to a LoRa gateway which exchanges data with users via a cloud server.
Figure 1. Smart farm system architecture overview. The farm is connected to a LoRa gateway which exchanges data with users via a cloud server.
Sensors 23 02725 g001
Figure 2. Siemens S7 PLC connected to Siemens Simatic I O T 2040 incorporating the Wimod LoRa shield. The LoRa gateway is powered and connected to the internet. The inputs/outputs of the different devices in the farm are simulated with the Simatic Step7 software and controlled with the S7 Siemens PLC.
Figure 2. Siemens S7 PLC connected to Siemens Simatic I O T 2040 incorporating the Wimod LoRa shield. The LoRa gateway is powered and connected to the internet. The inputs/outputs of the different devices in the farm are simulated with the Simatic Step7 software and controlled with the S7 Siemens PLC.
Sensors 23 02725 g002
Figure 3. (a) NodeRed dashboard, it provides a browser-based editor that makes it easy to wire together flows using the nodes. (b) a part of the code used to program the LoRaWan communication of the SIMATIC IoT2040.
Figure 3. (a) NodeRed dashboard, it provides a browser-based editor that makes it easy to wire together flows using the nodes. (b) a part of the code used to program the LoRaWan communication of the SIMATIC IoT2040.
Sensors 23 02725 g003
Figure 4. Experimental setup for outdoor LoRa communication test. (a) P1 to P14 represent the measurement locations, G represent the gateway location. (b) LoRa Mote II used as LoRa end-node.
Figure 4. Experimental setup for outdoor LoRa communication test. (a) P1 to P14 represent the measurement locations, G represent the gateway location. (b) LoRa Mote II used as LoRa end-node.
Sensors 23 02725 g004
Figure 5. LoRa communication values in outdoor testing: Average RSSI [dBm] and Average SNR [dB] as a function of distance [m].
Figure 5. LoRa communication values in outdoor testing: Average RSSI [dBm] and Average SNR [dB] as a function of distance [m].
Sensors 23 02725 g005
Figure 6. Estimated and measured PL compared with the FS model in the farm environment.
Figure 6. Estimated and measured PL compared with the FS model in the farm environment.
Sensors 23 02725 g006
Figure 7. The architecture of the web monitoring platform illustrates the flow of actions from the user’s request to the point of receiving the response.
Figure 7. The architecture of the web monitoring platform illustrates the flow of actions from the user’s request to the point of receiving the response.
Sensors 23 02725 g007
Figure 8. Screenshot from the web application “Mi Granja” showing the dashboard page and relevant data of a temperature sensor.
Figure 8. Screenshot from the web application “Mi Granja” showing the dashboard page and relevant data of a temperature sensor.
Sensors 23 02725 g008
Figure 9. Illustration of the smart farming application. The proposed IoT system integrates different devices and technologies: PLC controllers and LoRa nodes connected via a gateway. The gateway forward and receive data from the cloud server that hosts the web application.
Figure 9. Illustration of the smart farming application. The proposed IoT system integrates different devices and technologies: PLC controllers and LoRa nodes connected via a gateway. The gateway forward and receive data from the cloud server that hosts the web application.
Sensors 23 02725 g009
Table 1. The pros and cons of of implementing LoRa and LoRaWAN technologies.
Table 1. The pros and cons of of implementing LoRa and LoRaWAN technologies.
ProsCons
Long rangeLow data transfer rate
Low power consumptionLimited capacity
Low costInterference (unlicensed frequency band)
SecurityCentralized architecture
Scalability and flexibilityHigh latency
Table 2. Lognormal PL Model parameters in the outdoor environment and statistical measures.
Table 2. Lognormal PL Model parameters in the outdoor environment and statistical measures.
EPL exponent ( γ )2.9
EPL intercept (PL( d 0 ))36.34 dB
Standard deviation ( σ S F )6
Standard error of the mean (SEM)1.81
Range71.29 dB
Table 3. SNR, RSSI and RPP of received packets from each measurement point.
Table 3. SNR, RSSI and RPP of received packets from each measurement point.
LocationsDistance (m)RSSI (dBm)SNR (dB)RPP (%)
P150−369100
P2120−805.2100
P3200−707.4100
P4290−769100
P5415−905100
P6550−100690
P7580−95480
P8640−110250
P9720−105−260
P10755−98−270
P11795−109−460
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Saban, M.; Bekkour, M.; Amdaouch, I.; El Gueri, J.; Ait Ahmed, B.; Chaari, M.Z.; Ruiz-Alzola, J.; Rosado-Muñoz, A.; Aghzout, O. A Smart Agricultural System Based on PLC and a Cloud Computing Web Application Using LoRa and LoRaWan. Sensors 2023, 23, 2725. https://doi.org/10.3390/s23052725

AMA Style

Saban M, Bekkour M, Amdaouch I, El Gueri J, Ait Ahmed B, Chaari MZ, Ruiz-Alzola J, Rosado-Muñoz A, Aghzout O. A Smart Agricultural System Based on PLC and a Cloud Computing Web Application Using LoRa and LoRaWan. Sensors. 2023; 23(5):2725. https://doi.org/10.3390/s23052725

Chicago/Turabian Style

Saban, Mohamed, Mostapha Bekkour, Ibtisam Amdaouch, Jaouad El Gueri, Badiaa Ait Ahmed, Mohamed Zied Chaari, Juan Ruiz-Alzola, Alfredo Rosado-Muñoz, and Otman Aghzout. 2023. "A Smart Agricultural System Based on PLC and a Cloud Computing Web Application Using LoRa and LoRaWan" Sensors 23, no. 5: 2725. https://doi.org/10.3390/s23052725

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop