DEV Community

Souvik Biswas
Souvik Biswas

Posted on

Plant Monitor - Using IoT, MongoDB and Flutter

Overview

Plant Monitor is an IoT-based project for monitoring plant health with ease. The projects consists of three parts:

Submission Category:

Action Star

Link to Code

The code for both the app and the IoT part is present in the following GitHub repo:

GitHub logo sbis04 / plant-monitor

Plant monitoring system using IoT, MongoDB, and Flutter

Plant Monitor

IoT based plant monitoring system which is connected to MongoDB. This is a Flutter app to display the realtime data from the sensors attached to the plant on a mobile device.

License

Copyright 2022 Souvik Biswas

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.




Project Description

A detailed description of all the three parts of this project is present below.

IoT: Sensors

Hardware sensors

ESP32 module is used for collecting data, processing and uploading to the MongoDB database. It is a low powered microcontroller integrated with WiFi and Bluetooth.

DHT11 sensor is used for measuring raw temperate and humidity data from the surroundings of the plant.

LDR is used for calculating the light intensity that the plant is receiving.

Soil Moisture sensor module is used to measure the moisture or the water level of the soil. The sensor includes a potentiometer to set the desired moisture threshold.

Database: MongoDB

MongoDB Atlas

MongoDB Atlas provides cloud database service using AWS, Azure, and Google Cloud. It also has various automation tools for performing various backend functionalities and comes with visualization tools. The services that are used in this project are described below.

Atlas is used as the main cloud database for storing the sensor readings along with timestamps.

Atlas

Realm Function is defined to easily store the sensor data from the ESP32 module. A HTTP Endpoint is created to access the MongoDB database from the ESP32.

The following function is used for storing the sensor data:

exports = function(payload){
    var atlas = context.services.get("mongodb-atlas");
    var coll = atlas.db("plantdata").collection("readings");
    try {
      if (payload.body) 
      {
        body = EJSON.parse(payload.body.text());
      }
      coll.insertOne(body);
      console.log(body);
    } catch (e) {
      console.log("Error inserting doc: " + e);
      return e.message();
    }
};
Enter fullscreen mode Exit fullscreen mode

Charts are used to visualize the sensor readings directly inside the MongoDB web app.

Charts

For this project I have created four charts:

  • Plant Light (%): Amount of light intensity plant is receiving
  • Plant Humidity (%): Humidity around the plant
  • Plant Moisture (%): Amount of water present in the soil
  • Plant Temperature (°C): Current temperature around the plant

Mobile app: Flutter

Flutter app

To use the Realm data inside the Flutter application I have created a modified version of the flutter_mongodb_realm plugin to support Dart null safety and run it on the latest version of the Flutter SDK.

References

Top comments (19)

Collapse
 
andreshincapier profile image
Andres Hincapie

Congratulations Souvik, that is an excellent project but maybe you could explain a little more the connections you used in the ESP32, maybe using some tool like fritzing, thank you very much.

Collapse
 
sbis04 profile image
Souvik Biswas

Thanks, I'm thinking of working on a the 3-4 part step by step article series to explain the entire project.

Collapse
 
fan_karwanta profile image
Fan Karwanta

Hello, have you already posted a 3-4 step by step article series to explain this project sir? Because it will massively help me as a student. I badly needed for my major college project.

Collapse
 
frezyx profile image
Stanislav Ilin

Looks great!

Collapse
 
nandaamanta profile image
I Putu Nanda Amanta

wow that's a great project

Collapse
 
sbis04 profile image
Souvik Biswas

Thanks 😊

Collapse
 
aditmodi profile image
Adit Modi

This is a great project Souvik, keep up the good work!

Collapse
 
sbis04 profile image
Souvik Biswas

Thanks 😊

Collapse
 
truecritiqs profile image
truecritiqs

Useful stuff Souvik, keep it up!!!

Collapse
 
sbis04 profile image
Souvik Biswas

Thanks!

Collapse
 
sbis04 profile image
Souvik Biswas

Let me know in the comments what do you think about the project 🙂

Collapse
 
codeninjakun profile image
codeninjakun

This is absolutely amazing and astonishing I wish I could learn all of this . But you there did 🔥🔥🔥 work

Collapse
 
sbis04 profile image
Souvik Biswas

Great that you liked the project, thanks! 😊 I'm also thinking of creating a step-by-step guide for building the entire project from scratch (it will be 3-4 part series, I'll starting posting them on Dev soon) 😎

Thread Thread
 
fan_karwanta profile image
Fan Karwanta

Hello good day, you can literally save my college project if you will post the step-by-step guide of this entire project. Please I need your help, thanks for posting this I already cloned the repo and I have some issues along the way, perhaps you can help me?

Collapse
 
pedromagalhaes profile image
Pedro Magalhães

Lovely! Super cool!

Collapse
 
sbis04 profile image
Souvik Biswas

Thanks! 😊

Collapse
 
elsa profile image
Elsa

cool!

Collapse
 
sbis04 profile image
Souvik Biswas

Thanks! 😊

Collapse
 
mysteriza profile image
Iqfir Azirhcaf

Hello, I need full tutorial for this project, is there any? Thank you.