By Nic Jansma
This is an internet-connected water sensor that will alert you via SMS (or any other webhook via IFTTT) if water is sensed.
I am currently using this near my sump-pump to alert me if the pump fails. It can be run from either AC or battery power.
For hardware, I'm utilizing a Spark Core hooked up to a Grove Water Sensor.
Nowadays, there are even cheaper options from Particle (formerly Spark), such as the Photon or Electron.
The Grove Water Sensor's three wires (power, ground and data) are soldered to the top of the device.
I've 3D printed a simple "seat" for the Core to sit on so the external pins don't short. The STL is included under case/
.
The Core is taped to my sump pump's pipe, and the Water Sensor is taped just below ground-level in the sump pump water pit.
The Spark Core firmware is available under firmware/
. It should work for a Photon or Electron as well.
The firmware publishes these two events to the Spark Cloud:
online
when the device first starts upwater_alarm
when water is sensed. The payload is eitheron
oroff
.
The firmware also exposes two variables:
alarmStatus
:0
means not in alarm state, and1
means the alarm is active.water
:0
means no water detected, and1
means water detected.
In addition, there's also a version of the firmware available that's a combination Water Sensor plus a Temperature and Humidity logger, based on the dht-logger project. To use this combination sensor, check out the firmware-with-dht/
folder.
The previous version of this sensor used a NodeJS app to monitor for events from the Spark Core. This app would then use the Twilio API to send me a SMS when there was an alarm.
Particle now offers Webhooks, which does this job for you. You don't have to run a NodeJS app. Once it senses an event from your Spark Core / Photon / Electron, it will publish an event to any web URL you specify.
Instead of using Twilio for SMS, I am now using IFTTT to send me an email, SMS and a Pushbullet notification all at once -- for free!
The creation of the Particle Webhook is pretty simple. First, install the particle-cli
NPM module:
npm install -g particle-cli
Then, make sure you're logged in:
particle login
Next, create an IFTTT account. Then, create a IFTTT Maker page. On there, look for your private key (under Your key is).
Then, create a file called ifttt.json
into your directory (see the sample in this repo). Replace [your maker key]
in that file with your private key. It should look something like this:
{
"eventName" : "water_alarm",
"url" : "https://maker.ifttt.com/trigger/alert/with/key/[your maker key]",
"requestType" : "POST",
"query" : {
"value1" : "Water Alarm",
"value2" : "{{SPARK_EVENT_VALUE}}"
},
"mydevices" : true
}
Last, you need to tell Particle how to integrate with IFTTT. Do this:
particle webhook create ifttt.json
You should see a success message. You're all set!
This device can be hooked up to a SmartThings hub.
See my smart-things project for a sample Device Handler.
Total cost is around $21.90:
- $19 for the Photon
- $2.90 for the Grove Water Sensor
- Cables to connect the Water Sensor to the Core