Plant 🌳 Water Notification Using NodeMCU || Soil Moisture Sensor || Blynk App




Program Code :-

// Technical Scientist RM               //www.youtube.com/c/TechnicalScientistRM

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "Auth Code";  //code sent via email
const int sensorPin = 4; 
int sensorState = 0;
int lastState = 0;


void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "WiFi Name", "Password");  //wifi name and password
  pinMode(sensorPin, INPUT);
}

void loop()
  Blynk.run();

  sensorState = digitalRead(sensorPin);
Serial.println(sensorState);

if (sensorState == 1 && lastState == 0) {
  Serial.println("needs water, send notification");
  Blynk.notify("Time To Water The Plants");
  lastState = 1;
  delay(1000);
//send notification
    
  } 
  else if (sensorState == 1 && lastState == 1) {
    //do nothing, has not been watered yet
  Serial.println("has not been watered yet");
  delay(1000);
  }
  else {
    //st
    Serial.println("does not need water");
    lastState = 0;
    delay(1000);
  }
  
  delay(100);
}

Comments

  1. Hi there, I read your blogs on a regular basis. Your humoristic style is witty, keep it up! Thank You for Providing Such a Unique and valuable information, If you are looking for the best video wall singapore, then visit zoomvisual.com.sg. I enjoyed this blog post.

    ReplyDelete
  2. I liked your blog so much. It helps us to understand about Soil moisture sensor and its working. Thank you for providing this significant information.

    ReplyDelete

Post a Comment

Popular Posts