Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Arduino Home Assistant Water Flowmeter (and Leakage WatchDog)

License

NotificationsYou must be signed in to change notification settings

fortalbrz/fluxoino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚰 Arduino Water Flow Watchdog

(protection against water leaks)

  • HAL Water Flowmeter Sensor + Solenoid Flow Valve + Home Assistant (MQTT)
  • Optimized for Arduino Nano R3 (ATmega328P) and Ethernet module ECN28J60

I made this project after have some leakages and being caught by a very expensive water bill! 🧾 💸The goal is not only creates a Arduino water flow sensor, but a small "robot" that can close the water flow autonomously (if required) case detect any water leakages (i.e., "leakage watchdog").

Features:

  • home assistant water flow sensor
  • home assistant water flow switch (solenoid water valve) (optional, seeconfig flags)
  • home assistant leakage probability sensor (percentage)
  • autonomously closes the water flow case detect water leakages, i.e., "leakage watchdog" (optional, seeconfig flags)
  • displays water flow information on 16 x 2 LCD (optional, seeconfig flags)

Source code:

REMARKS

  • Arduino Nano with the CH340g USB/serial transceiver requires the Windows driver (next section)
  • this sketch should be pushed with Arduino IDE using configuration:
    • Board "Arduino Nano"
    • Processor: "ATmega328P (Old Bootloader)".
  • sets the macro "DEBUG_MODE true" in order to use serial communication for debugging (i.e., "Serial Monitor", seeconfig flags)

Drivers (CH340g) for Arduino Nano:

Configuration flags

Use these configurations flags to set fluxoino behaviour (as you wish). You can avoid dispensable hardwareand features to fit your needs...

macrodefaultdescription
RELAY_SIZE8number of relays (valid: 1 to 8)
USE_LCD_DISPLAYtrueenables/disables LCD display (disable it if not in use the LCD display)
USE_HOME_ASSISTANTtrueenables/disables Home Assistant integration (MQTT) (disable it if not in use the LAN network module)
USE_WALTER_FLOW_VALVEtrueenables/disables water flow valve (disable it if not in use the solenoid valve)
CAN_CLOSE_WATER_FLOWfalseenables/disables autonomous water valve closing (relaying on LEAKAGE_THRESHOLD)
MQTT_BROKER_ADDRESSipMQTT broker IP address (e.g., mosquitto broker), (requires USE_HOME_ASSISTANT true)
LEAKAGE_THRESHOLD0.9leakage detection sensitivity - threshold as percentage of the maximum theoretical flow (in range: 0 to 1)
LEAKAGE_INTEGRATION_WINDOW_SECONDS600sample window for flow volume integration (leakage volume estimation parameter) (default: 600 = 10 min)
LAMBDA_EWMA0.98lambda EWMA (moving average weight of water flow measurement) (in range: 0 to 1)
PULSES_PER_LITER450pulses per liter (from HAL flowmeter sensor datasheet)
DEBUG_MODEfalsetrue for serial debug (home assistant disabled), false for production (home assistant enabled)

Remark: home assistant can be disabled and therefore fluxoino will only work as standalone flowmeter (LCD display) and/or solenoid valve valve (leakage watchdog)

Materials:

  • Arduino Nano R3 (ATmega328P)
  • Ethernet LAN Network Module (ENC28J60) (optional, only with home assistant, seeconfig flags)
  • water flow sensor G 1/2"
  • solenoid valve 3/4" 12v (normally opened) (optional, seeconfig flags)
  • power supply 12vdc (2A)
  • 1 x rotary potentiometer 10k Ohm (Linear) (optional, only with LCD display, seeconfig flags)
  • 1 x N-channel MOSFET 60V 30A (TNMOSFETFQP) (optional, only with solenoid valve, seeconfig flags)
  • 1 x voltage regulator 3.3v (LD11173v3) (optional, only with solenoid valve, seeconfig flags)
  • 1 x diode rectifier 1A 50V (optional, only with solenoid valve, seeconfig flags)
  • 2 x 10K Ohm Resistor (optional, only with solenoid valve, seeconfig flags)
  • 1 x electrolytic decoupling capacitor 10uF/25V (optional, only with solenoid valve, seeconfig flags)
  • 1 x capacitor ceramic 100nF (optional, only with solenoid valve, seeconfig flags)

Circuit Wiring Instructions:

