Sonoff Fish Pond Pump

https://d33wubrfki0l68.cloudfront.net/76a1b619ffd4daa56755079d6cb60eb54aa2d66b/f532f/_images/sonoff-fishpond.jpg

The Sonoff range of products containing the ESP chips from espressif has a myriad of uses and best of all, you can customize it, aka hackable. This quick cookbook aims to provide a clear, simple working example.

This example is very basic in it’s operation.

  • Start the pump every hour and run it for 10 minutes.
  • Manually start and stop the pump with the toggle button on the Sonoff basic.
  • Use a water float sensor and stop the pump if water level is too low.

Some of the later Sonoff basics does not have GPIO pin available, check your board first

This example is using ESPHome 1.10.1 and Home Assistant 0.85.1

Assumptions

As many of the details on here a predicated on existing installations and knowledge the following is assumed:

  • You have installed the relevant environment and it is functional (Home Assisant, esphomeyaml).
  • You need to create your own secrets.yaml file.
  • You are proficient in reading instructions and capable of using a search engine.
  • You will look at the documentation on https://esphomelib.com/ (we may have missed something in this example).
  • This serves only as a guide and errors and outlets are excluded.

Warning

Do NOT connect your device to electricity when programming it. Take care working with electricity at all times

1. Configuration

Here is the configuration with the basic operations outlined above.

## Fish pond sonoff
## filename: fishpond.yaml
# Sonoff basic
# Button toggles pump on/off
# Float sensor stops pump
# Cron'd to run every hour, on the hour for 10 minutes
esphomeyaml:
  name: fishpond
  platform: ESP8266
  board: esp01_1m
  board_flash_mode: dout

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ## use fast_connect of you are connecting to a hidden WiFi network, else comment it out
  fast_connect: true

# Enable logging
logger:
  level: DEBUG

ota:

api:
  password: !secret esplibapi_password

status_led:
  pin: GPIO13

sensor:
  - platform: uptime
    name: "ESP Fish Pond System Uptime"

  - platform: wifi_signal
    name: "ESP Fish Pond WiFi Signal"
    update_interval: 15s

switch:
  ## restart
  - platform: restart
    name: "ESP Fish Pond Restart"

  ## relay / pump
  - platform: gpio
    pin: GPIO12
    name: "ESP Fish Pond Pump"
    id: esp_fishpond_pump

binary_sensor:
  - platform: status
    name: "ESP Fish Pond System Status"

  ## button - toggle relay
  - platform: gpio
    name: "ESP Fish Pond Button"
    pin:
      number: GPIO0
      inverted: true
    # Toggle pump when user presses the Sonoff Button
    on_press:
      - switch.toggle: esp_fishpond_pump

  # onboard header pin - sensor
  # when threshold is reached, turn off
  - platform: gpio
    name: "esp_fishpond_gpio14"
    pin:
      number: 14
      mode: INPUT_PULLUP
    on_press:
      - switch.turn_off: esp_fishpond_pump

## Use time
time:
  - platform: homeassistant
    ## Set your timezone
    timezone: Africa/Johannesburg
    on_time:
      # Switch on on the hour
      - seconds: 0
        minutes: 0
        hours: '*'
        then:
          - switch.turn_on: esp_fishpond_pump
          # Switch off 10 minutes later
          - delay: 10min
          - switch.turn_off: esp_fishpond_pump

2. Programming

Follow the standard way of uploading to your Sonoff basic.

https://d33wubrfki0l68.cloudfront.net/ec421d79c1a70485a0e1aed0d7f2b55a4edcda3f/f4d94/_images/sonoff-fishpond-pump-1-programming.jpg

For USB uploads this generally includes:

  • Modifications (soldering) made on the PCB for USB UART / FTDI uploads.
  • The relevant USB UART / FTDI uploads device connected to you PC and to your Sonoff.
  • Start Sonoff in programming mode.
  • Compile and upload the firmware via USB using esphomeyaml <some-yaml-file> run.

For OTA the generally includes:

  • Ensure device is on.
  • Compile and upload the firmware via USB using esphomeyaml <some-yaml-file> run.

Both options USB and OTA are done by running the command:

esphomeyaml <some-yaml-file> run

More details on programming can be found on Sonoff Basic section

3. Prepping and installing

  • Ensure power is switched off.
  • You can now add your water level sensor wiring to the PCB and have it extrude, SAFELY, next to your connector block.
  • Here it will be the further most pin (GPIO14) you soldered from the toggle button and then pin (Ground) next to it.
  • You can now easily connect and disconnect your liquid level sensor.

Connecting it

  • Connect your water level sensor.
  • Connect your pump to the Sonoff output.
  • Connect your input electrical wiring.
  • Test all connections are securely fastened.
  • You can toggle the on/off of the pump by pressing the toggle button.

Once the pump is running changing the position of the float in the float sensor will cause the Sonoff to stop the pump.

https://d33wubrfki0l68.cloudfront.net/b104ed7be4396b59d75f34495f5db4ca50cf13d1/e1d31/_images/sonoff-fishpond-pump-gpio14.jpg

Wires connected for easier access to connect and disconnect water level sensor

https://d33wubrfki0l68.cloudfront.net/f71dd1a9fa8fc6f3f420607cce601c53f24f9b8e/1905e/_images/sonoff-fishpond-pump-and-sensor.jpg

This needs to be submursed, pump (bio filter) and sensor connected in single housing (icecream tub).

https://d33wubrfki0l68.cloudfront.net/485d81ad39a59fe9d7f4bd477a673a57ffb4897e/e4910/_images/sonoff-fishpond-pump-installed.jpg

In this PVC housing the plates are secured using cabinet door magnets for easier access and maintenance.

  • Ensure you are using a proper and compliant waterproof box to house your electrical equipment (Sonoff basic) in.
  • Ensure you plan to be able to remove the unit with minimal effort should you need to manually USB reflash it again in future.

2.6. Home Assistant

You can now add your device to home assistant via the configurations page and under the Integrations option