Water Sensor (also known as Water leak, flood, or rain detector) for ESP8266, ESP32, Raspberry Pi Pico W for Alexa

In this tutorial, we’ll build a water sensor that can be connected to an ESP32, ESP8266, or Raspberry Pi Pico W and use it to monitor for water leaks, floods, or rainfall. With Amazon Alexa, you can check the status of your water sensor, ask for information about it, and receive push notifications when water is detected.

Sinric Pro HW-390 capacitive soil moisture sensor

Prerequisites :

  1. ESP32, ESP8266 or Raspberry Pi Pico W x 1.
  2. Water Sensor x 1.
  3. Jumper Wires.

Quick introduction to Water Sensor

A water detector, also known as a water sensor, is a device that detects the presence of water. Water detectors work in a variety of ways. Some common types of water detectors include:

Note: Water sensors have a shorter lifespan because they are exposed to water. This can cause the sensor to corrode quickly when it’s powered on while immersed in water. To avoid this, it is we are going to only turn on the sensor when taking readings.

Wiring Water Sensor

Let’s hook up the water level sensor.

Sinric Pro water sensor sensor wiring

MCU S Pin VCC Pin
ESP32 34 (Analog ADC1_CH6) 17
ESP8266 A0 D2
Pico W GP26 (ADC0) 6

Note: on ESP32, ADC2 (GPIO04, GPIO02, GPIO15) is unstable when Wi-Fi is being used.

Reading from Water Sensor

Let’s verify that sensor is wired correctly and working.

sinric pro water sensor arduino readings

Detecting flooding

Detecting water level

Step 1 : Connect to Sinric Pro

Step 1.1 : Creating a custom device type for Water Sensor.

Sinric Pro does not have a built-in device type for Water/Flood Sensor so we are going to create a custom device type for Water Sensor using Device Template feature to see.

  1. Flooding in the basement or not .

  2. Water level.

Note: You can use the device template import feature mentioned below to skip creating the full template.

Sinric Pro capacitive soil moisture sensor device template

Here we must select the features of our Soil Moisture Sensor. We want to know whether Soil is Wet or Dry and the Moisture level. So let’s drag a Range, a Mode and Push Notification capability.

Sinric Pro custom device type for capacitive soil moisture sensor

Click on Configure button and setup the two capabilities like below.

Sinric Pro moisture sensor template mode and range settings

Click on Save to save.

Sinric Pro moisture sensor template mode and range settings

Click on Save to save the template.

Sinric Pro moisture saved template

Now you can see the template we just created.

Import an existing template?

If you are feeling lazy setup all the Modes and Range values, you can use the import feature.

Sinric Pro capacitive soil moisture sensor import template

Paste this Template:

Sinric Pro create device alexa

Sinric Pro copy device id

Sinric Pro copy device id

Step 2 : Connect to Sinric Pro

Step 2.1 Install Sinric Pro Library

Sinric Pro install SinricPro library

2.2 Complete Code

Now you should be able to see the flooding status and water level via Alexa, Sinric Pro App

Alexa, What’s the flooding (mode name) in flood sensor(device name)

Alexa, What’s the water level(range name) in flood sensor(device name)

Sinric Pro Alexa capacitive soil moisture sensor

Sinric Pro Alexa capacitive soil moisture sensor portal

Troubleshooting

  1. Google Home or SmartThings are not supproted.

  2. Please refer to our Troubleshooting page for more details.

This document is open source. See a typo? Please create an issue