ESPHome L298N examples with PWM

Home Assistant automation projects, questions, etc. go here.
Post Reply
AndrewR
LED-Curious
LED-Curious
Reactions:
Posts: 2
Joined: Mon Apr 18, 2022 2:39 am

Hey Everyone,

First post, so Hi :)

I am wondering if anyone has any good ESPHome examples which include the PWM configuration for L298N drivers ?

Basically I dont know if i can even do this natively in ESPHome, but I am still learning. I am trying to control peristoltic pumps using the L298N driver so i can zone in the dosage delivered via the pumps.

I have found -
https://esphome.io/components/fan/hbrid ... ight=l298n
https://esphome.io/components/output/esp8266_pwm.html

The problem I am having is (at least in my brain), linking the PWM control with the 2 required inputs for the L298N (forward and backwards, when i only really care about forwards)

Any help or example code is greatly appreciated.
stud
LED Lover
LED Lover
Reactions:
Posts: 143
Joined: Wed Jun 03, 2020 4:19 pm
Location: Canada

Code: Select all

esphome:
  name: peristalticpumpa
  platform: ESP32
  board: mhetesp32devkit

wifi:
  ssid: "***"
  password: "***"

# Enable logging
logger:

output:
  - platform: ledc
    pin: GPIO32
    frequency: 1000 Hz
    id: pump_1_pwm
    min_power: 0
    max_power: 0.7
    
fan:
  - platform: speed
    output: pump_1_pwm
    name: "Dosing Pump 1"

Code: Select all

esphome:
  name: peristalticpumpa
  platform: ESP32
  board: mhetesp32devkit

wifi:
  ssid: "***"
  password: "***"

# Enable logging
logger:
output:
  - platform: ledc
    pin: GPIO19
    frequency: 5040 Hz
    id: ventilation_fan_pwm
    min_power: 0.0001
    max_power: 0.25
  - platform: gpio
    pin: 21
    id: gpio_21
    inverted: yes

#  - platform: speed
#    output: ventilation_fan_pwm
#    name: "AC_Infinity Blower1"
light:
  - platform: monochromatic
    output: ventilation_fan_pwm
    name: "AC_Infinity Blower1"

esp32_ble_tracker:
AndrewR
LED-Curious
LED-Curious
Reactions:
Posts: 2
Joined: Mon Apr 18, 2022 2:39 am

Thank you for responding with the code. I am hoping to get a chance to try this tomorrow. I will see how i go :)

Thank you once again.
Post Reply