Introduction: Flow Based Water Heater Switch (Bathroom Geyser)

Do you want to automate your Instant water heater?

Do you want to safely Switch ON and switch OFF the Instant heater?

Do you want to automatically turn OFF the Instant heater when the tap is closed?

This instructable helps to make your life easier in the bathroom.

This D-I-Y solution will effectively control power to the Geyser (Instant heater) when the hot water tap is turned.

Note: This system makes sense only for Instant electric water heaters. (Refer Image)

Background Information

Managing hot water flow in the bathroom is a major household problem in countries where there is no centralized hot water supply. Each bathroom has its own water heater which is controlled by a switch.

These water heaters are different from the conventional big sized storage water heaters in a way that they provide warm water instantly on turning on the power supply. It is not recommended to have the water heater powered ON when the water is not flowing through the system (outlet tap closed).

This is a safety issue since the heating chamber inside this type of heater is small and the water inside becomes hot so quickly that the temperature safety switch is triggered to turn off the power within few minutes.

Moreover, in most cases, the switch is located outside the bathroom. It becomes inconvenient to Switch ON and OFF while bathing and we tend to leave the heater ON even when the water tap is closed.

There are also situations when one forgets to turn OFF the system after bathing and the heater continuously heats and shuts down on reaching the threshold temperature. It will damage the machine, increase power consumption and pose a health risk as well.

This DIY solution will make controlling the heater more intuitive, safe and reduces electricity consumption.

A video of the working system in the link


  1. Flow sensor
  2. Microcontroller (Arduino series)
  3. Power adapter (220 VAC to 5 VDC) and Cable
  4. 16A Switch box (1 big 3 Pin socket and a Switch)
  5. Wires
  6. 16A 220 VAC Relay with 5 VDC coil voltage (Higher Amps rating is also fine)
  7. Additional Hose for Water heater
  8. 5A Switch box (Optional)

Step 1: Preparing the 220 VAC Lines

The 16A power socket inside the bathroom will be the mother supply for this system. This main power supply which is currently the power source for the Heater needs to be branched into two.

Branch 1 - Auxillary Power Supply

Connect the new 16A 220VAC switch box to the Mother supply via the Plug as shown in the Photos. You can choose to bypass the switch in the 16 A box. This means the Auxillary line will always be ON when the main switch is ON.

One can either use a dedicated AC to 5VDC converter or use a Mobile phone charger with a USB cable

Fix a separate 5 A switch box which is parallel connected to the 16 A switch box. This is recommended when using a Mobile phone charger to power the Arduino and the flow sensor.


Connect a 5VDC converter in parallel to the 16 A switch box. Make sure the 220 VAC to 5 VDC converter is insulated, especially any open terminals having 220 VAC supply.

Step 2: Heater Power Supply Through Relay

Branch 2 - Geyser Power Supply

It is time to use the Relay. Pay attention to the current rating of the Relay as it is a very important criterion. The Relay should be able to sustain the peak current load of the Heater. In most cases, it is about 16 A for 220 VAC systems. And it is also the rated current for the Heavy application switches in the market. Arduino Relay shields might not be able to power up the device. So, be sure to use a proper Relay. The Relay I am using is 220 VAC 25 Ampere rated Solid State Relay (SSR). It is activated by a trigger voltage of 5 VDC, which is suited for Arduino boards.

If you are using an SSR, make sure there is proper ventilation or heat sink for the Relay surface. The Relay needs to be connected in series to the Switch in the 16A switch box.

  1. Take the input Live from the Main supply and connect it to the Input of the Switch.
  2. Connect the Output of the switch to the Relay's input AC line. C
  3. Connect the Relay's output AC line to the Live pin of the 3 pin socket. Now, the circuit should be in such a way that the Geyser can be switched OFF using the Physical switch if required.
  4. The physical switch needs to be always ON and is implemented as an Emergency shut down for the Geyser. (As shown in the image)

Note: It is also possible to connect the Switch in Series to the Relay, so it can be used as a bypass for the control system. The choice of using the Switch as an Emergency switch or Bypass depends on you

Step 3: The Control Loop

