Sorry if this is a very simple question. I’m just getting started with Home Assistant and ESPHome. I successfully added a temperature sensor and camera to Home Assistant, now I’m trying to automate opening and closing a door for a chicken coop.
I’m using a motor controller board like the TI DRV8833. For one motor, two GPIO inputs are needed, IN1 and IN2. If IN1 high and IN2 low then motor spins forwards. If IN1 low and IN2 high then motor spins backwards.
So far, I’ve tried the following. The “show logs” in ESPHome show that the device has booted succesfully. However I don’t see the two switches in Home Assistant. I saw that one new device was found, but there are no entities attached to the device. Have I made a mistake in this code, for having two switches show up in my Home Assistant dashboard?
Stage 1 is to just add a switch to have add two switches for motor-forwards and motor-backwards
Stage 2 (once I get stage 1 working) - I want to add limit switches and timing. I have a switch that gets closed when the door gets all the way up and another when it gets all the way down. I would like to add logic where motor forwards runs the motor only until the upper switch is hit. Likewise motor-backwards should run the motor only until the lower switch is hit. A timeout will also be necessary so that the motor doesn’t run forever in case of switch error
internal ( Optional , boolean): Mark this component as internal. Internal components will not be exposed to the frontend (like Home Assistant). Only specifying an id without a name will implicitly set this to true.
Ah great - thanks @nickrout and @samnewman86 for the fast response. I’ve made the fix - switches show up now and I’m successfully lifting and lowering a 3lb weight. Stage 1 complete.
Do I need to add a pulldown resistor to GPIO0 and GPIO2? (Actually I think boot fails if pulled LOW). I’m relatively new to electronics - is there a “floating pin” issue here?
Note that I’m using an esp01s. As far as I understand, the esp01s breaks out 2 normal GPIOs (GPIO0 and GPIO2), but RX and TX can be used as GPIOs as well (GPIO3 and GPIO1 respectively). Do I need to set GPIO3 and GPIO1 to output mode? I guess I’ll need them for the endstop switches
I’d like to have the door raise and lower at 7am/7pm respectively. Is it common to do this within the sketch on the device itself or to have Home Assistant make the calls. Ideally I’d have this logic on the device itself in case Home Assistant or the router are down.
Will an endstop switch even be possible with an esp01s?
I’ve just seen on esp8266-pinout-reference-gpios that GPIO 0, 1, 2, 3 all either need to be high at boot or fail if pulled low at boot. The endstop switches will essentially force the pin to be pulled high or low (depending on if the switch is engaged or not).This means that if the esp01s power cycles while the pin is pulled low, the device won’t boot.
Is there any way around this? Are there any tricks to get an endstop switch working with an esp01s?
I’ve nearly found a solution with the esp01. The only remaining thing is - how can I perform an action after the endstop is hit?
I have the door working, with endstops. I invert the endstop switches so that GPIO 1 and 3 are default high, but low when the endstop switch is hit.
The remaining problem is that the esp won’t boot if it power cycles while the door is at the top or bottom. To fix this, I would like to have the door reverse direction for a brief period after hitting the endstop. That way it will leave GPIO 1 and 3 pulled high, except for the a brief moment while the switch is hit. I’m fine with the small gap that will be left from the door leaving the endstop position.
Remaining problem
The biggest issue I still have is with wifi connectivity. I’m right on the limit of the reach of my wifi. In testing, it seems like if wifi cuts out once the door is moving, the endstop no longer stops the motion. Luckily I observed this when testing the endstop with my finger and was able to yank the power cord before damage was done. If this were to happen in the real world, it would keep running the motor until the time limit and break the plastic bracket. Does the endstop require wifi to activate?