Skip to content

An Arduino based IoT system that monitor soil moisture and temperature using WiFi with a automated irrigation system using relay switch.

Notifications You must be signed in to change notification settings

jxwleong/iot-agriculturue-monitoring-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 

Repository files navigation

IoT Agriculture Monitoring System

This IoT monitoring system uses ESP8266 microcontroller such as NodeMCU and WeMos D1 R2 to monitor and upload plant's parameters. NodeMCU act as data acquisition node for plant's parameter such as soil moisture and temperature. Moreover, NodeMCU also used as server node so that the data from acquisition node can be upload to the IoT platform (ThingsBoard). When the acquired data is not optimal for the growth of the plant, the IoT platform will send notifications via email and Telegram. Moreover, the server node will sent a signal to the relay node so that it can turn on the actuator such as pump to water the plant if the soil moisture is too low or the temperature is too high.


Table of Contents

  1. Requirements for this repo
  2. Hardware setup
  3. Software setup
  4. Results
  5. Future Enhancement
  6. References
  7. Appendices

Requirements for this repo

Hardware

  1. NodeMCU x 2
  2. WeMos D1 R2 x 2
  3. 5V Relay x 1
  4. AC Power Socket Rocker Switch 3 Pin x 1
  5. 16AWG Silicone Wire x 1m (optional for different colour)
  6. 3 pin Wall Socket x 1
  7. An Enclosure Box for Relay and MCU x 1
  8. Soil Moisture Sensor x 2
  9. DHT11 Soil and Humidity Sensor x2
  10. 200mA 5V Solar Panel x2
  11. TP4056 1A Battery Charging Module x2
  12. ACS712 Current Sensor x1
  13. 25V Voltage Sensor x1
  14. CD4051 Analog Mux/ Demux x1
  15. Schottky Diode 1N5822 x1
  16. UltraFire 18650 3.7V 4200mAh Li-ion Battery x2
  17. 18650 Battery Holder x2
  18. 3.3V Voltage Regulator x2

Software

  1. Arduino IDE
  2. ThingsBoard (Demo version/ Professional Edition if you want to export the data to local PC)

For the schematic of this repo, please click here.

Back to Contents



Hardware Setup

The project consists of 4 hardware nodes which are sensor nodes, relay node, server node and power measure node (just to test power consumption). Figure below shows the fully integrated system for this project.

Back to Contents



Software Setup

Arduino IDE

  1. Setup the IDE by referring Appendix for setup of Arduino IDE.
  2. Install the following libraries:
  1. Get the credentials such as TOKEN_ADDRESS Step 4, IP addresses of respective node (exclude power measure node) this code and wifi credentials.
  2. Upload the codes to respective node.

ThingsBoard

  1. Setup the ThingsBoard dashboard by referring Appendix for setup of ThingsBoard, the setup should look like figure below.
  2. Setup the rule engine of the ThingsBoard as shown below.

Back to Contents


Client Node

This project consists two type of client nodes which are sensor nodes and relay node. These client nodes are setup to communicate to the IoT platform (ThingsBoard) via server node.

Sensor Node

The sensor nodes are incharged for acquiring the sensor data and sent it to server node via MQTT. Moreover, the can also receive command from ThingsBoard using MQTT.

Flowchart of Sensor Node

Breadboard View of Sensor Node


Relay Node

The relay node responsible to turn on the relay to power up the water pump if the soil moisture is below optimal. It toggle by receiving 'ON' or 'OFF' command from server node using MQTT.

Flowchart of Relay Node

Breadboard View of Relay Node

Back to Contents


Server Node

The server node was given several tasks when the system is running:

  • Upload the data received from sensor nodes to ThingsBoard.
  • When soil moisture data was received, the sensor node need to make decision whether to turn relay 'ON' or 'OFF' by sending command.
  • Sent command received from RPC Remote Shell on ThingsBoard to client nodes using MQTT.

Flowchart of Server Node

Breadboard View of Server Node

Back to Contents


Power Measure Node

Since the sensor nodes are design to acquire data remotely, it is important to know the power consumption of the sensor nodes. With the power consumptions of the sensor nodes, the battery life span can be determined. Moreover, suitable energy harvesting system can be determined for recharge the battery of sensor nodes. Thus, this node is created just to test the power consumption (Will not used in the field).

Flowchart of Power Measure Node

Breadboard View of Power Measure Node

Back to Contents



Results

Sensor Node Results

Sensor Readings on ThingsBoard's Dashboard

Sensor Readings Export to Desktop (ThingsBoard Professional Edition)

Warning When Soil Moisture is not Optimal.


Relay Node Results

Relay Off When Soil Moisture is Optimal

The relay will remain off when the soil moisture was above optimal.


Relay On When Soil Moisture is below Optimal


Server Node Results

The server node acts like a middleman between the client nodes and the IoT platform (ThingsBoard).


Power Measure Node Results

Solar Panel Current, Voltage and Power Table


Solar Panel Power Graph


Power Consumption of Sensor Nodes


Battery Life for Sensor Nodes (3400mAh battery)

The battery used by sensor nodes is UltraFire 18650 3.7V 4200mAh Li-ion Battery. By using the simple equation, the battery life can be calculated.
The battery life span (hrs) was calculated and tabulated in the figure below.



Future Enhancement

  1. Implementation of Low-Power Communication Protocol: The existing system relies on Wi-Fi for data communication, which, while reliable and ubiquitous, can be power-hungry. To optimize energy consumption, the integration of low-power wide-area network (LPWAN) technologies like LoRaWAN, Zigbee, or NB-IoT is recommended. These protocols are designed for long-range communication with minimal power usage, making them ideal for battery-operated IoT devices. Moreover, they provide sufficient data rates to transmit typical sensor data.
  2. Expansion of Sensor Array: In the present system, the sensors may be limited to basic parameters such as temperature, humidity, and soil moisture. By expanding the sensor array to include parameters like soil pH, nutrient content, light intensity, and carbon dioxide concentration, the system could provide a more comprehensive monitoring of plant health and environmental conditions. This could further allow the implementation of more sophisticated plant care algorithms, potentially improving plant growth and health outcomes.



References

[1] Thakare, S. and Bhagat, P.H., 2018, June. Arduino-Based Smart Irrigation Using Sensors and ESP8266 WiFi Module. In 2018 Second International Conference on Intelligent Computing and Control Systems (ICICCS) (pp. 1-5). IEEE.

[2] Athani, S., Tejeshwar, C.H., Patil, M.M., Patil, P. and Kulkarni, R., 2017, February. Soil moisture monitoring using IoT enabled arduino sensors with neural networks for improving soil management for farmers and predict seasonal rainfall for planning future harvest in North Karnataka—India. In 2017 International Conference on I-SMAC (IoT in Social, Mobile, Analytics and Cloud)(I-SMAC) (pp. 43-48). IEEE.

[3] Tsai, C.F. and Liang, T.W., 2018, November. Application of IoT Technology in The Simple Micro-farming Environmental Monitoring. In 2018 IEEE International Conference on Advanced Manufacturing (ICAM) (pp. 170-172). IEEE.

[4] Rachmani, A.F. and Zulkifli, F.Y., 2018, October. Design of IoT Monitoring System Based on LoRa Technology for Starfruit Plantation. In TENCON 2018-2018 IEEE Region 10 Conference (pp. 1241-1245). IEEE.

[5] Ma, Y.W. and Chen, J.L., 2018, April. Toward intelligent agriculture service platform with lora-based wireless sensor network. In 2018 IEEE International Conference on Applied System Invention (ICASI) (pp. 204-207). IEEE.

[6] Xue-fen, W., Xing-jing, D., Yi, Y., Jing-wen, Z., Sardar, M.S. and Jian, C., 2017, December. Smartphone based LoRa in-soil propagation measurement for wireless underground sensor networks. In 2017 IEEE Conference on Antenna Measurements & Applications (CAMA) (pp. 114-117). IEEE.

[7] Malik, H., Kandler, N., Alam, M.M., Annus, I., Le Moullec, Y. and Kuusik, A., 2018, March. Evaluation of low power wide area network technologies for smart urban drainage systems. In 2018 IEEE International Conference on Environmental Engineering (EE) (pp. 1-5). IEEE.

[8] Rahul, D.S., Sudarshan, S.K., Meghana, K., Nandan, K.N., Kirthana, R. and Sure, P., 2018, January. IoT based solar powered Agribot for irrigation and farm monitoring: Agribot for irrigation and farm monitoring. In 2018 2nd International Conference on Inventive Systems and Control (ICISC) (pp. 826-831). IEEE.

[9] Li, H., Huang, M., Tan, D., Liao, Q., Zou, Y. and Jiang, Y., 2018. Effects of soil moisture content on the growth and physiological status of ginger (Zingiber officinale Roscoe). Acta physiologiae plantarum, 40(7), p.125.

[10] Qiu, C., Gaudreau, L., Nemati, R., Gosselin, A. and Desjardins, Y., 2017. Primocane red raspberry response to fertigation EC, types of substrate and propagation methods. EUROPEAN JOURNAL OF HORTICULTURAL SCIENCE, 82(2), pp.72-80.

[11] Comparison of Wireless Technologies (Bluetooth, WiFi, BLE, Zigbee, Z-Wave, 6LoWPAN, NFC, WiFi Direct, GSM, LTE, LoRa, NB-IoT, and LTE-M)), John Teel, https://predictabledesigns.com/wireless_technologies_bluetooth_wifi_zigbee_gsm_lte_lora_nb-iot_lte-m/ (viewd on 3 January 2020)

[12] LoRa | Advantages of LoRaWAN | Disadvantages of LoRaWAN, https://www.rfwireless-world.com/Terminology/Advantages-and-Disadvantages-of-Lora-or-LoRaWAN.html (viewed on 3 January 2020)

[13] Advantages of BLE (Bluetooth Low Energy) | disadvantages of BLE (Bluetooth Low Energy), https://www.rfwireless-world.com/Terminology/Advantages-and-Disadvantages-of-BLE-Bluetooth-Low-Energy.html (viewed on 3 January 2020)

[14] Lee, Development of an FPGA based Iris Recognition System Using Self Organizing Map for Augmented Security FYP Thesis (viewed on 30 December 2019)

[15] How WiFiManager Works with ESP8266, Random Nerd Tutorials, 2018, https://randomnerdtutorials.com/wifimanager-with-esp8266-autoconnect-custom-parameter-and-manage-your-ssid-and-password/ (viewed on 11 January 2020)

[16] Telemetry Plugin, ThingsBoard, https://thingsboard.io/docs/reference/plugins/telemetry/ (viewed on 11 January 2020)

[17] Using RPC capabilities,https://thingsboard.io/docs/user-guide/rpc (viewed on 11 January 2020)

[18] Allegro ACS712 Datasheet, https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf (viewed on 10 January 2020)

[19] GreenIQ Smart Garden Hub Gen 3 review, Christopher Null, 2017 , https://www.techhive.com/article/3223128/greeniq-review.html (viewed on 12 January 2020)

Back to Contents


Appendices

Setup of Arduino IDE

  1. Download and install Arduino IDE from https://www.arduino.cc/en/main/software.
  2. Open Arduino IDE, go to File > Preferences.
  3. At Preferences, insert http://arduino.esp8266.com/stable/package_esp8266com_index.json at Additional Boards Manager URLs
  4. Go to Tools > Board>Boards Manager.
  5. At Boards Manager, type “esp8266” at the search bar and look for “esp8266by ESP8266 Community then install for the latest version”.
  6. After a few minutes (varies on internet speed), the library should be installed.
  7. Download the CH340 driver from https://sparks.gogo.co.nz/ch340.html based on your operating system, unzip the file and run the installer.
  8. Download the CP210x driver from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers based on your operating system, unzip the file and run the installer.
  9. Make sure to use micro USB data cable for connection between MCU and PC. Go to Device Manager > Ports (COM & LPT). In my case, the COM port is COM7.
  10. Go back to Arduino IDE, go to Tools > Board, choose “LOLIN(WEMOS) D1 R2& mini” for server and “NodeMCU 1.0 (ESP-12E Module)” for clients.
  11. At the same section, select the COM Port found at step 8.

Setup of ThingsBoard

  1. Sign up an account and log in at https://demo.thingsboard.io/login for demo version and https://cloud.thingsboard.io/login for professional version.
  2. Go to DEVICES then click on the ‘+’ sign on the bottom right and select ‘Add new device’.
  3. A window will pop-up, key in the suitable Name and leave the Device type as ‘default’ then click ADD.
  4. Click the created device, then copy the DEVICE ID and ACCESS TOKEN to a notepad. It will used later on.
  5. Go to Assets and repeat step 2 and 3. Leave the Asset type to ‘location’.
  6. Click on created Assets, go to RELATIONS then click ‘+’.
  7. A pop-up will shown, select the Type as Device and Key-in the Device name just created at step 3 then click ‘ADD’.
  8. Go to DASHBOARD and create a new dashboard.
  9. Click on created dashboard then enter into edit mode.
  10. Click ‘Entity aliases’ then click ADD ALIAS
  11. A pop-up named ‘Add alias’ will shown. The Alias name can be set to any name convinient but the Device, please select the device created earllier. Other options leave it as shown at figure below. After click ‘ADD’ then click ‘SAVE’.
  12. To add any widgets to the dashboard, just click Add new widget > Create new widget. Then select the widget type and click any desired widget.
  13. Select the Entity alias as alias created at step11. Then, type the parameter name desired and press ‘ENTER’. Then click ‘ADD’. The similar steps can be applied for other widgets.

Back to Contents

About

An Arduino based IoT system that monitor soil moisture and temperature using WiFi with a automated irrigation system using relay switch.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published