Notre Dame University - Louaize: Faculty of Engineering Department of Electrical, Computer, and Communication Engineering

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Notre Dame University – Louaize

Faculty of Engineering

Department of Electrical, Computer, and Communication


Engineering

Senior Project

AgroVue

Prepared by:

Charbel Sina Rahme

Karina Jaalouk

Thomas Souaid

Advised by:

Dr. Nassar Mendalek, PhD

Fall 2022
AgroVue

A Senior Project Report

Presented in Partial Fulfillment of the Requirements for

the Degree Bachelor of Engineering in the

Faculty of Engineering of Notre Dame University

By:

Charbel Sina Rahme

Karina Jaalouk

Thomas Souaid

Notre Dame University


Fall 2022

Notre Dame University

Fall 2022

Advised by:
Committee Member
Dr. Nassar Mendalek
Dr. Elias Nassar
Department of Electrical, Computer,
Department of Electrical, Computer,
and Communication Engineering
and Communication Engineering
ii

Disclaimer

This report is prepared by students of the Faculty of Engineering at Notre Dame University – Louaize, who are
the sole responsible for the integrity of its content. The advisor and committee member act only in an advisory
capacity and cannot be held responsible, under any circumstances, for any eventual misuse or violation of
intellectual property laws.
ii

Abstract

Digital transformation is speeding up the capacity for physical and organizational

limitations to be gone to draw in a continuous real-time labor force, connect groups, and make

collaboration. It drives interest in technologies to better monitor, control, and protect against

failures, guarantee product satisfaction, increase productivity, and security, and upskill staff

while utilizing improved cybersecurity architectures.

To meet these priorities, we must keep advancing industries' digital transformation and

deploy these key technologies, using a shared digital awareness that enables these key

technologies to improve responsiveness, reliability, and productivity. Lately, remote, and

automated operations are becoming autonomous and the new normal. All of these can either

enter the mainstream or -if it exists- keep gaining acceptance. All connect to the overall

digital transformation of the agriculture industry. Our goal is to improve the agriculture

industry through technology to develop upon the needs generated for farmers to succeed on a

planet where great conviction is uncertainty.


iii

Acknowledgments

We wish to thank Dr. Nassar Mendalek and Dr. Elias Nassar for their valuable insight

and guidance regarding the technical content and formatting requirements of our senior project

report.

We would also like to thank Dr. Lara Khabaz for her assistance in the preparation of the

marketing and business needs used in this report.

A special word of thanks goes to the Faculty of Engineering at Notre Dame University

for the effort and dedication it has invested in us in order to provide us with the knowledge and

background necessary to lead a successful engineering career.


iv

Table Of Contents

Abstract ...................................................................................................................................... ii
Table Of Contents ..................................................................................................................... iv
List Of Figures .......................................................................................................................... vi
List Of Tables .......................................................................................................................... vii
Chapter 1 – Introduction ............................................................................................................ 1
1.1. Problem Statement ...................................................................................................... 1

1.2. Project Needs and Objective Statements ..................................................................... 2

1.2.1. Needs Statement................................................................................................... 2

1.2.2. Objective Statement ............................................................................................. 3

1.3. Knowledge and Skills.................................................................................................. 4

Chapter 2 - Standards, Constraints, And Requirements Specification ...................................... 5


2.1. Relevant Engineering Standards .................................................................................... 5

2.2 Relevant Realistic Constraints .................................................................................... 5

2.2.1. Economic Restrictions ............................................................................................ 5

2.2.2. Environmental Constraints...................................................................................... 5

2.2.3. Health And Safety Constraints................................................................................ 6

2.2.4. Manufacturing Constraints...................................................................................... 6

2.2.5. Sustainability Constraints ....................................................................................... 6

2.3. Requirements Specifications .......................................................................................... 6

Chapter 3 – Functional Decomposition ..................................................................................... 8


3.1. Functional Decomposition Level 0 ................................................................................ 8

3.2. Functional Decomposition Level 1 .............................................................................. 10

3.3. Functional Decomposition Level 2 .............................................................................. 11

3.4. Functional Decomposition Level 3 .............................................................................. 13

3.4.1. Soil Monitoring Node ........................................................................................... 13

3.4.2. Water Management And Indoor Monitoring Node .............................................. 14

3.4.3. Data Link .............................................................................................................. 16


v

3.4.4. Dashboard ............................................................................................................. 17

Chapter 4 – Project Management ............................................................................................. 24


4. 1. Gantt Chart ................................................................................................................... 24

4.2. Cost Analysis ............................................................................................................... 25

Chapter 5 – Software Implementation ..................................................................................... 28


5.1. ESP32 Node .................................................................................................................. 28

5.1.1. Libraries ................................................................................................................. 28

5.1.2. Setup ...................................................................................................................... 28

5.1.3. Loop ....................................................................................................................... 28

5.1.4. Connecting to Wi-Fi and ThingsBoard .................................................................. 29

5.1.5. Sensor Readings and Transmitting Data ................................................................ 29

5.1.6. Receiving LoRa values and Transmitting Data ..................................................... 29

5.1.7. IR Sensor and LED Screen .................................................................................... 29

5.2. Arduino Node................................................................................................................ 29

