I have a new project to independently open and close 4 vents in my greenhouse using 4 12 VDC motors. Due to the number of GPIOs required, it will use 2 ESP32s and will be integrated into my 2 HA instances. I don’t know ESPHome (yet) and don’t know much about electronics, so I would greatly appreciate all comments and suggestions. I will post more details, schematics and ‘code’ when they are available.
I am using 2 ESP32-DEVKITC-V4 controllers. Each exposes 24 GPIOs.
I am using 2 Toshiba TB67H400ANG controllers. Each can control 2 motors. Here is a link to the datasheet: datasheet Each controller requires 9 or maybe 11 GPIOs. The 9 controller logic pins have 100K resistors so only use 33 microamps each. Logic pin settings (H vs L) control the output voltage polarity (motor rotation direction). The 2 pins that I am not sure about are output current sense pins, used for monitoring, feedback control and overcurrent protection. They would be connected to GPIOs that have analog to digital converters, but I am not sure that I need them. Comments?
After I received the motor controllers I learned that they are SDIP, not DIP so they don’t fit breadboards or perfboards. I found adapters here: SDIP to DIP adapter I received them quickly.
I am using 8 limit switches (open and close x 4 vents). limit switch I tested some and found them around 1 msec bounce time now. Assume 10-20 msec lifetime.
A big question was how to wire the GPIOs to the limit switches. Ideally 2 GPIOs per limit switch (1 output, 1 input), but that exceeds the number of available GPIOs. The other extreme is 2 GPIOs per 2 limit switches (1 output connected to both COM terminals, 1 input connected to both NO terminals). This has a problem that when the output GPIO is enabled, a limit switch is already tripped from the current position so the input GPIO is immediately triggered, shutting down the operation. Delaying enabling the GPIOs for 500 msec addresses this problem by giving the motor time to move the vent and free the tripped limit switch, but this adds complexity to the software. I decided to use 2 output GPIOs and 1 input GPIO per 2 limit switches. The output GPIOs will be connected to the COM terminals of the open and close limit switches (1-1) but both limit switch NO terminals will be connected to the same input GPIO. Software will have to ‘know’ the transit mode (open vs close) in order to interpret the input GPIO meaning. The action is always the same (turn the motor off) but it also has to signal HA that the appropriate operation has completed.
I plan to debounce the limit switches in hardware following this article:hardware debounce It is standard but has a good explanation of the details. I won’t be using the Schmitt trigger.
Here is a link to the motors: vent motors The output shaft rotates at 4 RPM under load, which is 15 seconds per revolution. I need a bit under 1/2 revolution so I guess 5-6 seconds transit time. The motor has 35 kg.cm (350 oz-in) of torque, which should be plenty. I think that I read somewhere (can’t find it now) that the stall current is 1.6 A. It is self locking so when it is stopped (open or closed) it should stay in place.
When a motor starts or stops a transit the microcontroller must send an event to HA which will keep a current transit count. When the count changes from 0 to 1 it will turn the 12 VDC power supply on and when it changes from 1 to 0 it will turn the power supply off. It is a 120 W (10 A) power supply that will probably generate a lot of heat. The SSR that switches the power supply input power has a logic level input pin so it can be controlled by a GPIO (not sure about current requirements, may need a resistor). I might need a small fan and ports in the box to keep the ESP32s cool.
When I started working with ESPHome I watched it build my first project. ESPHome compiled a lot of C++ code using PlatformIO. If I run into a limitation of ESPHome, I think that I should be able to define a project in VSCode and manually build the project. I worked in C++ for more than 30 years and VSCode for 2.




