top of page
Writer's pictureSanskruti Ashtikar

Automatic Water Tap Controller Using PIC Microcontroller

Updated: Nov 26

Introduction


Automatic water tap controllers are becoming increasingly popular in public restrooms and modern homes for their water-saving and hygiene benefits. By utilizing a PIC Microcontroller, you can create a smart tap that activates the water flow when hands are detected nearby and shuts off the flow when they are removed. This article provides a detailed guide to designing and implementing an Automatic Water Tap Controller using a PIC Microcontroller.





Components of the System


  1. PIC Microcontroller:

  2. Model: PIC16F877A or similar

  3. Function: Acts as the central control unit, processing sensor data and controlling the solenoid valve.

  4. Proximity Sensor:

  5. Type: Infrared (IR) or Ultrasonic sensor

  6. Function: Detects the presence of hands under the tap to activate the water flow.

  7. Solenoid Valve:

  8. Type: 12V DC or 24V DC solenoid valve

  9. Function: Controls the water flow by opening or closing based on the microcontroller's signal.

  10. Relay Module:

  11. Type: 5V or 12V Relay

  12. Function: Acts as a switch to control the solenoid valve, driven by the microcontroller.

  13. Power Supply:

  14. Type: DC adapter or battery pack

  15. Purpose: Powers the microcontroller, sensors, and solenoid valve.

  16. Connecting Wires and PCB:

  17. Purpose: For making the necessary connections between components.

  18. Enclosure:

  19. Purpose: Houses the components in a safe and water-resistant enclosure.


Design Considerations


  1. Sensor Placement:

  2. Position the sensor accurately to detect hands under the tap without false triggers from other movements.

  3. Power Consumption:

  4. Optimize the power usage, especially if using a battery-powered system. Use components with low power consumption and implement sleep modes.

  5. Water Flow Control:

  6. Ensure the solenoid valve is compatible with the water pressure and flow rate required for the tap.

  7. System Durability:

  8. Design the enclosure to be waterproof and robust to ensure long-term reliability in a moist environment.

  9. Safety:

  10. Ensure the relay and solenoid valve are correctly rated for the application to avoid overheating or electrical hazards.


Building the System


1. Microcontroller and Sensor Integration


  • Connecting the Proximity Sensor:

  • Connect the IR or ultrasonic sensor to the PIC microcontroller’s input pins. For an IR sensor, use an analog input pin to read the proximity data.

  • Programming the PIC Microcontroller:

  • Write firmware to monitor the sensor input, determine if hands are detected, and control the solenoid valve accordingly.



#include <xc.h>
#define _XTAL_FREQ 4000000
// Define pin connections
#define SENSOR_PIN PORTBbits.RB0
#define RELAY_PIN PORTBbits.RB1
void init() {
    TRISBbits.TRISB0 = 1;  // Set SENSOR_PIN as input
    TRISBbits.TRISB1 = 0;  // Set RELAY_PIN as output
    PORTBbits.RB1 = 0;     // Initially turn off the relay
}
void main() {
    init();
    while (1) {
        if (SENSOR_PIN == 1) {  // If the sensor detects a hand
            PORTBbits.RB1 = 1;   // Activate the relay to open the solenoid valve
            __delay_ms(500);     // Keep the valve open for a short duration
        } else {
            PORTBbits.RB1 = 0;   // Deactivate the relay to close the solenoid valve
        }
    }
}

2. Relay and Solenoid Valve Control


  • Connecting the Relay Module:

  • Connect the relay module to the microcontroller’s output pin, ensuring the relay can handle the voltage and current required by the solenoid valve.

  • Controlling the Solenoid Valve:

  • The relay acts as a switch to control the solenoid valve. When the relay is activated, it allows current to flow through the solenoid valve, opening it to allow water flow.


void controlWaterFlow(unsigned char state) {
    if (state) {
        PORTBbits.RB1 = 1;  // Turn on relay (open solenoid valve)
    } else {
        PORTBbits.RB1 = 0;  // Turn off relay (close solenoid valve)
    }
}

3. Sensor Calibration


  • Calibrating the Sensor:

  • Adjust the sensor’s sensitivity to detect hands accurately without triggering from ambient movements or reflections. Test and adjust the sensor threshold in the firmware if necessary.



unsigned char detectHands() {
    if (SENSOR_PIN == 1) {
        return 1;  // Hands detected
    }
    return 0;  // No hands detected
}

Testing and Optimization


  1. Functional Testing:

  2. Verify that the system accurately detects hands and controls the solenoid valve accordingly. Test the system under various conditions to ensure reliability.

  3. User Testing:

  4. Test the system with different users to gather feedback on response time, ease of use, and effectiveness. Adjust sensor placement or timing as needed.

  5. Power Management:

  6. Optimize power consumption by implementing sleep modes or using energy-efficient components, especially if the system is battery-powered.

  7. Durability Testing:

  8. Ensure the system can withstand long-term use in a moist environment. Check the enclosure’s waterproofing and the durability of all connections.


Conclusion


An Automatic Water Tap Controller using a PIC Microcontroller is a practical and efficient solution for reducing water wastage and improving hygiene. By integrating a proximity sensor, solenoid valve, and microcontroller, you can create a reliable system that automatically controls water flow based on the presence of hands.

Careful design, testing, and calibration are essential to ensure the system’s accuracy, reliability, and user satisfaction. With proper implementation, this system can significantly contribute to water conservation and provide a convenient hands-free experience.



Want us to guide you through your project or make the project for you ?






Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



3 views0 comments

Related Posts

See All

Comentarios


bottom of page