5.2.1. Libraries ................................................................................................................. 30

5.2.2. Setup ...................................................................................................................... 30

5.2.3. Loop ....................................................................................................................... 30

5.2.4. Sensor Readings and Transmitting through LoRa ................................................. 30

Chapter 6 – Result And Conclusion......................................................................................... 31


6.1. Conclusion .................................................................................................................... 31

6.2. Future Work .................................................................................................................. 31

References ................................................................................................................................ 33
vi

List Of Figures

Figure 1. Functional Decomposition Level 0............................................................................ 8

Figure 2. Functional Decomposition Level 1.......................................................................... 10

Figure 3. Functional Decomposition Level 2.......................................................................... 11

Figure 4. Soil Monitoring Circuit ........................................................................................... 13

Figure 5. Water Management and Indoor Monitoring Circuit ................................................ 15

Figure 6. LoRaWAN Protocol Stack [14] ............................................................................... 16

Figure 7. Flowchart of The Monitoring and Graphing System............................................... 19

Figure 8. Flowchart of the Valve Function ............................................................................. 21

Figure 9. Flowchart of the Alert System ................................................................................. 22

Figure 10. Dashboard .............................................................................................................. 23

Figure 11. Gantt Chart 1 ......................................................................................................... 24

Figure 12. Gantt Chart 2 ......................................................................................................... 25


vii

List Of Tables

Table 1. Engineering Requirements .......................................................................................... 6

Table 2. Functional Decomposition Level 0 ............................................................................. 9

Table 3. Cost Analysis ............................................................................................................ 26


1

Chapter 1 – Introduction

To identify our project concept, we collected information about technology agriculture

through extensive internet searching alongside retrieval of Journal and Conference papers

from IEEE. Furthermore, we inducted a site survey that provided valuable insights into the

main challenges that commercial greenhouse agriculture faces. For example, fertilization

alongside pest control and disease management are applicable to maintain the health of the

crops. Weather monitoring conditions are vital to adjust to and protect the crops, where

remarkably high and low temperatures are translated into a significant presence of diseases

and death to plants from frost bites of the wintry weather and the reduction of the absorption

level of water to nutrients from the ground due to the hot weather. Also, the soil type is

identified and maintained to improve the crop outcome. Therefore, crops are affected by

those properties, and technology applications can improve those conditions.

In this chapter, the problem, needs and objective statements are presented that lead to

the understanding of our topic of choice. Moreover, the skills required and acquired during

the project preparation is included.

1.1. Problem Statement

Medium to large-scale commercial greenhouse agriculture in industry encounters

unpredictable weather conditions, thus farmers collect data manually, which is inefficient,

inconsistent, and imprecise. What is not measured cannot be improved.


2

1.2. Project Needs and Objective Statements

1.2.1. Needs Statement

The planet generates enough food to feed its entire population. However, not everyone

has consistent access to appropriate nourishment. It is a matter of waste. According to

Deloitte, over 30% of the food produced is discarded between harvest and consumption in

our present supply chain for food production [4]. Moreover, by 2025, the world’s

population is predicted to be living in cities due to continued population growth and

urbanization [16]. Not only is the land being compromised but also the negative effects of

climate change are directly impacting farmers. Crop output is being influenced by elevated

temperatures interrupting growth and causing quality and waste to deteriorate [16]. A

system is needed to control green houses to boost production per area of land and

production efficiency per agricultural worker.

To use data acquired through digital transformation, farmers must focus on their

methods to provide and utilize information. The data visualization hardware and software

used applications are suitable for many tasks. However, within a connected digital

enterprise, additional visualization tools are needed to accommodate unique requirements

of all roles, especially remote labor [8].

Farmers and their supply chain demands face risk and operational interruption as they

struggle to minimize their dependence upon suppliers. Due to the inability to fulfill the

high request of consumers, the pandemic further revealed supply chain flaws and

vulnerabilities. Farmers realize that traditional ways are inadequate to compete today, and
3

there is a real need to shift to more adapted, agile, and intelligent tools that are digitally

enabled.

1.2.2. Objective Statement

The objective of this project is to design and prototype a system that can control

agricultural environments and improve visual production. In a controlled environment,

producing crops in greenhouses can be strictly controlled to minimize waste and boost

productivity. The system will regulate and manage the following:

• Temperature, Air humidity

• Soil Moisture

• Soil Temperature

All the above is monitored through a remote device to become labor-saving and time

efficient. A valve will be placed on the water tank so that the farmer can control remotely

the water being delivered to the crops as the user sees fit.

When linked with IoT and analytics, visualization tools will offer the potential to

provide users with immersive practices, real-time contextualized data, and role-associated

data to help users execute their regular tasks instantly, precisely, and successfully. It can

improve the user experience and alter the customer interaction standard to enhance the way

farmers grow, operate, and maintain their crops.


4

1.3. Knowledge and Skills

Following the completion of this project, we will acquire knowledge in systems

implementation, integration and maintenance. Collection of data from various levels of low

current systems (sensors, actuator, etc.). Further knowledge is acquired in software

algorithms developments and design through machine learning, Internet of Things and

cloud computing.

Other soft skills will be acquired from team player, leadership, time management,

