GithubHelp home page GithubHelp logo

Comments (16)

shafr avatar shafr commented on June 14, 2024 2

It took me 2 years to wrap my head around this thing (Mostly I was afraid to drill my window frame and was waiting for correct 3d model, PCB was ready and waiting).

I'm using L293D motor with 28BYJ-48 motors.

# IN1 = 16
# IN2 = 12
# IN3 = 15
# IN4 = 01

stepper:
  - platform: uln2003 
    id: my_stepper
    pin_a: 12 
    pin_b: 16
    pin_c: 01
    pin_d: 15
    max_speed: 250 steps/s
    sleep_when_done: true

    # Optional:
    acceleration: inf
    deceleration: inf

switch:
  - platform: gpio
    pin: 02
    id: red_pin
  
  - platform: template
    name: "Set position 250"
    turn_on_action:
      - stepper.set_target:
            id: my_stepper
            target: 250

  - platform: template
    name: "Set position -250"
    turn_on_action:
      - stepper.set_target:
            id: my_stepper
            target: -250     
  1. First of all - pin order here is in1,in3, in2,in4.
  2. sleep_when_done is crucial! Or your motor will overheat.
  3. Consumption - idle 0.09 A, with motor spinning - 0.3 A.
  4. Forget about 5v or 9v for driving motor if you will be moving something like blinds - torque wouldn't be powerful enough. Only 12 volts.

from feature-requests.

workingmanrob avatar workingmanrob commented on June 14, 2024 1

Hi guys,

I think I am also interested in this integration. I have recently purchased a few nodemcu motor shield boards and I'm pretty sure it's the same chip used. Oh I have 293 instead but I assume it's quite similar.

https://hackaday.io/project/8856-incubator-controller/log/29291-node-mcu-motor-shield

The shield is based on the L293D quadruple high-current half-H drivers typically used to drive motors.

This is supposed to support either a single stepper motor or two dc motors. I'm just trying to use a single dc motor. Seems to be a popular kit for making a wifi remote controlled car.

https://www.instructables.com/id/Motorize-IoT-With-ESP8266/

Will try that snippet from Otto and see if things move.

Thanks again!

Oh found this - http://drzzs.com/diy-window-shades-motorized-automated/

I really just want motorized curtain control..

from feature-requests.

OttoWinter avatar OttoWinter commented on June 14, 2024 1

@danpowpow See the response I posted above.

@RIKWEBB Looks like the L293D is essentially the same as the L298, so also look at said post.

from feature-requests.

glmnet avatar glmnet commented on June 14, 2024 1

It doesn’t make sense for a motor using this ic to switch inputs quickly. That’s why I’m asking a different issue with your code posted there so we can provide feedback related to it.

from feature-requests.

OttoWinter avatar OttoWinter commented on June 14, 2024

Yes, that integration is planned - and it wouldn't even be too hard to integrate.
The issue is that a whole "motor" abstraction layer would have to be created first and that's a lot of work since there are so many types of motors.
For now, you can also control it using the PWM components. For example

output:
- platform: gpio
  pin: D1
  id: direction_pin
- platform: esp8266_pwm  # or ledc if on ESP32
  pin: D2
  id: speed_pin

# In some call:
# Set to forward dir
- output.turn_on: direction_pin
# Turn on motor
- output.set_level:
    id: speed_pin
    level: 100%
# Let motor drive for a big
- delay: 1s
# Turn off motor
- output.turn_off: speed_pin
# Repeat for Oóther direction, this time with turning off the direction pin

from feature-requests.

Qu3uk avatar Qu3uk commented on June 14, 2024

Great! I'll give this a try thanks!

from feature-requests.

danpowpow avatar danpowpow commented on June 14, 2024

Hi @OttoWinter !
I absolutely love esphome - well done on such a great piece of work :-)
has there been any development on this? i'm looking at using hbridges to give me dimming control of some polarity-reversing led string lights. I have code working on arduino, but am hoping to move to esphome for better hass integration.
the code i'm using uses three gpio from the arduino going to the L298N modulem, IN1 IN2 and PWM. i've repurposed code from here:
https://tronixlabs.com.au/news/tutorial-l298n-dual-motor-controller-module-2a-and-arduino/
thanks again for esphome!

from feature-requests.

RIKWEBB avatar RIKWEBB commented on June 14, 2024

Any integration planned for the L293D?
This would help create an easy solution for Shades / Blinds with these
ARCELI L293D Wifi Motor Drive Expansion Board Shield Module For NodeMCU ESP-12E ESP8266
by QC EU
Learn more: https://www.amazon.co.uk/dp/B078CPZDW1/ref=cm_sw_em_r_mt_dp_U_OycyDbXBX2GX4

from feature-requests.

danpowpow avatar danpowpow commented on June 14, 2024