wiring

Wiring

  • diode 1A 50V (positive) --> power supply 12vdc (positive/Vcc)
  • Arduino Nano pin29 (GND) --> power supply 12vdc (negative/Gnd)
  • Arduino Nano pin30 (VIN) --> diode 1A 50V (negative)
  • solenoid valve coil 1 --> diode 1A 50V (positive)
  • solenoid valve coil 2 --> diode 1A 50V (negative)
  • diode 1A 50V (positive) --> TNMOSFETFQP Drain (center)
  • water flow sensor VCC (red/center) --> 5v (Arduino Nano Pin29)
  • water flow sensor GND (black/left) --> Gnd (Arduino Nano Pin29)
  • water flow sensor SIG (yellow/right) --> 10K Ohm Resistor A (terminal 1)
  • 10K Ohm Resistor A (terminal 1) --> Arduino Nano pin5 (D2)
  • 10K Ohm Resistor A (terminal 2) --> 5v (Arduino Nano Pin29)
  • TNMOSFETFQP Gate (left) --> 10K Ohm Resistor B (terminal 1)
  • TNMOSFETFQP Gate (left) --> Arduino Nano pin7 (D4)
  • TNMOSFETFQP Source (right) --> Gnd (Arduino Nano Pin29)
  • voltage regulator LD11173v3 Vin (right) --> 5v (Arduino Nano Pin29)
  • voltage regulator LD11173v3 Gnd (left) --> Gnd (Arduino Nano Pin29)
  • voltage regulator LD11173v3 Vout (center) --> 10uF electrolytic capacitor (positive)
  • voltage regulator LD11173v3 Vout (center) --> ethernet module ENC28J60 Pin9 (VCC)
  • 10uF electrolytic capacitor (positive) --> Gnd (Arduino Nano Pin29)
  • 100nF ceramic capacitor --> between Vcc and Gnd
  • LCD Pin2 (VDD) --> 5v (Arduino Pin27)
  • LCD Pin15 (A) --> 5v
  • LCD Pin1 (VSS) --> Gnd (Arduino Pin29)
  • LCD Pin5 (RW) --> Gnd
  • LCD Pin16 (K) --> Gnd
  • LCD Pin4 (RS) --> Arduino Nano Pin19 (A0)
  • LCD Pin6 (E) --> Arduino Nano Pin12 (D9)
  • LCD Pin11 (D4) --> Arduino Nano Pin8 (D5)
  • LCD Pin12 (D5) --> Arduino Nano Pin9 (D6)
  • LCD Pin13 (D6) --> Arduino Nano Pin10 (D7)
  • LCD Pin14 (D7) --> Arduino Nano Pin11 (D8)
  • LCD Pin3 (VO) --> 10k ohm potentiometer middle pin (the other two pins go to 5v and Gnd)
  • ethernet module ENC28J60 Pin2 (INT) --> Arduino Nano Pin6 (D3)
  • ethernet module ENC28J60 Pin4 (SO) --> Arduino Nano Pin15 (D12)
  • ethernet module ENC28J60 Pin5 (S1) --> Arduino Nano Pin14 (D11)
  • ethernet module ENC28J60 Pin6 (SCK) --> Arduino Nano Pin16 (D13)
  • ethernet module ENC28J60 Pin7 (CS) --> Arduino Nano Pin13 (D10)
  • ethernet module ENC28J60 Pin10 (GND) --> Gnd (Arduino Nano Pin29)

Home Assistant

The solution will be discoverable as MQTT device with:

MQTT sensors

Nameuiddescription
Flow Sensorsensor.flow_sensorwater flow (L/min)
Leakage Probsensor.leakage_prob_sensorleakage detection probability
Flow Switchswitch.flow_switchwater valve switch (on/off)
Flow Resetbutton.flow_resetreset EWMA flow estimation

Futhermore

Exponential weighted moving average (EWMA) flow estimation:

  flowEWMA[t] = lambda * flow[t] + (1 - lambda) * flowEWMA[t-1]

where:

 flow[t] =        pulses_in_1_sec * 60 / PULSES_PER_LITER          [liters/min] flow[t] = 0.06 * pulses_in_1_sec * 60 / PULSES_PER_LITER          [m3/h]

Jorge Albuquerque (2022)

References:


[8]ページ先頭

©2009-2025 Movatter.jp