The alarm has an AVR ATtiny85 microcontroller as its brain. It takes voltage readings from the battery and the water sensor and compares them with pre-defined value to detect the presence of water or a low-battery condition. The water sensor is simply two wires placed approximately 1 mm apart. One of the wires is connected to 3.3 V, and the other one is connected to a sensing pin on the microcontroller, which is also connected to ground through a 0.5 MOhm resistor. Normally, resistance between the sensor wires is very high (well over 10 MOhm), so the sensing pin is pulled all the way down to 0 V. However, when there is water present between the wires, resistance drops to less than 1 MOhm, and the sensing pin sees some voltage (in my case about 1.5 V). When ATtiny85 detects this voltage on the sensing pin, it activates a MOSFET to power up a buzzer, and sends the wake-up signal to the ESP8266 module which is responsible for sending alerts (email and push notifications). After a minute buzzing, the alarm is disarmed, and can be reset only by power cycling.