Now add some code to make it 'adaptive'. Each time it has to adjust the cold tap, monitor for overshoot and such. Then 'tweak' PID constants slowly over multiple runs to get to desired goal faster and faster. Where I'm at, the ground temperature and thus cold water temperature varies with the seasons. So some form of adaptive control that can take this into account would be another interesting 'tweak' to the system. But this is a pretty cool project as it is and shows a lot of great ideas. Looking forward to viewing more of your content.
did you look at thermostatic mixing valves? We just put one in our RV because we were wasting SO much water just to get the right temperature. Now the cold water is the distance from the hot water tank to the faucet and after that the water temperature is completely consistent. Best $100 we have ever spent on a faucet
Yea, I definitely agree that if my goal was to just have something that managed water temperature, a thermostatic mixing value would probably be a better solution. My goal here was mainly to build something fun and interesting, and this seemed like a good, straightforward example of an application where a PID controller would work well.
Man, just the quality of this video gets an instant sub. Really well done. I am familiar with building system design and always thought about making a faucet temperature controller for fun, but I never put in the work. I know water temperature regulation is already a firmly solved problem even with no electronics, but this is a great knowledge deepening project for control systems and design/ integration. Thanks for sharing your work.
With some tweaks, this could be a sellable product. It needs: 1. a way to control the flow independent of the handle design 2. dynamic logic to arrive at efficient PID settings for different water sources
"Why waste all that time adjusting when you can spend even more time building a robot?" That is exactly how I approach projects. My wife will say "can you just buy one?" and I answer "but I can spend 6 months designing my own and build it for only 4x the price!"
i did this for my freshman design class, but a load cell was the plant, and you entered a volume of water you wanted. We knew the mass flow at a certain faucet open value, super fun stuff, love the idea.
Nice work! I've wanted a voice interface to my faucet, so I can say on/off while washing dishes and hopefully conserve some water. My sink has a single lever and I think your mechanism might work on it...
Yea that would be really cool! I was thinking about doing something similar, but maybe putting some kind of IR motion sensor somewhere near your feet so once you turn it on, you can turn the tap on/off by putting your foot in a specific place on the ground.
Most of IKEA shower valves are thermostatic. They use a bi-metal valve to adjust the water temperature mechanically. You can also get them at your local hardware store, but it’ll be more $$$ cause they are considered “fancy” in US.
0:21 That's totally me. My S.O.P. is as follows: 1) If it's broken, I'll either try to rebuild it better, repurpose it, or strip it for parts. 2)If it's not broken yet, then I'll fix it until it is broken. 3) Once 2 is accomplished then, see step 1
Very cool. I'd consider doing this if the kitchen hot water didn't tame FOREVER to get up to temp. Maybe that's the best reason to use it - have it beep when it's at temp :P I've seen some that show a bar of color based on the temperature, as well. Oh the things that one can over-engineer.
I have a similar situation with the tap. I've put an extra thermostat micxe rin the hot water supply. So now I have a "correct warm" tap and a cold one.
Neat execution, especially the disengagement gear so you can still use it manually, though I wonder if it could disengage itself before it loses all power in event of a power cut. My idea is more invasive, using a pair of control valves plumbed inline with the hot and cold water, a flow-meter after the combination, a modified faucet with integral thermistor, and magnetically coupled stick-on knobs for waterproof control. One knob for temperature, one knob for flow rate. Because making it resilient to power loss would be difficult without making the valves accessible with handles, it would need to be reliable and work even during a power cut. Maybe the flow-meter could generate energy, or it could use a thermoelectric generator.
@@ERGU9 simpler solution - just unpower the servo - its a bit harder to turn but will turn easy enough. That way the thing is always engaged with the tap - but unless it needs to be used, its physically unpowered - also better for servo
This is very nice. I've got the old-school single knob mixing valve faucet, so maybe mounting a premixing under the sink and merely using the valve for turning flow on and off. I'm sure water flow can be detected with a piezo to run the temp control.
You can use a thermostat cartridge pre mix tap in the hot water feed. That you end up with a choice between warm, cold, or in between. But never too hot.
Do you think you could go into detail on how you did the simulation using weighted averages? I’m a controls engineer working on large scale battery sites and have been working on a sim for the PLCs. It’s difficult to generate feedback for the control loops and your method looks very straight forward to do this.
One issue I've been having at home is that when someone opens the tap in the kitchen, the cold water pressure drops, leading to a temperature spike for whoever is in the shower. I've had an idea to make something similar to this, but with thermometers and pressure sensors in the hot and cold pipes, as well as a thermometer at the output. A system like that should have a faster response to input temperature differences, and might just be able to save me from minor annoyance
You have to also adjust the temperature there, and may I say it's less precise. We only have mixers in the house and it's way more convenient to manage water temp with (one lever only). But tbh I'd much better like an auto-adjuster like he built in the video. At work, we have an auto-adjuster that has a built-in thermostat, so it doesn't even need electronic bits, and I want one of those at home.
@@bagoston325 I think a system like this would be awesome for the shower as you need a precise temperature over a longer time. You could even have different set points per user.
What usually leaves me unsatisfed with pid is the idea that i can be faster and better because i know stuff about the system the pid doesnt know. Obviously if i was a god in setting up a smooth pid controller as well as configuring it perfectly id probably be able to transfer my knowledge into the machine and make it just as good. The most defining metric for the "easy-ness" of controlling something is set by the delay between actions and reactions as well as how fast of a change we can make. If the piping is made so the warm water has to rise 2 stories before the tap gets hot, the pid will max out (or go even frther) and wait while it integrates into space. But i can know how long it takes, i can even estimate what kind of temperature the pipes and the water left in them might have depending on where heat has been used and at what time it has been used last. So if i know the pipes are cold i just jump to full heat, wait the estimated time and then lower smoothly into comfortable terretory while the pipes slowly heat up and throw me off a couple degrees within the next 20 or so seconds but how do i translate this into my controlling unit? Ideally i would know all the temperatures, all the pipes, the boiler, all the statistics about where heat has been used in the last hour or so and combine them into one all knowing algorythm that can bring my tap up to setpoint within the least ammount of time plus like 1s. At this point we might be able to combat peak human skill. But what im more interested in then is why i can still do what the pid cant, do all this without all the neccessary sensors. Id love to try this out, install your machine on every tap on the house, feed it into a neural network of some sort and train it to almost match human peak performance but i really lack the ambition to do that... Still i like to think about it...
There is a way you can directly import your knowledge of the physical world into a PID controller! It's called math. The core concept is taking real world physics, like how the temperature of the water in the pipe is effected by pipe length of temperature of the room and insulation and flow rate and so on, and modeling that into a set of equations. The equations are most likely derivatives and stuff (i forget the actual term, equations of state?), and they tell you how the physical world should act given certain parameters. After getting the modeling equations, you can then do some more math on them and put them into a PID loop, whether that be open loop or closed loop (closed loop is like the video, i.e. having a sensor and using error to correct the output). Once you have a PID loop you can analytically find the PID values (pain in the ass) then finally build a prototype that works first try. The problem? It's basically a bachelors degree in engineering. (I'd do mechanical if you want to mess around with physical stuff)
Great video! I'm still somewhat new to electronics and such and I was curious why you chose to step down the 12v power to power the servo motors rather than just powering them from the 5v on the Arduino?
I always thought about making something like this, but for the shower. It takes a few minutes for the hot water to kick in, but it kicks in faster when I turn it to the maximum, but then it burns me few seconds later.
At that timestamp I was talking about a moving average of the *derivative of the error* (as opposed to a moving average of the temperature), and yea, there’s theoretically a situation where that could look like the integral, but it’s usually gonna be unrelated. Using a moving average doesn’t really change the derivative except it just smooths it out. For example, the system starts and the goal temp is 100, the current temp is 60, and the temp is going up. Then, the integral and derivative would have opposite signs (one positive, one neg). If the temp was 110 and going up, then they would have the same sign.
Awesome project! Been dreaming about something like this myself - thanks for open sourcing it! 🙌 Quick suggestion though: Instead of letting water run continuously (which wastes water), maybe add a container (and some extra valves and stuff) with a temperature sensor? That way, the system could pre-adjust the temp in the container before releasing it. I know manual adjustment probably wastes more water, but every drop counts for our planet! 💧 Really impressed by the quality of your content - can't believe you don't have more subs! Keep up the great work! 👍
Look man, I love this as a project, but it's really a bad idea overall with all the electronics around water. Also for temperature loops you shouldn't ever really need a D term. Feel free to ask me any questions.
Your case design and the way you fit things together is beautiful. I struggle a lot with this myself and your video is good inspiration.
Thanks! I actually think it was the hardest part of this whole system
Now add some code to make it 'adaptive'. Each time it has to adjust the cold tap, monitor for overshoot and such. Then 'tweak' PID constants slowly over multiple runs to get to desired goal faster and faster.
Where I'm at, the ground temperature and thus cold water temperature varies with the seasons. So some form of adaptive control that can take this into account would be another interesting 'tweak' to the system.
But this is a pretty cool project as it is and shows a lot of great ideas. Looking forward to viewing more of your content.
did you look at thermostatic mixing valves? We just put one in our RV because we were wasting SO much water just to get the right temperature. Now the cold water is the distance from the hot water tank to the faucet and after that the water temperature is completely consistent. Best $100 we have ever spent on a faucet
That's...not the point here :)
Yea, I definitely agree that if my goal was to just have something that managed water temperature, a thermostatic mixing value would probably be a better solution. My goal here was mainly to build something fun and interesting, and this seemed like a good, straightforward example of an application where a PID controller would work well.
Man, just the quality of this video gets an instant sub. Really well done. I am familiar with building system design and always thought about making a faucet temperature controller for fun, but I never put in the work. I know water temperature regulation is already a firmly solved problem even with no electronics, but this is a great knowledge deepening project for control systems and design/ integration. Thanks for sharing your work.
With some tweaks, this could be a sellable product. It needs:
1. a way to control the flow independent of the handle design
2. dynamic logic to arrive at efficient PID settings for different water sources
Laziness is the mother of creativity. Caffeine is the delivery nurse.
I love your use of an exceptionally long screwdriver :) it brought a tear of joy to my easily amused heart
"Why waste all that time adjusting when you can spend even more time building a robot?" That is exactly how I approach projects. My wife will say "can you just buy one?" and I answer "but I can spend 6 months designing my own and build it for only 4x the price!"
painfully relatable
Cool design! You've made me understand PID loops better.
I had this idea for such a long time, its time someone actually ended up doing it 😅
i did this for my freshman design class, but a load cell was the plant, and you entered a volume of water you wanted. We knew the mass flow at a certain faucet open value, super fun stuff, love the idea.
First 5 seconds made me go from "why the fuck would you need PID on a faucet" to "oh yea"
Engineer approval rating: 100%
Wife approval rating: 0%
Nice work! I've wanted a voice interface to my faucet, so I can say on/off while washing dishes and hopefully conserve some water. My sink has a single lever and I think your mechanism might work on it...
Yea that would be really cool! I was thinking about doing something similar, but maybe putting some kind of IR motion sensor somewhere near your feet so once you turn it on, you can turn the tap on/off by putting your foot in a specific place on the ground.
@noahponto Oh that's clever! I like that
awesome project
very cool! I sometimes wonder why we don't have this as standard at home. Would make showering etc much more easy.
Thermostatic shower taps are pretty common around here. Basically similar functionality without all the electronics.
Most of IKEA shower valves are thermostatic. They use a bi-metal valve to adjust the water temperature mechanically. You can also get them at your local hardware store, but it’ll be more $$$ cause they are considered “fancy” in US.
@@mr_voron yep, 70$ here in Poland
You’re thinking of an electric shower 😂
They have them in Japan
Lot of inspiration in this video, thanks
That’s awesome! I’ve wanted to do this for years on my sink. Cool to see it in action.
0:21 That's totally me.
My S.O.P. is as follows:
1) If it's broken,
I'll either try to rebuild it better, repurpose it, or strip it for parts.
2)If it's not broken yet, then I'll fix it until it is broken.
3) Once 2 is accomplished then, see step 1
i love everything about this. Instant subscribe.
Very cool. I'd consider doing this if the kitchen hot water didn't tame FOREVER to get up to temp. Maybe that's the best reason to use it - have it beep when it's at temp :P I've seen some that show a bar of color based on the temperature, as well. Oh the things that one can over-engineer.
cool (shall I mention you can buy thermostatic faucets in the DIY store?)
I have a similar situation with the tap. I've put an extra thermostat micxe rin the hot water supply. So now I have a "correct warm" tap and a cold one.
Neat execution, especially the disengagement gear so you can still use it manually, though I wonder if it could disengage itself before it loses all power in event of a power cut.
My idea is more invasive, using a pair of control valves plumbed inline with the hot and cold water, a flow-meter after the combination, a modified faucet with integral thermistor, and magnetically coupled stick-on knobs for waterproof control. One knob for temperature, one knob for flow rate.
Because making it resilient to power loss would be difficult without making the valves accessible with handles, it would need to be reliable and work even during a power cut. Maybe the flow-meter could generate energy, or it could use a thermoelectric generator.
I also wonder if sometimes moving gear miss the exact place and stuck in the process.
@@ERGU9 simpler solution - just unpower the servo - its a bit harder to turn but will turn easy enough.
That way the thing is always engaged with the tap - but unless it needs to be used, its physically unpowered - also better for servo
This is very nice. I've got the old-school single knob mixing valve faucet, so maybe mounting a premixing under the sink and merely using the valve for turning flow on and off. I'm sure water flow can be detected with a piezo to run the temp control.
You can use a thermostat cartridge pre mix tap in the hot water feed. That you end up with a choice between warm, cold, or in between. But never too hot.
I might be able to use this in on Cross Flow Heat Exchanger for a lab demonstration.
Do you think you could go into detail on how you did the simulation using weighted averages? I’m a controls engineer working on large scale battery sites and have been working on a sim for the PLCs. It’s difficult to generate feedback for the control loops and your method looks very straight forward to do this.
One issue I've been having at home is that when someone opens the tap in the kitchen, the cold water pressure drops, leading to a temperature spike for whoever is in the shower.
I've had an idea to make something similar to this, but with thermometers and pressure sensors in the hot and cold pipes, as well as a thermometer at the output. A system like that should have a faster response to input temperature differences, and might just be able to save me from minor annoyance
Bro has got looong screw driver
This is really cool and all, but wouldn't it be easier to get a single lever mixer? xD
You have to also adjust the temperature there, and may I say it's less precise. We only have mixers in the house and it's way more convenient to manage water temp with (one lever only). But tbh I'd much better like an auto-adjuster like he built in the video.
At work, we have an auto-adjuster that has a built-in thermostat, so it doesn't even need electronic bits, and I want one of those at home.
@@bagoston325 I think a system like this would be awesome for the shower as you need a precise temperature over a longer time. You could even have different set points per user.
Probably, but where's the fun in that 😅
What usually leaves me unsatisfed with pid is the idea that i can be faster and better because i know stuff about the system the pid doesnt know. Obviously if i was a god in setting up a smooth pid controller as well as configuring it perfectly id probably be able to transfer my knowledge into the machine and make it just as good. The most defining metric for the "easy-ness" of controlling something is set by the delay between actions and reactions as well as how fast of a change we can make. If the piping is made so the warm water has to rise 2 stories before the tap gets hot, the pid will max out (or go even frther) and wait while it integrates into space. But i can know how long it takes, i can even estimate what kind of temperature the pipes and the water left in them might have depending on where heat has been used and at what time it has been used last. So if i know the pipes are cold i just jump to full heat, wait the estimated time and then lower smoothly into comfortable terretory while the pipes slowly heat up and throw me off a couple degrees within the next 20 or so seconds but how do i translate this into my controlling unit? Ideally i would know all the temperatures, all the pipes, the boiler, all the statistics about where heat has been used in the last hour or so and combine them into one all knowing algorythm that can bring my tap up to setpoint within the least ammount of time plus like 1s. At this point we might be able to combat peak human skill. But what im more interested in then is why i can still do what the pid cant, do all this without all the neccessary sensors. Id love to try this out, install your machine on every tap on the house, feed it into a neural network of some sort and train it to almost match human peak performance but i really lack the ambition to do that... Still i like to think about it...
There is a way you can directly import your knowledge of the physical world into a PID controller! It's called math. The core concept is taking real world physics, like how the temperature of the water in the pipe is effected by pipe length of temperature of the room and insulation and flow rate and so on, and modeling that into a set of equations. The equations are most likely derivatives and stuff (i forget the actual term, equations of state?), and they tell you how the physical world should act given certain parameters.
After getting the modeling equations, you can then do some more math on them and put them into a PID loop, whether that be open loop or closed loop (closed loop is like the video, i.e. having a sensor and using error to correct the output). Once you have a PID loop you can analytically find the PID values (pain in the ass) then finally build a prototype that works first try.
The problem? It's basically a bachelors degree in engineering. (I'd do mechanical if you want to mess around with physical stuff)
@@marshmellominiapple or you can just buy a DIN mount PID controller for $20 and run the autotune function.
@SolarMillUSA he said that there's stuff that the pid in the system doesn't know. And you can tune for different things.
You might like model predictive control!
Thanks for sharing. What is the brand of tweezers you are using?
Great video! I'm still somewhat new to electronics and such and I was curious why you chose to step down the 12v power to power the servo motors rather than just powering them from the 5v on the Arduino?
The arduinos built in regulator can't handle the current required by the servos
@@the555timer oh ok that makes sense thank you!
very nice bro! i like the clean and logic design!
What was the purpose of the relay? There are some mosfet boards also, I think
I always thought about making something like this, but for the shower. It takes a few minutes for the hot water to kick in, but it kicks in faster when I turn it to the maximum, but then it burns me few seconds later.
Very good video, 10.10
@6:35 a moving average of the input is a bit like the Integral ;) [but not literally the same, because it's also a bit like noise rejection]
At that timestamp I was talking about a moving average of the *derivative of the error* (as opposed to a moving average of the temperature), and yea, there’s theoretically a situation where that could look like the integral, but it’s usually gonna be unrelated. Using a moving average doesn’t really change the derivative except it just smooths it out.
For example, the system starts and the goal temp is 100, the current temp is 60, and the temp is going up. Then, the integral and derivative would have opposite signs (one positive, one neg). If the temp was 110 and going up, then they would have the same sign.
@@noahponto fascinating. Thanks for the explanation!
Funny how you thought of that at 6:35 and i was just giggling at cumError
Haha! That’s awesome! Just forgot to remove protected film over lcd! 😆
This is very cool!
Beautiful :)
I wonder how it would react if you turned on the cold water ONLY during a heat wave when the tap water was coming out super hot.. :)
0:20 thats just engineering 101
Awesome project! Been dreaming about something like this myself - thanks for open sourcing it! 🙌
Quick suggestion though: Instead of letting water run continuously (which wastes water), maybe add a container (and some extra valves and stuff) with a temperature sensor? That way, the system could pre-adjust the temp in the container before releasing it. I know manual adjustment probably wastes more water, but every drop counts for our planet! 💧
Really impressed by the quality of your content - can't believe you don't have more subs! Keep up the great work! 👍
subbed
Thats so cool. Did you learn robotics at college or self taught?
I can tell you, at school you never learn useful things
You're better off to learn it online, a lot of tutorials, readily available electronic kits, and GPIO programming.
I wonder how long till you learn about bi-metalic faucets that do the same thing in seconds, without electricity :D
2:48 my eyes🥲
Or you could just buy a thermostatic tap/valve... Still a nice project!
Look man, I love this as a project, but it's really a bad idea overall with all the electronics around water.
Also for temperature loops you shouldn't ever really need a D term. Feel free to ask me any questions.
Hehe I mean I like this it's a fun project but thermostatic valves are already a thing
Cool project. And entirely useless since thermostatic mixers exist