problem-solving, adaptability, innovation, and project management (Gantt chart).

The gain from the overall experience is teaching us the importance of product

management from creation to design and implementation, and testing aligned with clarity

of mission and vision, which will boost our career development.


5

Chapter 2 - Standards, Constraints, And Requirements Specification

2.1. Relevant Engineering Standards

The LoRa communication network protocol follows the regional standards parameters

listed by The lora alliance (an open association of collaborating members) non-profit

organization that regulates it. The frequency range parameters for Lebanon is from 862-

870 MHz to 863-87 MHz. [13].

2.2 Relevant Realistic Constraints

2.2.1. Economic Restrictions

Major backfire on local component market supply. Its cause is due to an unprecedented

economic crisis. The project scope is revised recurringly to meet minimum requirement

compliance.

2.2.2. Environmental Constraints

The project being carried out in a greenhouse is vulnerable to uncontrollable external

elements like direct sunshine, wind, temperature, etc., which may cause reading

fluctuations. There is no access to internet infrastructure near the greenhouse because of

its distant location. As a result, the gateway won't have access to WiFi or a power source,

which prevents it from connecting with the cloud network.


6

2.2.3. Health And Safety Constraints

Having one of the wireless nodes positioned right adjacent to the irrigation system might

pose a safety and electrical threat in the event of water leaks and the exposure of electronic

equipment to water.

2.2.4. Manufacturing Constraints

Global electronic components shortage impacts microcontroller model selection and

availability. The camera selected in our scope of work is only compatible with Raspberry

Pi microcontroller.

2.2.5. Sustainability Constraints

Due to the nature of all electrical components and the unpredictability of their life

duration, some materials and batteries utilized may be subject to sustainability constraints.

2.3. Requirements Specifications

Engineering and marketing requirements assigned for the project is shown in the table

below.

Table 1. Engineering Requirements

Marketing Engineering
Justification
Requirements Requirements
1, 2, 4, 6 The tolerance of every Based upon hardware benchmarking
sensor should not exceed a specifications, sensors have up to ± 2%
5% margin. error margin. Also, external factors such
as the weather (direct sunlight, wind
etc...) will create reading fluctuations.

1-5, 9 Interface: Dashboard This module will provide a direct


interface for the farmer to monitor and
control the crops. It will provide
notifications in case of drastic shift in
values. An error message will be
7

displayed in case a sensor is not


available or present.

7 Web Interface: Weather This module will provide a direct


forecast weather interface for the farmer like
weather temperatures and wind speed.

3 ML1 algorithms: soil Using the application result, the


properties and crop yield identification of nutrient status and crop
prediction. health monitoring could yield
estimation for individual farms. Alerts
will be provided in case of a drastic shift
in the dashboard results and shifts in
optimal values for the crops.

8, 9 Screen; LED screen on- The need to have an on-site monitor is


site crucial for efficiency of the farmer. The
humidity and temperature of the
greenhouse will be displayed. Also, it
can be used as maintenance guidance
and checks for technical issues on the
dashboard to keep the system available
and in optimum productivity.

Marketing Requirements
1. Data Analytics To Prevent Excess Fertilization And Irrigation
2. Operate & Maintain Ideal Microclimate Control
3. Avoid Diseases
4. Minimize Manual Intervention
5. Visualizing Representation
6. Minimize Costs And Increase Return On Investment
7. Provide Real-Time External Weather Interface
8. On Site Monitoring
9. Maintenance And System Availability

1
Machine Learning
8

Chapter 3 – Functional Decomposition

3.1. Functional Decomposition Level 0

A greenhouse can be modeled as a complex multi-input and multi-output (MIMO)

system that is highly nonlinear and strongly coupled, influenced by the outside weather

[11]. The basic set of variables that characterize the internal climate is the air temperature,

air humidity, and soil measurements [11]. Identifying them as process outputs, consider

the schematic representation of the greenhouse shown in Figure 1.

Figure 1. Functional Decomposition Level 0

Inputs:

• T; internal temperature

• H; internal humidity

• ST; soil temperature


9

• SM; soil moisture

• MS; motion sensor

• WVC; water valve control

• WFI; weather forecast interface

Outputs:

• IV; internal values/ dashboard

• CA; crop health alerts

• SC; LED screen

• WV; water valve

Table 2. Functional Decomposition Level 0

Module AgroVue
Inputs • Sensors: temperature, humidity, soil moisture, soil temperature
• Water station: actuator valve control
• Motion sensor

Outputs • Water valve status


• Crop Health Alerts
• Analytical Dashboard (internal values)
• LED screen
Functionality Using these sensors and the weather forecast interface, the analytical
dashboard will be produced and displayed. The dashboard will also
provide alerts for abnormal shifts in values. A solenoid valve will be
placed in the water tank to control the irrigation of the crops, upon the
farmer’s preference. A separate LED screen will be present inside the
greenhouse for monitoring the internal temperature and humidity of
the greenhouse.
10

3.2. Functional Decomposition Level 1

Figure 2. Functional Decomposition Level 1

The project architecture is divided into three vertical tiers, as shown in the figure 2

above. The sensors and actuators in the first left layer interact wirelessly with each other

through LoRa wireless communication modules. It breaks down into two nodes: the first

