In this article we are going to make a NodeMCU and IoT based Smart plant watering system that you can use for your own garden. In our busy schedule, sometimes we need to stay outside for a while. During this abcense, sometimes our plants die due to lack of water. So here is the solution you can use for your own plant.
Disclaimer:
Handling electricity carries inherent risks. It’s essential to have the appropriate skills to manage it safely. Proceed at your own risk, as the author disclaims responsibility for any misuse, harm, or errors. All content on this website is unique and copyrighted; please avoid unauthorized copying. While most articles are open-source for your benefit, feel free to use the knowledge provided. If you find our resources helpful, consider purchasing available materials to support our work.
For assistance or guidance, leave a comment below; the author is committed to helping. Some articles may contain affiliate links that support the author with a commission at no additional cost to you. Thank you for your understanding and support.
Plants need water to survive. Maintaining the right moisture levels for your plants can be a challenge, especially if you travel often or have a busy schedule. This is where a smart plant watering system can come to your rescue. Using a NodeMCU, soil moisture sensor, and a few other components, you can automate the watering of your plants based on real-time soil moisture levels. Additionally, this system will have remote monitoring and control capabilities, including scheduling features, ensuring your plants are always well-watered.
Table of Contents
Components Needed
- NodeMCU v3 (ESP8266)
- Soil Moisture Sensor
- Relay Module
- Water Pump or valve
- Jumper Wires
- Breadboard
- 5V Power Supply
- Water Tubing and Container
- IoT Platform (e.g., Blynk or Adafruit IO)
These are the basic components you may need. If you already have similar things, you can use that.
Hardware settings:
You need to drive a pump through the relay module to turn on watering. Or you can use a valve instead of the pump if you have researve tank overhead. Then simply drive a pin high/low to drive the relay switch. Here is a basic diagram you can follow.
Download NodeMCU Proteus library.
Code:
#define BLYNK_PRINT Serial #include <ESP8266WiFi.h> #include <BlynkSimpleEsp8266.h> char auth[] = "YourAuthToken"; char ssid[] = "YourNetworkName"; char pass[] = "YourPassword"; #define SOIL_MOISTURE_PIN A0 #define RELAY_PIN D2 int moistureLevel = 0; int threshold = 600; // Adjust this threshold based on your soil and sensor BlynkTimer timer; void setup() { Serial.begin(9600); Blynk.begin(auth, ssid, pass); pinMode(SOIL_MOISTURE_PIN, INPUT); pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, HIGH); // Ensure the relay is off initially timer.setInterval(2000L, checkSoilMoisture); } void checkSoilMoisture() { moistureLevel = analogRead(SOIL_MOISTURE_PIN); Serial.print("Soil Moisture Level: "); Serial.println(moistureLevel); Blynk.virtualWrite(V1, moistureLevel); if (moistureLevel < threshold) { digitalWrite(RELAY_PIN, LOW); // Turn on the water pump Serial.println("Watering the plant..."); Blynk.notify("Watering the plant..."); } else { digitalWrite(RELAY_PIN, HIGH); // Turn off the water pump Serial.println("Soil moisture is adequate."); } } BLYNK_WRITE(V2) { int pinValue = param.asInt(); if (pinValue == 1) { digitalWrite(RELAY_PIN, LOW); // Manually turn on the pump } else { digitalWrite(RELAY_PIN, HIGH); // Manually turn off the pump } } BLYNK_WRITE(V3) { threshold = param.asInt(); // Adjust the threshold remotely } void loop() { Blynk.run(); timer.run(); }
Explanation of Code:
- Blynk Setup:
- Replace
YourAuthToken
,YourNetworkName
, andYourPassword
with your Blynk authentication token, Wi-Fi SSID, and password.
- Replace
- Moisture Level Check:
- The
checkSoilMoisture
function reads the soil moisture level every 2 seconds and decides whether to water the plant based on the threshold.
- The
- Remote Control:
- Virtual pins
V1
,V2
, andV3
are used for remote monitoring, manual control of the pump, and adjusting the moisture threshold via the Blynk app.
- Virtual pins
Setting Up the Blynk App:
- Install Blynk App:
- Download the Blynk app from the App Store or Google Play.
- Create a New Project:
- Create a new project and select NodeMCU as the hardware model.
- Add Widgets:
- Gauge Widget: Set to virtual pin V1 to display soil moisture levels.
- Button Widget: Set to virtual pin V2 to manually control the water pump.
- Slider Widget: Set to virtual pin V3 to adjust the soil moisture threshold.
- Configure Notifications:
- Enable notifications to receive alerts when the system waters the plants.
Testing and Calibration:
- Upload the Code:
- Upload the code to your NodeMCU via the Arduino IDE.
- Monitor Output:
- Open the Serial Monitor to observe the soil moisture readings and relay state.
- Calibrate the Sensor:
- Adjust the threshold value in the code or via the Blynk app to suit your plant’s moisture requirements.
Conclusion:
With this smart plant watering system, you can ensure your plants receive the right amount of water even when you’re away. The combination of soil moisture sensing and remote control capabilities via the Blynk platform makes this project both practical and educational. Happy gardening!
Feel free to modify and expand this system by adding more sensors, integrating weather data, or even implementing machine learning for more precise watering predictions.
For Professional Designs or Help:
Read more:
- Adafruit_FONA Library with ESP32
- Read ThingSpeak Channel using ESP8266 and Arduino
- How to interface ESP8266 with STM32
- How to implement a maximum power point tracking (MPPT) algorithm with an Arduino
0 Comments