Book Image

Raspberry Pi Home Automation with Arduino - Second Edition

By : Andrew K. Dennis
Book Image

Raspberry Pi Home Automation with Arduino - Second Edition

By: Andrew K. Dennis

Overview of this book

Table of Contents (16 chapters)
Raspberry Pi Home Automation with Arduino Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Temperature Storage – Setting Up a Database to Store Your Results
Index

Water detection


Of course, testing for humidity might not alert us to a major leak problem. During a severe rainstorm, the basement could be flooded quickly if it relies on a sump pump and that breaks down.

One device we could use with an Arduino or attach to the Raspberry Pi via the bridge shield is a water sensor.

Seeed Studios offer such a device (http://www.seeedstudio.com/depot/Grove-Water-Sensor-p-748.html) that can be connected to either the analog or digital pins on your microcontroller.

With this device hooked up, the following example sketch can be run to check whether device is working correctly.

Note

The example sketch is available on GitHub, at https://github.com/Seeed-Studio/Grove_Water_Sensor.

Integrating this module with your existing damp detection circuit is simple. Attach the device to one of the digital pins on your Uno. Next, add the following code to your damp detection device sketch:

boolean waterDetected() {
  if(digitalRead(WATER_SENSOR) == LOW) {
     return true;
 } else...