is soil sensors and the second is a weather and water management system.

The second tier is the gateway and the cloud network layer, which is in charge of

sending, receiving, and storing data from end nodes.

The third tier is the application and user layer, which allows the end user to visualize

real-time data, control the actuator, and check the weather forecast.

In addition to traditional methods of collecting data through sensors. Our system design

enables the farmer to download an application on his mobile device, such as Plantix, which
11

is based on deep learning and identifies probable faults and nutrient deficits in the soil. The

recognized image may be integrated into the dashboard we're using through API. Other

techniques include capturing a regular photo and showing it on your dashboard via a cloud-

based shared folder.

3.3. Functional Decomposition Level 2

Figure 3. Functional Decomposition Level 2

All nodes feature a LoRa wireless module transceiver, and an antenna interfaced with

all two microcontrollers, allowing the ESP microcontroller and the gateway to

communicate wirelessly. In addition, all the nodes and gateway have a power operation of

around 3.3V and 5.5 V and are power supplied by a 12 V battery.

The soil monitoring node consists of four moisture sensors, four soil temperature

sensors, a ESP32 microcontroller, a LoRa wireless module transceiver, and an antenna.


12

The four moisture sensors are linked to the microcontroller, and their average is shown

on the dashboard. The soil temperature sensors are connected to one pin of the

microcontroller. Both types of sensors are placed in the soil near the plant's roots to get the

desired reading.

The water management and indoor monitoring node consist of a temperature and

humidity sensor, LED screen, motion sensor, solenoid valve, an Arduino pro mini, a LoRa

wireless module transceiver, and an antenna. The temperature and humidity sensor are

connected to the microcontroller and their reading values are shown on the dashboard. The

motion sensor and the LED screen are connected to the microcontroller, so when the

motion sensor detects movement in the greenhouse the LED screen will turn on, to reduce

power consumption, and the user can check or detect any fluctuations between on-site

nodes and dashboard. The solenoid valve actuator is connected to the same microcontroller.

The LoRa transceivers will communicate with each other and send the sensor values to

the ESP microcontroller. This microcontroller will communicate with a gateway that is

located in a distant location from the greenhouse. It will ensure that the microcontrollers

with the LoRa wireless module transceiver and antennas will manage to connect to a

network service provider.

The dashboard connect to the network service provider and manage two-way

communication with sensors and the actuator. It will display the values of the sensors

mentioned above as well as control the solenoid valve.


13

3.4. Functional Decomposition Level 3

3.4.1. Soil Monitoring Node

In this circuit, an Arduino Pro Mini is being used to monitor the soil moisture and

temperature. It also includes the LoRa transmitter and its antenna. The TX, RX, VCC,

ground pins, and antenna connection are all connected similarly to the camera node.

Moreover, the enable or auxiliary pin is connected to the ground, between two resistors for

safety reasons.

Figure 4. Soil Monitoring Circuit

Four soil moisture sensors are used, and the ground pin of each one is connected to the

ground of the microcontroller, consequently, the VCC of each one is connected to the

power supply. This sensor consists of three pins; the third pin of each sensor is connected
14

to an analog input of the microcontroller. The analog inputs used, in our case, are A0, A1,

A2, and A3.

Four soil temperature sensors are used each with three pins, same as the soil moisture

sensors. The ground pin is connected to the microcontroller's ground, As a result, the VCC

of each is linked to the power supply. While the third pin of each is linked to a 4.7-ohm

resistor, which is coupled to an Arduino Pro Mini digital pin, D9.

3.4.2. Water Management And Indoor Monitoring Node

The first part, the interior monitoring node, consists of a humidity and temperature

sensor as well as an LED screen. All three components of this section will have their ground

pin linked to the microcontroller's ground, and therefore their VCC pins will be connected

to the power supply. The temperature and humidity sensor has three pins, one of which

will be attached to a digital pin on the microcontroller, D1. The LED screen has four pins,

with pins 1 and 2 each linked to a separate analog pin and digital pin, A0 and D0,

respectively. The IR senor’s 3rd pin is connected to the S3 pin of the ESP8266.
15

Figure 5. Water Management and Indoor Monitoring Circuit

The second part is the water management circuit. It consists of a solenoid valve and its

relay. The solenoid valve needs around 12 volts to operate, hence, the separate 12V power

and the relay. For the solenoid valve to properly work, its ground pin will be connected to

the 12V power supply’s ground and its 2nd pin, VCC, will be connected to the 2nd pin of

the relay. Additionally, the 5th and 6th pins of the relay are the ground and VCC pins; the

VCC pin will be connected to the power supply of the circuit, while the ground pin will be

connected to the ground. Finally, the input pin of the relay, the 4th pin, will be connected

to a digital pin, D2, on the ESP8266. The power supply will be connected to the 1st spin of

the relay, N0. This will ensure that the valve will get the proper voltage needed to operate

smoothly and it does not disrupt the 3.3-5 V operating power of the microcontroller.
16

3.4.3. Data Link

The two end nodes will communicate through the LoRa topology. LoRa operates in the

ISM band and is a spread-spectrum modulation technique. LoRa is derived from Chirp

Spread Spectrum (CSS) technology. Chirp stands for Compressed High intensity Radar

Pulse. A chirp is a ramp from minimal to maximal (up-chirp) or from maximal to minimal

frequency (down-chirp) [10]. LoRa’s CSS technology is energy-efficient, robust and serves

long ranges.

Figure 6. LoRaWAN Protocol Stack [14]

LoRa is working in half duplex mode, which means sending and listening

simultaneously is not possible [17]. Thus, LoRa uses separate messages for sending and

receiving data, namely uplink and downlink messages. Therefore, the node with the

Arduino Pro mini will be the node sending data and the node with the ESP8266 will receive

the data. Via a radio frequency transmitter radio waves are emitted, in our case 868 MHz.

When all the data is transmitted and located and ESP node, the ESP8266 NodeMCU

will be able to connect to Wi-Fi via 2.4 GHz. This will secure a safe and reliable connection

from our end nodes to the Internet. The NodeMCU offers a variety of development

environments, including compatibility with the Arduino IDE (Integrated Development


17

Environment) [7], which is being used in this project. NodeMCU is an open-source

platform based on ESP8266 which can connect objects and let data transfer using the Wi-

Fi protocol [3]. In addition, by providing some of the most important features of

microcontrollers [3].

The ESP8266 contains a 2.4Ghz antenna, ESP-12E chip and 802.11b/g/n HT40 Wi-Fi

transceiver, so it can not only connect to a WiFi network and interact with the Internet, but

it can also set up a network of its own, allowing other devices to connect directly to it [5].

This makes the ESP8266 NodeMCU even more versatile.

3.4.4. Dashboard

A MQTT protocol is being used to transfer the data from the end devices to the end

user. A lightweight open messaging protocol called MQTT (MQ Telemetry Transport)

gives network clients with limited resources an easy way to share telemetry data in low-

bandwidth settings [2]. The protocol is used for machine-to-machine (M2M)

communication and uses a publish/subscribe communication structure.

The most popular messaging protocol for the Internet of Things is MQTT (IoT). The

protocol is a set of guidelines that specify how Internet of Things (IoT) devices can publish

and subscribe to data [6]. MQTT is used to send and receive messages and data between

Internet of Things (IoT) and Industrial Internet of Things (IIoT) devices, such as embedded

hardware, sensors, industrial PLCs, etc. The protocol uses the publish/subscribe (Pub/Sub)

paradigm to link devices and is event driven. Topics are used for communication between

the sender (Publisher) and the recipient (Subscriber), who are separate from one another
18

[6]. The MQTT broker is in charge of maintaining the link between them. All incoming

messages are filtered by the MQTT broker, who then correctly distributes them to the

Subscribers [6].

Using MQTT, the dashboard will be developed. A dashboard is a tool for data

visualization that monitors, evaluates, and presents metrics, KPIs, and important data

points [12]. Users of all skill levels may utilize dashboards to comprehend business

intelligence and use it to make better decisions. By gathering data, showing trends or

occurrences, and discovering an objective perspective of performance indicators that can

be understood right away, users actively participate in the analytics process [12]. Charts,

tables, and gauges are used to display visible data on dashboards. Dashboards can be used

to monitor progress, track, and identify patterns over time, offer insightful data on

consumer behavior and market developments, and aid in decision-making [1]. They offer

a quick and simple approach to track progress and spot possibilities by gathering important

data points and metrics [1].

The dashboard process will be divided into four parts. The first being the monitoring

and graph plotting system, as seen in Figure 6.


19

Figure 7. Flowchart of The Monitoring and Graphing System


20

The above flowchart is the process that every sensor should go through. To start the

greenhouse screen will load, then it will check for any available data, or in other words

available sensors. In case there is no available data, an error message will be displayed,

and the process would end. While in case there is a sensor available, a request to the

microcontroller will be sent to get the data, then the data can be sent to the database.

Converting the digital data into a widget alternative and then displaying it is crucial for the

user experience. The system will check if the data received is new, or in other words, if it

is different from the previous one, if it is not different the system will check if a different

greenhouse was chosen. Now in case, there is new data, it will be incremented on its graph

and displayed on the screen. Finally, the system will check if a different greenhouse was

chosen if the same greenhouse is being displayed, the system will check if there is data

available. If a different greenhouse was chosen to be displayed, then the greenhouse screen

will load, and the process will repeat itself.


21

Figure 8. Flowchart of the Valve Function

Figure 7 illustrates the flowchart of the valve control function. First, the screen will load

and will check for the user’s change of the valve state. If the user did not change the state

of the valve, then the system will keep checking until a change is present. When the user

changes the state of the valve, the system will check if the valve is present. In case the

valve is not present then a display error message will be displayed, and the process will

end. However, if the valve is present then the change will be converted to a digital value

and sent to the actuator through the microcontroller. Then, the system will check for a

change in the state of the valve, and the process will repeat itself.
22

Figure 9. Flowchart of the Alert System

Figure 8 illustrates the flowchart of the alert system. The widget will load and will enter

the checking process. First, it will check if the soil moisture is less than 60 and will send

an alert and display it on the screen; this indicates that the soil needs water. Second, it will

check if the temperature is less than 12 or greater than 30 and will send an alert and display

