Introduction: Arduino Water/Shower Regulator
Today, we will be building a simple water regulator. This is a very simple project and very easy to build. This device controls a solenoid valve to control the flow of water based on a set time. This time can be easily changed and the code modified if needed. The materials for this project will be easy to source and purchase. A great website to get components cheap is aliexpress or ebay.
Arduino Uno (1)
Male to male jumper wires
Male to female jumper wires
220ohm resistor (2)
LCD module 1602 (1)
12V Solenoid (1)
MOSFET (I used IRFZ44N, but any mosfet should work)
1N4007 Diode (1)
XL6009 Boost Buck Converter (1)
100K Potentiometer or Trimmer (1)
Plastic container (optional, but recommened)
Step 1: Prototype the Circuit
Prototype the circuit on a breadboard according to the schematic. I made a few changes to the original circuit. Because I don't have a solenoid valve right now, I used a mosfet and led to simulate the solenoid turning on and off. If you do have a solenoid, you need to use a boost converter to boost the 5v rail to 12v in order to switch the solenoid. I used a DIY version of a boost converter, but buying one from aliexpress is preferred.If you do not know how to use a breadboard, please watch this very useful youtube video here: https://www.youtube.com/watch?v=6WReFkfrUIk
If nothing shows up on the lcd screen, try adjusting the potentiometer. This device controls the backlight intensity and contrast. Make sure that you use a flyback diode on the source of the mosfet or you will fry it. This is because of the inductive switching spikes from the solenoid when it turns on and off.
Step 2: Uploading the Code
Download the Arduino IDE if you haven't already from https://www.arduino.cc/en/Main/Software. If you want to change the shower time and warmup time, you can change the timing on the first 2 lines of the code under user configuration. Before you upload, make sure you select the correct board and serial port. This can be done by going to tools and then board and port. If you are having trouble using an arduino please watch this very useful youtube video by Afrotechmods : https://www.youtube.com/watch?v=nL34zDTPkcs
Step 3: Testing the Circuit
Connect up your 5v battery bank to the circuit and arduino and turn on the power switch. The device should begin counting down from a set time and the buzzer should beep during specific time intervals. The mosfet should turn off after the device counts down to zero. You can verify this by using a led connected to a 220ohm resistor between the 5v rail and mosfet source. Make sure the drain of the mosfet is connected to ground. I did encounter a few issues during the testing of the circuit. When I plugged in the arduino, my led decided to explode violently. I realized that I didn't add a current limiting resistor to the led. Once I replaced the led with a fresh one and added a resistor, no more issues occured and the circuit worked very well.
Step 4: Understanding the Circuit
You may be wondering how this circuit works. The arduino is a microcontroller and it is basically the brains of this entire setup. We have programmed it with a lcd code in order to drive the lcd screen. We are using the digital output pins on the arduino in order to send out a pulse of high or low signal to the gate of the mosfet in order to turn it on. You may be wondering what is a mosfet is. A mosfet is a device that turns on and off based on the input signal and allows power to flow between 2 other pins. This is how your laptop turns on. When you press the power button, a signal is sent to the mosfet which allows the charger power or battery power to flow into the laptop motherboard. In this case, we are using a mosfet to turn on a solenoid valve. The solenoid valve needs 12v to turn on and a very high burst of current to initially open it. This is why we need a mosfet. The output of the arduino can only supply 5v at 100ma, so we connect the mosfet between the solenoid and the 12v power source, which can deliver much more power. We create this 12v power source by using a boost converter, which steps up our 5v from our arduino into 12v to drive the solenoid valve. A potentiometer is a device that allows the adjustment of resistance, which is like a blocking force for current. When we adjust this potentiometer near the lcd screen, we are changing the voltage going to the backlight, which reduces or increases the contrast and backlight intensity. You may be asking what is a diode and why is it needed in this circuit. A diode is a device that allows current to flow in one direction, but not the other way. In this circuit, we have it configured as a flyback diode. The solenoid is made up of an electromagnet to lift up a flap and close it when current is applied. When the solenoid closes, it sends a very high pulse of current back into the mosfet, which can easily fry it. We use this diode to send this high pulse back into the power lines in order to save our mosfet. You don't need this diode for the circuit to work, but it is recommended for reliability purposes. We use a breadboard to quickly test the circuit and get it working. You don't need to solder any components if you use a breadboard. Soldering a circuit can be very time consuming and it may not even work properly on your first attempt. This is why we use a breadboard to test the circuit first and make sure it works and then we solder it on a protoboard in order to make it a functional end product.
1st - Mosfet pinout
2nd - Lcd screen
3rd - 12v solenoid
4th - Boost converter
4th - Arduino uno
5th - Potentiometer
6th - Diode
7th - Breadboard
8th - Protoboard
Step 5: This Instructable Is Not Fully Finished
Since I don't have the solenoid valve, I cannot properly test the circuit in a real life situation. As soon as I receive the valve, I will immediately begin designing an enclosure, soldering the components on a pcb, and testing it on my shower. I will update this instructable as soon as I can. Thanks for your understanding.