Smart Plant Monitoring System

Project Description

The aim of the project is to create an intelligent system for monitoring a plant that can be used when you are away from home for long periods of time. The system consists of an ESP32 and a raspberry PI5 used as an HTTP server. The ESP32 is connected to: a DHT11 sensor, a soil moisture sensor, an LCD, a fan and a submersible water pump. The collected data is:temperature, humidity and soil moisture. The data is sent via MQTT to the server. The server has a web interface through which the user can monitor the plant in real time, download all collected data or update environmental limits. Based on the limits set by the user via the web interface, the ESP32 will turn on/off the fan and pump to maintain optimal conditions for the installation.

Hardware Description

The hardware components needed for the project are:

  • ESP32 board - The main micro-controller of the application, it is used to connect to WiFI in order to send MQTT messages.
  • DHT11 - The sensor used to collect the temperature and the air humidity.
  • Soil moisture sensor - Used to get the moisture level of the soil.
  • LCD with I2C - Used to display the collected data.
  • DC Motor - Used to control the fan.
  • Submersible water pump - Used to water the plant.
  • 12V DC power supply - Used to power the pump.
  • 2 relays - To control the fan and the pump.
  • 10 K resistor - Used for the DHT11 sensor.
  • Breadboard
  • Wires

Architecture Diagram:

Setup:

Software Description

Software prerequisites: ESP-IDF was used for the ESP32 code(https://github.com/espressif/esp-idf).
ESP32 uses freeRTOS to easily use the 2 available cores.

ESP32 software diagram:

“Init” functions have their own tasks, because the init process for some components requires delays (e.g. LCD). In this way, the workload is split and freeRTOS can switch from one component to another when one of them needs to wait.

In the main loop there are 3 tasks that are running:

  • Reads the sensor data, controls the fan and the pump.
  • Prints the collected data to the LCD and sends it to the server via MQTT.
  • Checks if any new MQTT message was received. If this is the case (the user set some new limits), the limits are updated.

Backend software diagram:

A flask application runs on RPI5, it communicates with the MQTT broker, Mosquitto, and responds to the user's HTTP requests. A virtual python environment was used for development, so porting the application is easy.

Frontend software diagram:

React was used for the frontend. The application does fetch for the limits already set and also a dataset to render on the graphical components like table and graph. Then an interval is set to fetch the data every second.

Web interface

The web interface presents a chart, a table, one fan status switch, one pump status switch and a download button. The chart allows to enable or disable the characteristics to allow observations only on a certain characteristic Each characteristic in the table has an upper and a lower limit option, which can be changed according to the plant's needs. By pressing the “Download” button, the user will get all the collected data in a “csv” format.

Conclusions

In conclusion, ESP32 is a fantastic option for an IoT project because of the different connection options it has. Using ESP-IDF compared to Arduino has proven to provide more support for handling tasks on ESP32, thus allowing efficient use of hardware resources. Using a web framework like Flask for the backend was a good choice, considering the scalability of this application.

iothings/proiecte/2023/smartplantmonitoringsystem.txt · Last modified: 2024/01/15 18:45 by nicusor.drogeanu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0