it on the screen; this indicates that the temperature of the greenhouse is abnormal, and that

irrigation is not possible. Then, the system will repeat the checking process.

To develop the dashboard for the project, various dashboard services were tested and

examined. However, none are 100% open source and compatible with the project’s IoT

goals. The availability of open-source and proprietary platforms is limited. Also, they are

likely to predominate. Weeks of researching and testing have led to several dashboards to

review such as ThingsBoard, ThingsStream, Cayenne, ThingWorx, ThingSpeak,


23

OpemRemote, Freeboard, Grafana, etc. [16]. Finally, using ThingsBoard, a dashboard was

developed and designed to be able to visualize the dashboard.

Figure 10. Dashboard

On the left, a weather forecast is visualized using an API. Under it, it shows the humidity

and temperature inside the greenhouse as well as the moisture and temperature of the soil.

Also, the alerts will be displayed, on the far right, in addition to a switch to turn on and off

the valve. Finally, graphs will be drawn for each of the required value.

Note: the values are not shown on the dashboard because the sensors are not connected.
24

Chapter 4 – Project Management

4. 1. Gantt Chart

One of the most common and effective methods of displaying activities displayed

against time is a Gantt chart, which is frequently used in project management [9]. As list

of the activities is located on the chart's left side, and a suitable time scale is located along

the top. A bar is used to symbolize each activity, and the position and length of the bar

correspond to the activity's beginning, middle, and finish dates [9]. Moreover, the

percentage of the completion of the task is also displayed. Figures 10 and 11 represent the

Gantt Chart of this project.

Figure 11. Gantt Chart 1


25

Figure 12. Gantt Chart 2

4.2. Cost Analysis

Comparing the anticipated or predicted costs and benefits connected with a project

choice to assess whether it is feasible from a business standpoint is known as a cost-benefit

analysis [18]. In general, cost-benefit analysis entails totaling up the expenses associated

with a project. In Table 3, a cost analysis table was made for this project. Note that all

components in red are yet to be purchased.


26

Table 3. Cost Analysis

Item Description Qty. Unit Total Purchase


No. Price Price Status

Information Communication Technology


Software
1 Arduino IDE 1 - - In hand
2 ThingsBoard 1 - - In hand
3 SQL database 1 - - In hand
Hardware
Node 1 Soil Sensors
4 NodeMCU V3 ESP8266 With CH340G 1 6.00 6.00 In hand
5 SX1276 LoRa Spread Spectrum 1 16.00 16.00 In hand
Wireless Transceiver 20dBm 862-
931MHz E32-900T20D-V8.1
6 5dBi GSM Antenna UMTS Omni 1 5.00 5.00 In hand
Directional 868Mhz 915Mhz
7 DS18B20 Waterproof Temperature 4 2.75 11.00 In hand
Sensor
8 Capacitive soil moisture sensor not 4 1.90 7.60 In hand
easy to corrode wide voltage wire for
Arduino
Node 2 Indoor Climate & Water
Sensors
9 Arduino Pro mini 328 1 4.50 4.50 In hand
10 SX1276 LoRa Spread Spectrum 1 16.00 16.00 In hand
Wireless Transceiver 20dBm 862-
931MHz E32-900T20D-V8.1
11 5dBi GSM Antenna UMTS Omni 1 5.00 5.00 In hand
Directional 868Mhz 915Mhz
12 Digital Temperature and Humidity 1 6.00 6.00 In hand
Sensor AM2301 sensor
13 0.96" Inch Blue SPI OLED LCD Module 1 5.00 5.00 In hand
+ Cspin 7pin (with GND VCC)
14 HC-SR501 PIR Motion Sensor Module 1 3.00 3.00 In hand
Green
15 1 Channel Relay Module with light 1 3.00 3.00 In hand
coupling 5V
27

16 Automatic Manipulator Shut Off Valve 1 15.87 15.87 In hand


DC8V-DC16V For Alarm Shutoff Gas
Water Pipeline Security Device
Electrical
17 12-Volt Rechargeable Battery 1 6.25 6.25 In hand
18 Wiring Cable Roll 1 12.00 12.00 In hand
Civil works
19 Waterproof enclosure (100 x 100 x 70 3 3.00 9.00 In hand
mm)
20 Blank PCB (5x7) 3 1.00 3.00 In hand
TOTAL 131.22
28

Chapter 5 – Software Implementation

5.1. ESP32 Node

In this part, the code for the ESP8266 will be explained. In brief it will highlight the

code’s main functions.

5.1.1. Libraries

The libraries needed for this part is the DHT library for the humidity and temperature

sensor. The ESP8266 Wi-Fi library, which will allow it to connect to Wi-Fi. The

ThingsBoard library which will help us create MQTT clients and publish the sensors’ result

to the dashboard. Also, the LoRa and SPI libraries that will allow the communication

between the 2 LoRa Transceiver.

5.1.2. Setup

Setting up the code consists of defining Wi-Fi access point and its password, creating

an object for the Wi-Fi, defining the Token Access Key for the ThingsBoard network,

creating an object for the ThingsBoard server, and defining the inputs of the sensors and

LED screen.

Also, initiating the Wi-Fi connection and setting up the ThingsBoard server will be done

