Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP8266-Based Battery-Powered Water Flow Monitoring System with Vibration Alert

View and Edit Project In Cirkit DesignerImage of ESP8266-Based Battery-Powered Water Flow Monitoring System with Vibration Alert

Circuit Documentation

Summary

This circuit is designed to monitor water flow using a flow sensor and provide a reminder via a vibration motor if no flow is detected for a specified interval. The circuit is powered by a 3.7V LiPo battery and includes an ESP8266 NodeMCU microcontroller for processing and control.

Component List

  1. ESP8266 NodeMCU

    • Description: A low-cost Wi-Fi microcontroller with GPIO pins.
    • Pins: D0, D1, D2, D3, D4, 3V3, GND, D5, D6, D7, D8, RX, TX, A0, RSV, SD3, SD2, SD1, CMD, SD0, CLK, EN, RST, VIN
  2. Water Flow Sensor

    • Description: A sensor that measures the rate of water flow.
    • Pins: Signal, Vcc, GND
  3. Vibration Motor

    • Description: A small motor that provides haptic feedback through vibration.
    • Pins: +, -
  4. NPN Transistor

    • Description: A transistor used to switch the vibration motor on and off.
    • Pins: E (Emitter), C (Collector), B (Base)
  5. 1N4007 Rectifier Diode

    • Description: A diode used to protect the circuit from reverse voltage.
    • Pins: Cathode, Anode
  6. PowerBoost 1000 Basic Terminal USB

    • Description: A power supply module that boosts the voltage from a LiPo battery to 5V.
    • Pins: VBAT, GND, ENABLE, LBO, 5.0V
  7. 3.7V LiPo Battery

    • Description: A rechargeable lithium polymer battery.
    • Pins: +Ve, GND

Wiring Details

ESP8266 NodeMCU

Water Flow Sensor

Vibration Motor

NPN Transistor

1N4007 Rectifier Diode

PowerBoost 1000 Basic Terminal USB

3.7V LiPo Battery

Code Documentation

#include <AntoCommon.h>
#include <AntoHTTP.h>
#include <AntoIO.h>
#include <AntoMQTT.h>
#include <AntoWiFi.h>
#include <AntaresESP8266MQTT.h>
#include <ArduinoJson.h>
#include <ArduinoJson.hpp>
#include <PubSubClient.h>
#include <AntaresESP8266HTTP.h>
#include <ArduinoJson.h>
#include <ArduinoJson.hpp>
#include <Ambient.h>
#include <Adafruit_ESP8266.h>

// Pin assignments
#define FLOW_SENSOR_PIN D1  // GPIO5
#define VIBRATOR_PIN D2     // GPIO4

// Variables
volatile int flowPulseCount = 0; // Flow sensor pulse count
unsigned long lastReminderTime = 0; // Time since last reminder
unsigned long reminderInterval = 60000; // Reminder interval in milliseconds (1 minute)

// Interrupt service routine for flow sensor
void pulseCounter() {
  flowPulseCount++;
}

void setup() {
  // Initialize serial monitor
  Serial.begin(9600);

  // Set up flow sensor
  pinMode(FLOW_SENSOR_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_PIN), pulseCounter, FALLING);

  // Set up vibrator motor
  pinMode(VIBRATOR_PIN, OUTPUT);
  digitalWrite(VIBRATOR_PIN, LOW); // Ensure motor is off
}

void loop() {
  // Calculate flow rate (assuming a specific sensor)
  float flowRate = (flowPulseCount / 7.5); // Example conversion factor (depends on sensor)
  flowPulseCount = 0; // Reset pulse count
  Serial.print("Flow Rate: ");
  Serial.print(flowRate);
  Serial.println(" L/min");

  // Check if flow rate is zero for a certain interval
  if (flowRate == 0 && millis() - lastReminderTime > reminderInterval) {
    // Trigger the vibrator motor
    digitalWrite(VIBRATOR_PIN, HIGH);
    delay(1000); // Vibrate for 1 second
    digitalWrite(VIBRATOR_PIN, LOW);
    lastReminderTime = millis(); // Update reminder time
  }

  delay(1000); // Delay for reading stability
}

This code sets up the ESP8266 NodeMCU to monitor the water flow sensor and control the vibration motor. The flow sensor's pulse count is used to calculate the flow rate, and if no flow is detected for a specified interval, the vibration motor is triggered to provide a reminder.