ESPHOME esp8266 and L298n

Hi,
I am new to both HA and esphome, but needs to have HA to activate 2 motors driving a cover for my robot.
I can program it in arduino ide, but i do not know how to do it in yaml.

the process I need to do:

  1. send a “on” to esp8266 to activate - here the cover i closed and limit switch 1 is activated.
  2. when it is “on” 2 motors should move the cover to open - where it hits limit switch 2. - here it should stay until off.
  3. when I send “off” to esp8266 - then the motors should close the cover and stop when it hits the limit switch 1

Can anyone help me understanding how yaml controls inputs and outputs vs arduino IDE?

TIA.

I also just had the pleasure of using the L298N. I couldn’t get it to work with the H-Bridge component.

Here is my solution:

esphome:
  name: ***********
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: ********
  password: *********
  
logger:
api:
ota:

output:
  - platform: gpio
    id: motor_forward
    pin: GPIO5 # Pin to IN1
  - platform: gpio
    id: motor_reverse
    pin: GPIO4  # Pin to IN2
  - platform: esp8266_pwm    (ESP32 use  ledc)
    pin: GPIO0   # Pin to EAN
    id: motor_speed
    frequency: 1000Hz

number:
  - platform: template
    name: helloween_motor
    id: motor_controll
    min_value: -100
    max_value: 100
    step: 10
    optimistic: true
    initial_value: 0
    on_value:
       then:
          - lambda: |- 
                  if (id(motor_controll).state == 0) {
                    id(motor_speed).set_level(0.0);
                    id(motor_forward).turn_off();
                    id(motor_reverse).turn_off();
                  } else {
                    if (id(motor_controll).state < 0) {
                      id(motor_speed).set_level((id(motor_controll).state *-1)/100);
                      id(motor_forward).turn_on();
                      id(motor_reverse).turn_off();
                    } else {
                      id(motor_speed).set_level((id(motor_controll).state)/100);
                      id(motor_forward).turn_off();
                      id(motor_reverse).turn_on();
                    }
                  }

This slider then appears in the HA

example:
off:
01
100% forward
02
60% reverse
03

Pin to IN1 - I understand, it is located beside the power input on L298N
Pin to IN2 - I understand, it is located beside the power input on L298N
Pin to EAN - What is this and where is it located?

images (10)

Google image “thing X pinout” usually gets you a labelled diagram pretty quick.

The EN’s control motor speed

“The ENA pin controls Motor A and the ENB pin controls Motor B. When these pins are HIGH, power is output to the motor. By using PWM, you are turning power on and off very quickly to adjust the speed of the motor. The longer the PWM duty cycle is, the faster the motor will turn.”

https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.bananarobotics.com/shop/How-to-use-the-L298N-Dual-H-Bridge-Motor-Driver%23:~:text%3DThe%20ENA%20pin%20controls%20Motor,faster%20the%20motor%20will%20turn.&ved=2ahUKEwiz6Mauvo7-AhVvS2wGHbGWAZgQFnoECFsQBQ&usg=AOvVaw0WCwB1IIvv1IFh68G6IMZp

The ones I have are labelled pretty clearly like this. If I recall correctly you have to remove the jumper.