in this step. Beginning the LoRa protocol by setting the frequency at 868 MHz will

initialize the LoRa transceiver.

5.1.3. Loop

The loop will constantly check if the Wi-Fi is connected, as well as the ThingsBoard

network. Every second the loop will call the functions to get the LoRa data and the

greenhouse data. This process will repeat itself constantly.


29

5.1.4. Connecting to Wi-Fi and ThingsBoard

Initializing the ESP8266 will be the first step. In this part the function will check if the

ESP is present and if it has a stable connection to the Wi-Fi access point. It will also

initialize the connection between the ThingsBoard and the ESP using the Token Access

Key. It will also check if it’s connected to the ThingsBoard network.

5.1.5. Sensor Readings and Transmitting Data

Using the DHT library, it will be possible to directly read the values of the humidity and

temperature. Using the ThingsBoard library, it will be possible to directly send the values

as attributes to the dashboard.

5.1.6. Receiving LoRa values and Transmitting Data

Before receiving the data, the function will check if there is available data. If there is

data, it will read the first packet and save it. Five seconds later, it will read the second

packet and save it. Similarly, to the previous part, it will be possible to send these values

as attributes to the dashboard.

5.1.7. IR Sensor and LED Screen

This function will read the IR sensor, if the sensor detects motion, it will turn on the

LED screen. If the LED screen receives positive feedback from the IR sensor, it will turn

on and display the values of the DHT sensor which was previously obtained above. The

screen will turn on for 2 minutes.

5.2. Arduino Node

In this part, the code for the Arduino Pro Mini will be explained. In brief it will highlight

the code’s main functions.


30

5.2.1. Libraries

The libraries needed for this part is the One Wire and Dallas Temperature library for the

soil temperature and soil moisture sensor. Also, the LoRa and SPI libraries that will allow

the communication between the 2 LoRa Transceiver.

5.2.2. Setup

Setting up the code consists of defining the inputs of the sensors, as well as, calibrating

the sensors by setting constant values when the sensors are in air and when they are in the

soil.

Beginning the LoRa protocol by setting the frequency at 868 MHz will initialize the

LoRa transceiver.

5.2.3. Loop

Every second the loop will call the functions to get the LoRa data and the soil data. This

process will repeat itself constantly.

5.2.4. Sensor Readings and Transmitting through LoRa

After reading the values of the sensors, the values will be mapped from zero to hundred

for the humidity percentage and will be saved. Also, the average of all 4 soil moisture

sensor will be saved as the final value. However, the temperature will directly be read and

saved.

Using LoRa Library, a packet will be created and will print the value of the soil moisture

sensor. Then , the packet will end. After 5 seconds, a packet will be created and will print

the value of the soil temperature sensor. Then, the packet will end. After 5 seconds, the

process will repeat itself.


31

Chapter 6 – Result And Conclusion

6.1. Conclusion

A final graduation project on IoT in agriculture with a focus on sensors and LoRaWAN

technology could involve the design and implementation of a system that uses sensors and

LoRaWAN-based devices to monitor and control various aspects of agricultural

production. The project could involve the development of sensors for measuring soil

moisture, temperature, and nutrient levels, as well as sensors for tracking the location and

condition of crops and livestock. The data collected by these sensors could be transmitted

to a central server or cloud platform using LoRaWAN technology, which offers long-range,

low-power communication capabilities. This data could then be used to monitor and control

various agricultural processes, such as irrigation and fertilization, as well as to predict and

respond to potential problems, such as pests or diseases. The project could also involve the

development of a user-friendly interface, such as a smartphone app, to enable farmers to

easily access and manage the data and control the system. Overall, the aim of the project

could be to demonstrate the feasibility and potential benefits of using sensors and

LoRaWAN technology in agriculture.

6.2. Future Work

The idea for the current study was a medium to large-scale greenhouse use case for data

gathering from soil temperature and moisture monitoring to develop methods that can

improve farming and reduce capital expenditure, improve the quality of crops, as a result,
32

and benefit the food market in cities. A prototype for monitoring soil moisture and

environment indoor vs outdoor temperature was developed.

Although LoRaWAN has gained popularity lately, LoRaWAN devices are not yet plug-

and-play. Problems were encountered in setting up the use case, such as difficulties

connecting to a LoRaWAN and collecting performance statistics. Based on the

examination of the setup procedure and its technological hazards, a method of simplifying

the setup for IoT application developers utilizing LoRaWAN-based communication can be

provided. This signifies that it is a framework. It helps the sensor application developer

during installation and testing the architecture shown here incorporates a specific prototype

sensing device and links to The ThingsBoard dashboard. This prototype is scalable and can

be easily expanded in the future to accommodate a LoRaWAN network server.

Furthermore, additional and diverse sensors may be incorporated. A bigger payload will

result in a higher transmission burden and a longer duration on air, which the framework

can monitor. These measurements might help developers make decisions about payload

structure. Another ideal feature would be the ability to serve more than one sensor, at the

same time, which is readily enabled with a few framework modifications. Help with the

setup and testing of a whole sensor network. Another enhancement would be to set up a

loraWan gateway that can interface with various greenhouses on site.


33

References

