Introduction: Bluetooth Water Detection System
Ever find yourself in this situation…
It’s happened to me. But, worry no more with this water detection system which is fun to build and capable of saving you some $$$ when the plumbing busts.
This example shows how to use Node-RED on a RaspberryPi to send an email whenever a moisture reading exceeds a threshold. Node-RED connects to the LightBlue Bean once a minute, requests the moisture and sends an email if water is detected.
Node-RED is a visual programming interface for the Internet of things. If you haven’t used Node-RED with the LightBlue Bean before, here is more information. This example uses a RaspberryPi to run the Node-RED server. Here is the setup page for getting started with Node-RED on RaspberryPi.
Step 1: Learn About Node-RED
Above is the Node-RED flow for this project.
What do the different nodes do?
- 1 min interval: Triggers the nodes it's connected to on a set interval. In this example the interval is 60 seconds.
- Bean serial: This is a node developed specifically for the LightBlue Bean. It connects to a specified Bean and allows you to send and receive serial messages.
- Moisture threshold: Compares the current moisture to a high threshold. If it's too wet it sends a string with the moisture reading to the next node.
- Email: Sends the string passed from the previous node to a specified address.
Step 2: Get Node-RED Up and Running on the RaspberryPi
Follow these instructions to set up Node-RED.
Step 3: Gather Parts
Step 4: Wire the Bean
Solder the wires accordingly and connect the Grove moisture sensor using the 4 pin male jumper to Grove conversion cable.
Step 5: Program the Bean
Use the attached code to measure the moisture.
Step 6: Copy Node-RED Flow to Clipboard
Copy the JSON data to your clipboard.
Step 7: Import Project File to Node-RED
Go to http://<your raspberry pi's ip>:1880/ in your browser. Click the menu in the top right corner and choose import > clipboard.
Step 8: Add Your Bean
Double click the Bean serial node and click on the pen to edit the Bean settings. Update the name to be the name of your Bean. It is important you write the exact name as it’s the only way for Node-RED to find and connect to the correct Bean.
Step 9: Set Up Email
Double click the email node and fill in the account details for your email.
Step 10: Deploy
Click deploy in the top right corner to update server.
Step 11: Activate Water Detection System
Place the sensor in water to send warning email.