thanks for the response @OttoWinter :-)
i'm not sure i completely follow you though. I understand ledc for pwm on the esp32, and have succeeded where that is concerned. the main issue i'm facing however is that in order to get my led festoon to light all the bulbs i have to keep switching the polarity very fast to the in1 and in2 pins of the L298N. not polarity reversing results in only 1/2 of the string working, as each led is wired up in reverse to that last one. the arduino code is dead easy:
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
but i can't quite see how to run this bit (or equivalent) in esphome. i've tried using the loop() iteration but it isn't fast enough.
Is esphome the right tool for this job?
thanks again,
dp

from feature-requests.

glmnet avatar glmnet commented on June 14, 2024

@danpowpow that doesn’t seem like a motor. Would you like to open a new issue and share your code there. People are willing to help

from feature-requests.

danpowpow avatar danpowpow commented on June 14, 2024

hi @glmnet yes it isn't a motor i'm driving, it's an LED festoon light string, with which I use an L298N H Bridge controller to work. This thread was/is for native L298N H Bridge motor controller support within esphome, which is exactly what i'm looking for.

from feature-requests.

cnctech avatar cnctech commented on June 14, 2024

I hope that I am asking this question in the right place. It's my first time using this.
I have HASSIO up and "somewhat" running, and have been looking into a good closed loop DC motor control. After experimenting with EspHome, I feel that this is one of the most advanced and flexible options to do much control. Has anyone tried using the L298 with a DC gear motor with encoder, and using the "Rotary Encoder" function in EspHome, along with "Cover" templates to set "Home" for position? I do not want to use stepper motors.

from feature-requests.

glmnet avatar glmnet commented on June 14, 2024

I hope that I am asking this question in the right place. It's my first time using this.
I have HASSIO up and "somewhat" running, and have been looking into a good closed loop DC motor control. After experimenting with EspHome, I feel that this is one of the most advanced and flexible options to do much control. Has anyone tried using the L298 with a DC gear motor with encoder, and using the "Rotary Encoder" function in EspHome, along with "Cover" templates to set "Home" for position? I do not want to use stepper motors.

Certainly you can use ESPHome here, I haven't tried using the rotary encoder to control the position but that sounds clever, you'll have to implement the closed loop yourself as ESPHome does not provide any PID algorithm yet.

from feature-requests.

shafr avatar shafr commented on June 14, 2024

Well it worked with exactly one chip.
I'm uploading the exact same code to another and motors have no torque at all. That is very very confusing.

UPD: Some corrupted L298 drivers.

from feature-requests.

glmnet avatar glmnet commented on June 14, 2024

@shafr this FR is about the L298 Dual H Bridge which is a driver not suitable for the 28BYJ-48 motor
The driver is meant for a standard DC motor which can be powered directly or reversed so the turn direction changes. The motor you are using in contrast is a stepper motor, hence you're using the stepper integration. I don't know what will happen if you try to use the L298 with the stepper, but it will not work well for sure.

from feature-requests.

wmnl25 avatar wmnl25 commented on June 14, 2024

Yes, that integration is planned - and it wouldn't even be too hard to integrate.
The issue is that a whole "motor" abstraction layer would have to be created first and that's a lot of work since there are so many types of motors.
For now, you can also control it using the PWM components. For example

output:
- platform: gpio
  pin: D1
  id: direction_pin
- platform: esp8266_pwm  # or ledc if on ESP32
  pin: D2
  id: speed_pin

# In some call:
# Set to forward dir
- output.turn_on: direction_pin
# Turn on motor
- output.set_level:
    id: speed_pin
    level: 100%
# Let motor drive for a big
- delay: 1s
# Turn off motor
- output.turn_off: speed_pin
# Repeat for Oóther direction, this time with turning off the direction pin

Can confirm that the L298 works fine this way. I use it to drive the lid of a (now smart) simplehuman bin. I adjusted the code a little bit so the lid can both be opened and closed. Shows up as cover in HA.

output:
  - platform: esp8266_pwm
    pin: D5
    frequency: 1000 Hz
    id: sh_speed_pin
  - platform: gpio
    pin: D7
    id: sh_direction_pin1
    inverted: true
  - platform: gpio
    pin: D8
    id: sh_direction_pin2
    inverted: true

cover:
  - platform: template
    name: "Simplehuman bin"
    id: lid
    open_action:
      - light.turn_on: 
          id: ws2811led
          effect: strobe
      - output.turn_on: sh_direction_pin2
      - output.turn_on: sh_speed_pin
      - delay: 2s
      - output.turn_off: sh_direction_pin2
      - output.turn_off: sh_speed_pin
    close_action:
      - output.turn_on: sh_direction_pin1
      - output.turn_on: sh_speed_pin
      - delay: 200ms
      - output.turn_off: sh_direction_pin1
      - output.turn_off: sh_speed_pin
      - delay: 1s
      - light.turn_off: ws2811led
    stop_action:
      - output.turn_off: sh_direction_pin1
      - output.turn_off: sh_direction_pin2
      - output.turn_off: sh_speed_pin
    optimistic: true
    ```


from feature-requests.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.