ESP8266 Water Pump Button-Controlled

The “ESP8266 Button-Controlled Water Pump” is an excellent project to create an efficient and effective system. It uses an ESP8266 microcontroller, a tactile button, a relay, silicon tubing, a water pump, and a breadboard. These components work together to allow easy control of the water pump.

It creates an easy-to-use water pump control system that can be managed with a single button press. The aim is to simplify the process of turning the water pump on and off. Making it accessible and convenient for various applications. By using the ESP8266 microcontroller, this system provides a practical example of integrating to enhance functionality and user experience.

As technology continues to advance, projects like this demonstrate how simple IoT implementations can lead to more sophisticated and user-friendly applications, ultimately improving our daily lives. It can serve as the foundation for more complex system. It inspires beginners, showcasing the potential for IoT to streamline and improve a wide range of tasks and processes.

Components:

Connection:

Powering the Breadboard:

  • Connect the Power Adapter 12V: Insert the female plug adapter into the 12V power supply. Link the positive (red) jumper wire to the positive rail and the negative (black) jumper wire to the negative rail of the breadboard.
  • Connect ESP8266 to Breadboard: Connect the VIN pin of the ESP8266 to the positive rail of the breadboard. The GND pin of the ESP8266 to the negative rail of the breadboard.
See also  Getting Started with LCD 1602: A Beginner's Guide

Setting Up the Relay:

  • Power the Relay: The DC+ (VCC) pin of the relay module connect to the positive rail of the breadboard. On the hand the DC- (GND) pin of the relay module link it to the negative rail of the breadboard.
  • Connect Control Pin: Connect the IN pin of the relay to pin D8 on the ESP8266.

Configuring the Tactile Button:

  • Install the Tactile Button: Connect one pin of the tactile button to pin D1 on the ESP8266. The other pin to the GND pin on the ESP8266.

Connecting the Water Pump:

  • Connect the Water Pump to Relay and Breadboard: Connect the positive wire of the Water Mini Pump RS-360S to the COM (common) terminal of the relay. The negative wire of the Water Mini Pump RS-360S to the negative rail of the breadboard.
  • Complete the Water Pump Circuit through Relay: Insert the NO (Normally Open) terminal of the relay to the positive rail of the breadboard.

Code:

At the heart of this project is the ESP8266 microcontroller. Which continuously monitors the state of a button connected to one of its GPIO pins. This ensures that the pump can be turned on and off with a simple press of a button. It uses debouncing techniques, which filter out any noise or unintended signals. Allowing the user to monitor the pump’s operation easily and effectively.

#include <ezButton.h>

#define BUTTON_PIN  D1 // The ESP8266 pin connected to the button's pin
#define RELAY_PIN   D8 // The ESP8266 pin connected to the relay's pin

ezButton button(BUTTON_PIN);  // create ezButton object for pin D1
bool pumpOn = false; // Boolean to keep track of the pump state

void setup() {
  Serial.begin(9600); // Initialize the Serial to communicate with the Serial Monitor.
  pinMode(RELAY_PIN, OUTPUT); // Set ESP8266 pin to output mode
  button.setDebounceTime(50); // Set debounce time to 50 milliseconds
  digitalWrite(RELAY_PIN, LOW); // Initially turn off the pump (assuming LOW means off)
}

void loop() {
  button.loop(); // MUST call the loop() function first

  if(button.isPressed()) {
    pumpOn = !pumpOn; // Toggle the pump state
    if (pumpOn) {
      Serial.println("Pump is ON");
      digitalWrite(RELAY_PIN, HIGH); // Turn on the pump
    } else {
      Serial.println("Pump is OFF");
      digitalWrite(RELAY_PIN, LOW); // Turn off the pump
    }
  }
}

Troubleshooting:

  • Double-check your relay specifications to ensure it can handle the current and voltage required by the pump.
  • Verify that the ESP8266, relay module, and water pump share a common ground to prevent any potential issues with the circuit.
  • Check the Serial Monitor output for any messages indicating the state of the pump.
See also  Pisonet Coin Slot Wiring Diagram

QUICK LINKS: