Paige Niedringhaus
Published © MIT

Leave the Water Running? πŸ’§ Build an IoT Smart Leak Detector

Learn how to build a low-cost (and low-code) water leak detection device complete with SMS notifications if a leak's detected.

BeginnerFull instructions provided2 hours1,246
Leave the Water Running? πŸ’§ Build an IoT Smart Leak Detector

Things used in this project

Hardware components

Blues Notecarrier-A
Blues Notecarrier-A
×1
Blues Notecard (Cellular)
Blues Notecard (Cellular)
×1
Songhe Rain Water Level Sensor Module
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Adafruit Lithium Ion Polymer Battery - 3.7v 2500mAh
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Blues Notehub.io
Blues Notehub.io
SMS Messaging API
Twilio SMS Messaging API

Story

Read more

Code

JSONata Expression to Send Notecard Device Name and Time to Twilio for Leak Alert SMS Messages

JSON
In the code, replace the $from and $to numbers with the Twilio number and user's phone number who should receive the SMS.
( $from := "+1706XXXXXXX";
   $to := "+1404XXXXXXX";
   $body := function(){
    (
    $join([
      "Leak detected by ",
      best_id ? best_id : device,
      " at ",
      $fromMillis(when * 1000,
      "[M01]/[D01]/[Y0001] [h#1]:[m01][P]",
      "-0500"),
      " EST! πŸ’§πŸͺ£ "
   ])
  )
};
$result := (body.state[0] = {"high": true}) ? "&Body=" & $body() & "&From=" & $from & "&To=" & $to & "&" : $doNotRoute();
)

Notecard Config Commands

JSON
Enter each of these commands one at a time inside of the Notecard CLI or the in-browser Notecard playground available at https://dev.blues.io to program your Notecard to be a leak detector.
{"req":"card.restore","delete":true}

{"req":"hub.set","product":"com.blues.pniedringhaus:leak_detector","mode":"periodic","outbound":1440, "inbound":1440}

{"req":"card.aux","start":true,"mode":"gpio","usage":["input","","",""], "file": "leak.qo", "sync": true}

Credits

Paige Niedringhaus

Paige Niedringhaus

8 projects β€’ 30 followers
Staff Software Engineer @ Blues Wireless. In tech since 2016, but new to IoT and eager to learn.

Comments