Control the speed of a water pump

Good Evening,

Could someone help me with my solar project. I want to be able to control the speed of a water pump depending on the temperature.

The pump I have is Seaflo 41 Series DC Water System Pump 12V 12.5 LPM 35 PSI

I have made it switched on/off with a relay connected to an Arduino configured with esphome.

I want to take this a step further and get it to HIGH / Medium or Low.
Do I need some additional components?

I have tried a Mosfet driver but these seem to burn out.

also tried a different one still the same results.

any help would be much appreciated.

Hi.
I have the same system here, but it’s based on another mosfet (actually, dual H-Bridge) for controlling 2 FAN’s of my electronic box based on temperature. I think you can use the same code…just use another type of temperature sensor since you might be insert into water tube.
In my case, temperture sensor is i2c based.

substitutions:
  hostname: 'esp32_cam_1'
  ssid1: 'Skynet_dvcs'
  ssid2: 'Skynet'


esphome:
  name: exp32_ext_1
  platform: ESP32
  board: esp32doit-devkit-v1

wifi:
  networks:
  - ssid: $ssid1
    password: !secret wifi_dvcs_pwd
  - ssid: $ssid2
    password: !secret wifi_skynet_pwd
  manual_ip:
    static_ip: 192.168.22.58
    gateway: 192.168.22.1
    subnet: 255.255.255.0    

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Exp32 Ext 1 Fallback Hotspot"
    password: "Z7Aw17U0Kh1d"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80
  auth:
    username: jmaurin
    password: !secret web_server_pwd



i2c:
  - id: bus_a
    sda: 21
    scl: 22
    scan: True
    
    
fan:
  - platform: speed
    output: fans_caixa
    name: "Fan Caixa"
    id: fan_caixa

# PC Fan Controller
output:
  - platform: ledc
    pin: GPIO19
    frequency: 10000 Hz
    id: fans_caixa
    


switch:
  - platform: template
    id: fan_low
    turn_on_action:
      - fan.turn_on:
          id: fan_caixa
          speed: LOW
          
  - platform: template
    id: fan_med
    turn_on_action:
      - fan.turn_on:
          id: fan_caixa
          speed: MEDIUM
        
  - platform: template
    id: fan_hig
    turn_on_action:
      - fan.turn_on:
          id: fan_caixa
          speed: HIGH    
    
sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 60s

  # Temperature Sensor
  - platform: am2320
    temperature:
      name: "Temperature Caixa"
      id: sensor_temp
      on_value_range:
        - below: 25.0
          then:
            - fan.turn_off: fan_caixa
        - above: 25.1
          below: 27.0
          then:
            - switch.turn_on: fan_low
        - above: 27.1
          below: 29.0
          then:
            - switch.turn_on: fan_med
        - above: 29.1
          then:
            - switch.turn_on: fan_hig
      
    humidity:
      name: "Umidade Caixa"
    update_interval: 30s
    

   
    
      

Thanks for this, so are you using one of these?

If so how would I wire my pump up to this

I’m assuming provide 12v to 12+ and ground, the positive from the pump to output 1 and the negative back to source.

Output 1 and 2 are for the channel 1, output 3 and 4 are for channel 2.
Output polarity is variable. You can control output polarity (therefore the direction of motor) using IN1 and IN2 pins (for channel 1) and turn it ‘on’ using EN pin (the one that came with jumper).
Since I won’t reverse my motor, I have hard-wired IN1 to +5v and with PWM signal to EN pin I can control the speed of motor.

Evening

is this part of your script for a screen?

i2c:
  - id: bus_a
    sda: 21
    scl: 22
    scan: True

What board are you using that supports ledc?

so just to confirm the wiring diagram.
Battery 12v and grd to input
pump 12v+ to output 1 and 12v- to output2
5v to in1 pin
GPIO19 (PWM signal) to ENA do I need to remove the jumper?

** update I did remove the jumper and was able to control the speed.

OK, I have this all rigged up now I think. how do I know what frequency to set?
frequency: 10000 Hz

The problem I was having was 0.33 wasn’t enough to power the pump and I was just getting a high pitch sound. I increased this to Low = 0.6 Medium 0.7 High = 1

The next problem I have is the L298n heatsink getting extremely, hot but I think that is because my pump is 100w pulling about 8.3 amps.