Check out my interview with MLH!
Fresh water is one of the most important natural resources we use every day.
Studies show that before COVID-19, the average American used around 100 gallons per day (including laundry, dishes, bathroom, etc.) And with all of the extra hand washing we’re doing now (at least 20 seconds of scrubbing, many times throughout the day) that number is probably much higher.
Most of us leave the water running while we brush our teeth and wash our hands. We’re not using it to rinse off, so all of that extra water going down the drain is just wasted.
In fact, estimates show that the average American wastes about 20 gallons a day just on washing hands and brushing teeth! Over the course of a year, that’s enough drinking water for about 20 people. That’s a pretty scary number when you consider how many people live in drought-stricken areas where drinking water is running out!
Now more than ever, it is important for us to take action to preserve this precious natural resource.
I wanted to find a way to help solve this problem by working as an individual, in my own home. When we think of conserving water, we usually think about stopping watering lawns and washing cars, and taking shorter showers. But there are gallons and gallons of water we waste little by little throughout the day.
For example, I noticed that when I washed my hands and brushed my teeth, I left the water running, too. It was just a habit!
I knew that if I could make a few small changes to my daily habits (and to my family’s), I could conserve a significant amount of water each month in my own house. But that’s the tricky part about habits, you do them without thinking about them.
This hack is a solution to that problem. You don’t have to think about turning off the water, because the Smart Faucet does it for you!
What it does
Smart Faucet is an inexpensive and easy-to-use smart home device designed to help you use less water. The device attaches directly to your bathroom faucet, and automatically turns the water on and off when you wash your hands, brush your teeth, shave, etc.. The device then takes your water usage data per sink, and sends it to the web dashboard. There, you can see and manage all of your devices, and track where and when you are using the most water. Although devices designed to automatically control sinks have been on the market for a while, the components of my device cost less than 40 dollars. Other off the shelf smart faucet alternatives cost over 100 dollars. But more importantly, Smart Faucet allows the user to store and analyze their water usage data automatically, revealing any bad habits that are wasting water.
How I built it
Smart Faucet is based on a Raspberry Pi 3, and uses an ultrasonic sensor and a servo motor to control the sink. A Python script analyzes the data from the ultrasonic sensor, and updates a MongoDB Atlas database, recording the real-time usage data. That data then goes to the visualization front end, which runs on React.js, and Nivo.
This project was an eclectic mix of parts, with the servo from an Arduino Kit, and the ultrasonic sensor coming from a Raspberry Pi Kit (along with the Raspberry Pi). Since I’m somewhat new to hardware hacks, there was a lot of troubleshooting that occurred to get it to work! (See more in Challenges I ran into).
Challenges I ran into
The biggest challenge that I ran into was hardware availability. I needed to scavenge for parts between multiple different IoT kits and projects, which made working with the servo “interesting” to say the least. All of the information I had about controlling it was for writing code on an Arduino, and the spec sheet online was in Chinese! After much trial and error, and a lot of erratic flailing, I finally got the servo under control.
When I tried it on a faucet, however, I found out that it was too weak to turn on the water! I went back to the drawing board, working with gears and motor controllers to try switching to a DC motor I had. It ended up spinning too fast, however, and was unreliable. I then went on a great spigot crusade, searching for a faucet that the servo I had could actually open. I finally found one, set up the servo, and it worked!
After that, I needed to set up the IoT data tracking aspect of the hack. I’d never worked with MongoDB Atlas before and hadn’t really worked with databases at all before this hack, so there was a lot to learn, and a lot of troubleshooting. But in the end, it works!
Accomplishments that I'm proud of
I’m proud of getting the whole hack to work at all! Like I mentioned above, the hardware was both new to me, and mismatched. Plus, MongoDB Atlas was a completely new platform for me. Being able to get everything to work together in 24 hours was definitely a stretch goal, and I’m very proud that I was able to achieve it!
What's next for Smart Faucet
In the future, I plan on:
- Increasing the power of the servo, so it can work on more styles of faucets
- Creating a more robust web app, including
- Pairing new devices
- Renaming devices
- AI to identify patterns and make suggestions on how to reduce water use
- Creating a mounting bracket for showers