NodeMCU water controll with autocuff

How the tool works

We put the microcontroller in the water Pump power supply section with Relay.If water switch in trigger(FULL) then it will cut of the relay power(Machine off) with Buzzer indicating the water tank is full. We use blynk to monitoring the value. The microcontroller which connected to internet connection trigger ON/OFF to blynk cloud and the cloud will send the data to our app(remotely turn on/off the machine).


Hardware Component

  • ESP8266 module
  •  USB Cable
  • Water switch
  •  buzzer
  •  Wires
  • Button
  • 5v Relay switch
  • Software Os and Apps(Arduino IDE)

Arduino Code

#include <Blynk.h>

int relayPin = 5; // D1(gpio5)

int buttonPin = 4; //D2(gpio4)

int buzzerPin = 15; //D8(gpio15)

int TANK1 = 14; //D5(gpio14)

int buttonState=0;

int switchState = 0;

int oldSwitchState = 0;

int lightsOn = 0; // is the switch on = 1 or off = 0

int TANK1flowState = 0;

int buzzerstate = 0;

#define BLYNK_PRINT Serial

#include <BlynkSimpleEsp8266.h>

char auth[ ] = “Dv7n81Jj_T325ZnjfzQvq6khsqW0N1qR”;

WidgetLED led1(V1);

BlynkTimer timer;

#include <ESP8266WiFi.h>

#include <WiFiClient.h>

//ESP Web Server Library to host a web page

#include <ESP8266WebServer.h>


//Our HTML webpage contents in program memory

const char MAIN_page[] PROGMEM = R”=====(

<!DOCTYPE html>




<h1>WiFi Switch on off demo: 1</h1><br>

Ciclk to turn <a href=”ledOn”>Switch ON</a><br>

Ciclk to turn <a href=”ledOff”>Switch OFF</a><br>


<a href=”“>satya</a>






//SSID and Password of your WiFi router

const char* ssid = “satya_guest_wifi”;

const char* password = “satya123#@!”;

// V1 LED Widget is blinking

void blinkLedWidget()  // function for switching off and on LED


  if (led1.getValue()) {;

    Serial.println(“LED on V1: off”);

  } else {


    Serial.println(“LED on V1: on”);



//Declare a global object variable from the ESP8266WebServer class.

ESP8266WebServer server(80); //Server on port 80


// This routine is executed when you open its IP in browser


void handleRoot() {

Serial.println(“You called root page”);

String s = MAIN_page; //Read HTML contents

server.send(200, “text/html”, s); //Send web page


void handleLEDon() {

Serial.println(“LED on page”);

switchState = HIGH;

lightsOn = 1;

server.send(200, “text/html”, “Switch is ON”); //Send ADC value only to client ajax request


void handleLEDoff() {

Serial.println(“LED off page”);

switchState = LOW;

lightsOn = 0;

server.send(200, “text/html”, “Switch is OFF”); //Send ADC value only to client ajax request



//                  SETUP


void setup(void){

pinMode(buzzerPin, OUTPUT);

pinMode(relayPin, OUTPUT);

pinMode(buttonPin, INPUT);

pinMode(TANK1, INPUT);




  WiFi.begin(ssid, password);     //Connect to your WiFi router


   Blynk.begin(auth, ssid, password);

   timer.setInterval(1000L, blinkLedWidget);

  // Wait for connection

  while (WiFi.status() != WL_CONNECTED) {




  //If connection successful show IP address in serial monitor


  Serial.print(“Connected to “);


  Serial.print(“IP address: “);

  Serial.println(WiFi.localIP());  //IP address assigned to your ESP

  server.on(“/”, handleRoot);      //Which routine to handle at root location. This is display page

  server.on(“/ledOn”, handleLEDon); //as Per  <a href=”ledOn”>, Subroutine to be called

  server.on(“/ledOff”, handleLEDoff);

  server.begin();                  //Start server

  Serial.println(“HTTP server started”);



//                     LOOP


void loop(void){

  server.handleClient();          //Handle client requests;;

  //set default value

  digitalWrite(buzzerPin, LOW); // set buzzer on

switchState = digitalRead(buttonPin); // read the pushButton State

TANK1flowState = digitalRead(TANK1); // read the flowButton State

if (switchState != oldSwitchState) // catch change


oldSwitchState = switchState;

   if (switchState == LOW && TANK1flowState == LOW)


   // toggle

   lightsOn = !lightsOn;



  if (TANK1flowState == HIGH && buzzerstate == 0) {

      buzzerstate = millis();


if (TANK1flowState == HIGH)


   // toggle

   switchState = LOW;

   lightsOn = 0;

      //buzzer activation time in ms 15 secc(15000L)

       if(millis() – buzzerstate < 15000L) {






    } else  {


        buzzerstate = 0;




  digitalWrite(relayPin, LOW); // set the LED on

} else {

  digitalWrite(relayPin, HIGH); // set the LED off



Leave a Reply

Your email address will not be published.