[1] A. Kumar, “Purpose of dashboard: Advantages & Disadvantages,” Data Analytics,


28-May-2022. [Online]. Available: https://vitalflux.com/dashboard-purpose-
advantages-
disadvantages/#:~:text=Dashboards%20can%20be%20used%20to,you%20achieve
%20your%20desired%20outcomes. [Accessed: 02-Oct-2022].

[2] C. Bernstein, K. Brush, and A. S. Gillis, “What is MQTT and how does it work?,”
IoT Agenda, 27-Jan-2021. [Online]. Available:
https://www.techtarget.com/iotagenda/definition/MQTT-MQ-Telemetry-Transport.
[Accessed: 30-Sep-2022].

[3] ElectoPeak, “Getting started w/ NodeMCU ESP8266 on Arduino Ide,” Arduino


Project Hub, 14-Aug-2019. [Online]. Available:
https://create.arduino.cc/projecthub/electropeak/getting-started-w-nodemcu-
esp8266-on-arduino-ide-28184f. [Accessed: 11-Dec-2022].

[4] K. Szegedi, “Food waste has gone viral,” Deloitte Switzerland, 19-Feb-2021.
[Online]. Available: https://www2.deloitte.com/ch/en/pages/consumer-
business/articles/food-waste-has-gone-viral.html. [Accessed: 20-Sep-2022].

[5] Last Minute Engineers, “Insight into ESP8266 NODEMCU features & using it with
Arduino IDE (easy steps),” Last Minute Engineers, 18-Dec-2020. [Online].
Available: https://lastminuteengineers.com/esp8266-nodemcu-arduino-tutorial/.
[Accessed: 13-Dec-2022].

[6] “Mqtt Essentials,” MQTT Essentials - All Core Concepts explained, 2022. [Online].
Available: https://www.hivemq.com/mqtt-essentials/. [Accessed: 30-Sep-2022].

[7] “Nodemcu ESP8266 specifications, overview and setting up,” Make, 25-Mar-2022.
[Online]. Available: https://www.make-it.ca/nodemcu-details-specifications/.
[Accessed: 14-Dec-2022].

[8] N. Shoji, “Precision Agriculture Creates New Business Opportunities,” Mitsui


Global Strategic Studies Institute Monthly Report, Jun. 2017.

[9] R. Duke, Ed., Gantt.com, 2022. [Online]. Available: https://www.gantt.com/.


[Accessed: 14-Oct-2022].

[10] R. Lie, “ LoRa and LoRaWAN Tutorial.,” Mobilefish.com - LoRa/LoRaWAN


tutorial., 2020. [Online]. Available:
34

https://www.mobilefish.com/developer/lorawan/lorawan_quickguide_tutorial.html.
[Accessed: 14-Dec-2022].

[11] R. L. Sumalan, N. Stroia, D. Moga, V. Muresan, A. Lodin, T. Vintila, and C. A.


Popescu, “A cost-effective embedded platform for Greenhouse Environment Control
and remote monitoring,” Agronomy, vol. 10, no. 7, p. 936, 2020.

[12] R. Serpa, “How to build data visualization dashboards,” Sigma Computing, 21-Jul-
2022. [Online]. Available: https://www.sigmacomputing.com/blog/how-to-build-
data-visualization-dashboards/. [Accessed: 20-Sep-2022].

[13] Rp2-1.0.3 LoRaWAN® regional parameters. LoRa Alliance®. (2021, July 20).
Retrieved November 4, 2022, from https://lora-alliance.org/resource_hub/rp2-1-0-3-
lorawan-regional-parameters/

[14] SemTech Corporation , “What are Lora® and Lorawan®?,” LoRa Developer
Portal, Feb-2020. [Online]. Available: https://lora-
developers.semtech.com/documentation/tech-papers-and-guides/lora-and-lorawan/.
[Accessed: 14-Dec-2022].

[15] S. Cope, “Steve's Internet Guide,” |Guide to IOT Dashboards and Platforms, 04-Jul-
2022. [Online]. Available: http://www.steves-internet-guide.com/iot-mqtt-
dashboards/. [Accessed: 27-Oct-2022].

[16] S. Nozaki, “Controlled Environment Agriculture Capturing Growing Interest, The


Accelerating Expansion Of Urban Agriculture,” Mitsui & Co. Global Strategic
Studies Institute Monthly Report, May 2021.

[17] “TR 103 526 - v1.1.1 - System Reference document (SRdoc); Technical
characteristics for Low Power Wide Area Networks Chirp Spread Spectrum
(LPWAN-CSS) operating in the UHF spectrum below 1 GHz,” ETSI, Mar-2018.
[Online]. Available:
https://www.etsi.org/deliver/etsi_tr/103500_103599/103559/01.01.01_60/tr_10355
9v010101p.pdf. [Accessed: 14-Dec-2022].

[18] T. Stobierski, “Cost-benefit analysis: What it is & how to do it: HBS Online,”
Business Insights Blog, 05-Sep-2019. [Online]. Available:
https://online.hbs.edu/blog/post/cost-benefit-
analysis#:~:text=A%20cost%2Dbenefit%20analysis%20is,sense%20from%20a%2
0business%20perspective. [Accessed: 19-Oct-2022].

You might also like