Choose the Flow sensor based on the tap diameter. The model used in this project is a Hall-effect type sensor (YF-S201) in a transparent casing. It has a rotor in the middle that rotates when there is water flow. It outputs pulse signals that can be counted to determine flow and also the flow rate if required.

1. Connect the +5 VDC and GND lines to the Arduino's input power pins.

2. Next, connect the +5 and GND lines of the Flow sensor to the Arduino's output power supply pins. (The flow sensor can also be directly powered from the DC converter)

3. Connect the Digital Pin 12 to the +VDC port of the Relay and GND to the -VDC port of the Relay. This will be the control signal.

4. Connect the Digital Pin 2 to the Data line of the Flow sensor

Step 4: Plumbing

This involves simple plumbing. A cutting plier and a piece of cloth will be handy.

  1. Attach the flow sensor to the new hose.
  2. Connect the sensor hose to the existing water line.
  3. Ensure the arrow mark on the flow sensor is the same as the water flow direction.
  4. Make sure there is no water leak in any of the Joints.

The plumbing work is done if you can see the rotor inside the flow sensor rotating when you turn On the hot water tap. (Not possible if the sensor case is not transparent, just wait till you fix the Arduino to sense it)

It is recommended to have the sensor positioned vertically for maximum sensitivity. It also works in horizontal orientation but the sensitivity (flow required to turn the rotor) is reduced.

Step 5: Program the Arduino

This project can be done by any of the Arduino boards. I initially used an Uno board and then moved to a Micro due to its compact size.

The logic to be implemented is really simple.

  1. Monitor the Flow sensor for pulses which indicate the flow.
  2. At the detection of the smallest flow, trigger the control signal via a Digital pin.
  3. Continuously monitor the pulses
  4. If the pulses from Sensor stop, turn OFF the control signal

The photo was taken when I was Calibrating the control parameters with Live data to determine system parameters like Delay and Flow sensitivity. ;)

/*Connect Vcc (red) and Gnd (black) of flow sensor to arduino, and the signal line to arduino digital pin 2.(Yellow wire from sensor)*/

byte sensorInterrupt = 0; byte sensorPin = 2; int RelayPin = 12;

/* The hall-effect flow sensor outputs approximately 4.5 pulses per second per litre/minute of flow*/ float calibrationFactor = 4.5;

volatile byte pulseCount; unsigned long oldTime;

void setup() { Serial.begin(9600); pinMode(13, OUTPUT); pinMode(RelayPin, OUTPUT); pinMode(sensorPin, INPUT); digitalWrite(sensorPin, HIGH); pulseCount = 0; oldTime = 0; //The Hall-effect sensor is connected to pin 2 which uses interrupt 0. // Configured to trigger on a FALLING state change (transition from HIGH // state to LOW state) attachInterrupt(sensorInterrupt, pulseCounter, FALLING); }

void loop() { if((millis() - oldTime) > 2500) // Only process counters once per 2.5 second { // Disable the interrupt while calculating flow rate and sending the value to // the host detachInterrupt(sensorInterrupt); if(pulseCount == 0) { digitalWrite(RelayPin, LOW); digitalWrite(13, LOW); // for the inbuilt LED in the Arduino } else if (pulseCount > 0) { digitalWrite(RelayPin, HIGH); digitalWrite(13, HIGH); // for the inbuilt LED in the Arduino

} oldTime = millis(); Serial.print("Pulse count"); // Print the Pulse count for debugging


// Reset the pulse counter so we can start incrementing again pulseCount = 0; // Enable the interrupt again now that we've finished sending output attachInterrupt(sensorInterrupt, pulseCounter, FALLING); } }

/* Insterrupt Service Routine */ void pulseCounter() { // Increment the pulse counter pulseCount++; }

Step 6: Test the System and Enjoy Your Bath!!

I hope you have managed to get all the things working. It is a very simple project but will be very handy when you need it the most.

Now, it is up to you to cleverly package all the components in such a way that there is no entry for water/moisture on the electronics and the electrical system.

I suggest keeping it covered in a plastic or wooden box with enough ventilation for the Relay.

The photos show the full system in order with an AC to DC converter and an Arduino micro.

This is my first Instructable and I thank the community for inspiring me to write my own. I look forward to feedback on improving the system and the post as well.


Vivek Devaraj