Water dispenser
I made this project under mark Rober's monthly course. Its basic idea was that while sitting on my chair I would forget to drink enough water and hence needed a device to keep me heedful of my water consumption. This dispenser not only dispenses the water automatically but it tracks the amount of water that has been consumed in a day.
​
It accordingly resets every day, or when you top it up with water again. It uses the raspberry pi 3 along with an ultrasonic sensor to measure the amount of water in its jar. A node MCU (Making it Alexa controlled) controls a 12v water pump which transfers water from the jar, travels though cable managed channels and finally reaches the end of my desk.




Insights and coding.
The code is fairly simple considering it was my first time playing around with raspberry pi and python. It calculates the volume of the jar, by using the distance from the ultrasonic sensor and multiplying that to the average surface area of the jar. This way we can get a decently precise volume of the water that is consumed. The code also resets the number back to 3cm which is the starting water height when the jar is completely filled.

As you can see in the screenshot above, the "distance" is the distance between the sensor and the surface of the water in cm. The beginning of the code has height displacement set to 3cm because when the jar is full, the sensor and the surface are 3cms apart. The code resets its counter to 0 at midnight, and when the jar is refilled it resets itself.
​
The node MCU works on a completely different code which is similar to the Alexa controlled ceiling lights. It just switches on the motor when asked and keeps it on for 15 secs until my glass is filled with water.