Hey Folks, I’m back again with a new and interesting project related to irrigation. In this article, we are going to make an IoT based smart irrigation. We are using soil moisture sensors that can find the moisture content in the soil and so according to it the water pump is turned on or off. If the moisture content of the soil is high that means your plants don't need more water. If you still provide them water so it is a chance that your plants may be got rotten. So it is very important to measure the moisture content every time before turn the water pump on. For more information about this project please visit the original post of this project, also bookmark TECHATRONIC.COM as all my further projects and tutorials will be pre-uploaded there.
About the projectThis is IoT-based smart irrigation. We connect a DHT-11 temperature and humidity sensor in our project that can tell us the values of the temperature and humidity in the air. If the moisture content of the soil is low then the green led will glow and the water pump is activated automatically. You can also see the real-time readings on the Blynk app. All the detailed procedure is given below.
Components Required- NodeMCU (ESP8266MOD)
- Soil-Moisture sensor
- DHT11 sensor
- Relay module
- Water Pump
- Green Led with resistor
- 12V supply for pump( if needed)
NOTE: Please upload this code to the nodemcu.
// BLYNK LIBRARY
// https://github.com/blynkkk/blynk-library
// ESP8266 LIBRARY
// https://github.com/ekstrand/ESP8266wifi
// DHT11 SENSOR LIBRARY
// https://github.com/adafruit/DHT-sensor-library
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
#define BLYNK_PRINT Serial
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
char auth[] =" your auth code";
char ssid[] = "your wifi ssid";
char pass[] = "your wifi password";
#define DHTPIN 2
#define DHTTYPE DHT11 // DHT11 SENSOR CONNECT D4 PIN
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V5, h); //V5 is for Humidity
Blynk.virtualWrite(V6, t); //V6 is for Temperature
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor);
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
sensors.begin();
}
int sensor=0;
void sendTemps()
{
sensor=analogRead(A0);
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
Serial.println(temp);
Serial.println(sensor);
Blynk.virtualWrite(V1, temp);
Blynk.virtualWrite(V2,sensor);
delay(1000);
}
void loop()
{
Blynk.run();
timer.run();
sendTemps();
}
Set Up the Blynk App:Download and install Blynk app from any App store.
You will see main screen after logging into the app.
Then create a new project with any of your desired name.
after completion you’ll see this type of interface
We hope that you like this project. Thanks for reading.
HAPPY LEARNING!
Comments