Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Grove tb6612 fng #4797

Merged
merged 45 commits into from Jul 12, 2023
Merged

Conversation

max246
Copy link
Contributor

@max246 max246 commented May 9, 2023

What does this implement/fix?

I am working with this handy motor driver which can drive DC and Stepper motors : https://wiki.seeedstudio.com/Grove-I2C_Motor_Driver-TB6612FNG/
The good thing about this driver is the connectivity to be used over i2c rather than the usual hbridge and you can set the motor driver to standby to stop wasting power.

Methods implemented:

  • grove_i2c_motor.motor_run
  • grove_i2c_motor.motor_break
  • grove_i2c_motor.motor_stop
  • grove_i2c_motor.standby
  • grove_i2c_motor.no_standby

At the current state, only DC motor is implemented but the code for the stepper motor is already ready to be expose via an action. I dont currently have a stepper motor so in my case I can only test a DC motor

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • [ x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#2906

Test Environment

  • ESP32
  • ESP32 IDF
  • [ x ] ESP8266
  • RP2040

Example entry for config.yaml:

i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a
grove_i2c_motor:
    id: test_motor
    name: motor_outside
    address: 0x14

switch:
  - platform: template
    name: open_vent
    id: open_vent
    optimistic: True
    on_turn_on: 
      then:
        - grove_i2c_motor.motor_run:
            channel: 1
            speed: 255
            direction: BACKWARD
            id: test_motor
        - delay: 10s
        - switch.turn_on: stop_motor
        - switch.turn_off:  open_vent



# Example config.yaml

Checklist:

  • [ x ] The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

probot-esphome bot commented May 9, 2023

Hey there @max246,
Thanks for submitting this pull request! Can you add yourself as a codeowner for this integration? This way we can notify you if a bug report for this integration is reported.
In __init__.py of the integration, please add:

CODEOWNERS = ["@max246"]

And run script/build_codeowners.py

(message by NeedsCodeownersLabel)

tests/test3.yaml Outdated Show resolved Hide resolved
Copy link
Member

@jesserockz jesserockz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, just a few "tips" to align better with the codebase =)

esphome/components/grove_i2c_motor/__init__.py Outdated Show resolved Hide resolved
esphome/components/grove_i2c_motor/grove_i2c_motor.cpp Outdated Show resolved Hide resolved
esphome/components/grove_i2c_motor/grove_i2c_motor.cpp Outdated Show resolved Hide resolved
esphome/components/grove_i2c_motor/grove_i2c_motor.cpp Outdated Show resolved Hide resolved
esphome/components/grove_i2c_motor/grove_i2c_motor.cpp Outdated Show resolved Hide resolved
esphome/components/grove_i2c_motor/grove_i2c_motor.cpp Outdated Show resolved Hide resolved
esphome/components/grove_i2c_motor/grove_i2c_motor.h Outdated Show resolved Hide resolved
max246 and others added 6 commits May 14, 2023 22:23
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
@max246 max246 changed the title Feature/grove tb6612 fng Add support for Grove tb6612 fng May 14, 2023
@max246 max246 requested a review from jesserockz May 17, 2023 16:52
@max246
Copy link
Contributor Author

max246 commented Jul 8, 2023

@jesserockz could this be approved?

Copy link
Member

@jesserockz jesserockz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the actions to the test yaml file too

@max246
Copy link
Contributor Author

max246 commented Jul 11, 2023

Please add the actions to the test yaml file too

Should be all good now

jesserockz
jesserockz previously approved these changes Jul 12, 2023
@jesserockz jesserockz merged commit e0fd8cd into esphome:dev Jul 12, 2023
25 checks passed
@jesserockz jesserockz mentioned this pull request Jul 12, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants