Introduction: ESP8266/ESP-01 Arduino Powered SmartThings Leak Detector

Sooooo Many leak detectors to choose from, which one will work best for you? If you have Samsung SmartThings controlling any devices in your home, then this one might just be the ticket!

This is the final version in a series that I've been building around the ESP8266/ESP-01 controller powered by Arduino. We all know that the more mature siblings of the ESP-01 like the NodeMCU ESP12's, etc...are much easier to work with, but this was a mission to show off the power of the little ESP-01 which I am still very fond of. It was my first ESP8266!!

To see the previous versions in this little 'Leak Detector How-To' series, please take a look at the Instructables below. There is something for everyone!

ESP8266/ESP-01 Arduino Powered Leak Detector - No Wi-Fi Basic Local Alarm

ESP8266/ESP-01 Arduino Powered MQTT Leak Detector & Remote Alarm Receiver

If the steps contained within this Instructable look familiar, it is because they are similar to some of the steps in the Instructables above, as well as the one for ESP8266/Arduino SmartThings Relay for Christmas Lights

Step 1: Hardware - What You'll Need

I DO NOT endorse, represent, or receive anything at all for the examples below. Caveat Emptor.

Step 2: Software - What You'll Need

ASSUMPTIONS: Comfortable working with Arduino IDE, Libraries, SmartThings IDE and GITHub.

  • Arduino IDE
  • Samsung SmartThings IDE
  • SmartThings Android App
  • GITHub

Step 3: Hardware Setup

  1. Identify a power source for your ESP. I used an older ESP programmer plugged into my laptop USB, and plugged VCC and Grnd jumpers into their respective locations. (See Pic)
  2. Straddle the ESP breadboard adapter over the center channel of the mini-breadboard so one row of 4 pins is on either side.
  3. Connect Vcc Source to the ESP's Vcc, Ch_Pd, and the Hygrometer.
  4. Connect Grnd Source to the ESP's Grnd, Hygrometer, and Piezo/LED 'short' leg.
  5. Connect the ESP pin 2 to the Hygrometer's Data (Not analog).
  6. Connect the ESP pin 0 to the Piezo/LED 'long' leg.
  • TIPS
    • DO NOT assume the jumper colors in attached pics represent Vcc or Grnd.
    • The Piezo and/or LED cannot be attached during boot. If they are, the ESP will power-up in bootload mode and will not execute the loaded code. Attach them after the ESP is powered up.
    • Adjust sensitivity as needed on Hygrometer with attached Potentiometer.

WrapUp: I plan on making the connections on this permanent and housing it all in a decent enclosure. That enclosure may wind up being another one of my famous Lego boxes again!! When it is complete I'll share it as well.

Step 4: Software Setup/Configuration

ASSUMPTIONS: Comfortable working with Arduino IDE, Libraries, SmartThings IDE and GITHub.

Please Be Careful in the Following Steps (If you are already currently using a ST_Anything Contact Sensor child device, these steps may disable it:

Additional Note:If you setup your SmartThings IDE connection to GITHub for the ST_Anything repo, future changes that are made to the contact sensor in the repo may be pushed to your SmartThings. This may result in the following changes being overwritten.

  1. Modify the attached Arduino sketch, adding your WiFi/SmartThings environment specifics. The sketch calls out where to make the changes, as do the steps on the GITHub Page.
  2. Open your SmartThings IDE page, and secondly...the My Device Handler page.
  3. Locate the ogiewon : Child Contact Sensor in your list and click on it to open.
  4. Select all of the code, Copy and Paste it into a document for 'safe-keeping' of the Original. Save this document someplace you'll remember if/when needed in the future.
  5. Make the following change to the Child Contact Sensor you currently have opened in the SmartThings IDE:

    attributeState "open", label:'${name}', icon:"", backgroundColor:"#e86d13" attributeState "closed", label:'${name}', icon:"", backgroundColor:"#00a0dc"

    attributeState("open", label: "Dry", icon:"st.alarm.water.dry", backgroundColor:"#ffffff")
    attributeState("closed", label: "Wet", icon:"st.alarm.water.wet", backgroundColor:"#00a0dc")
    See attached for additional detailed info if needed.

  6. Click on Save from the top/right menu.

  7. Click on Publish from the top/right menu.

  8. Click'For Me' . Exit the IDE.

  9. Load your modified Arduino sketch to the ESP-01. Attach your ESP-01 to your Leak Detector rig and power up.

  10. Open your SmartThings Mobile App on your device. In your list of 'Things', you should now see a Contact Sensor dressed as a Water Sensor.

  11. Dunk the Water Sensor and see what happens. Fingers crossed that your results are like mine and the water icons appearance change when triggered.

    EXTRAS: Add a SmartThings SmartApp to push Alarms from this device.
    Select Automation, SmartApps, Scroll down to Add a SmartApp, Safety and Security, Notify Me When. Follow the Wizard for 'Contact Closes'.

Step 5: