This repository contains circuit diagram and code for low power water leak sensor using ESP-8266 (ESP-12).
Purpose of this project is to create an online sensor that detects water leak (e.g. in bathroom or toilet) and sends a push notification immediately.
The sensor also observes its level of battery voltage at regular intervals and sends notification in case the energy drops below a critical threshold.
The circuit was designed to run on a 3.7V Li-Ion battery, but it can accept any voltage between
3.5 - 12 volts. Just don't forget to adjust the CRITICAL_VOLTAGE
in the
sketch accordingly.
This snippet uses a configuration file config.h
that stores credentials and confidential
information used within the code.
To create the file, run the following script (replace ***
with the real values):
cat << EOF >> config.h
#ifndef CONFIG_H
#define CONFIG_H
#define WIFI_NAME "***"
#define WIFI_PSWD "***"
#define API_HOST "https://***"
#define API_TOKEN "***"
#define PHONE_NUM "***"
#define EMAIL "***"
#define PLACE "toilet"
#endif
EOF
- Board: Generic ESP8266 Module
- Upload speed: 115200
- Flash size: 4M (1M SPIFFS)
I was able to lower the power consumption of ESP-8266 board by using the deep sleep mode. I am using the maximum reliable deep sleep interval of 3 hours.
Current draw of the board and supplemental circuit in the deep sleep mode is about 30uA. When the board awakes and is not connected to WiFi (i.e. is only checking the voltage), then it draws around 70 mA for about 2 seconds.