2.5 KiB

Smart Fish Feeder (ESP32 + MQTT)

An automated aquarium feeder system based on the ESP32. It dispenses food via a motor pulse triggered by Home Assistant and continuously monitors tank temperature.

Features

  • Remote Feeding: Trigger a measured feed pulse via MQTT (tank/feed).
  • Temperature Monitoring: Reports water temp every 10 seconds via MQTT (tank/temperature).
  • Home Assistant Integration: Fully compatible with HA Dashboards and Automation.
  • Safe Power Design: Optically isolated power rails (ESP32 vs Motor) to prevent brownouts.

🛠 Hardware List

  • Microcontroller: ESP32-D0WD-V3 (DevKitC)
  • Actuator: DC Motor (3V-6V) with auger/screw mechanism
  • Switching: N-Channel MOSFET (IRFZ44N)
  • Sensor: DS18B20 Waterproof Temperature Sensor
  • Protection:
    • 1N5822 Schottky Diode (Flyback protection)
    • 10kΩ Pull-down Resistor (Gate to GND)
  • Power:
    • USB-C (5V) for ESP32
    • External 5V/12V DC Adapter for Motor

🔌 Wiring & Pinout

⚠️ CRITICAL: The ESP32 and Motor Power Supply must share a Common Ground, but 5V lines should remain separate to prevent noise/brownouts.

GPIO Config

Component Pin ESP32 GPIO Notes
MOSFET Gate Left Leg GPIO 27 Use 10kΩ Pull-down to GND
Temp Data Yellow Wire GPIO 14 Requires 4.7kΩ Pull-up (if not on module)

Circuit Diagram (MOSFET)

  • Gate (Left): -> GPIO 27
  • Drain (Middle): -> Motor Negative (-)
  • Source (Right): -> Common GND
  • Motor (+): -> External Power 5V
  • Diode: Across Motor Terminals (Silver stripe to +5V)

💻 Firmware Configuration

Dependencies (Arduino IDE):

  • PubSubClient (Nick O'Leary)
  • OneWire
  • DallasTemperature

Setup:

  1. Update ssid, pass, and mqtt_server in fish_feeder.ino.
  2. Set MOTOR_PIN (Default: 27) and TEMP_PIN (Default: 14).
  3. Upload.

🏠 Home Assistant Integration

1. Manual Configuration (YAML)

Add to configuration.yaml to create entities:

mqtt:
  sensor:
    - name: "Fish Tank Temperature"
      state_topic: "tank/temperature"
      unit_of_measurement: "°C"
      device_class: temperature
      unique_id: "fishtank_temp_01"

  button:
    - name: "Feed Fish"
      command_topic: "tank/feed"
      payload_press: "pulse"
      icon: mdi:fish
      unique_id: "fishtank_feed_btn"

2. Dashboard (Lovelace)

  • Temperature: Use a Gauge card linked to sensor.fish_tank_temperature.
  • Feeder: