- Mon Aug 27, 2018 6:38 pm
#77950
peba wrote:I ordered some a few optocouplers ... I hope this model will do the trick.
Should I pay close attention to the polarities when it comes to connecting the circuit to the optocoupler? I'm not sure if I can read this schematic the right way, but what I'm gonna do is put 3 volts for the GPIO2 for a really short period of time, and I should treat the "LED side" of the optocoupler just like I do with any other regular LED, right? Like putting a 330 ohm resistor in front of it. Kinda looks that the LED's schematic arrow is not pointing the right way, is that possible?
On the other hand, does the polarity matter on the collector side?
The third one is, once I build this "bridge" over the original pushutton on the heater's PCB, for how long should my code send 3 volts to GPIO2? 1 second, maybe a lot less? The way it works now if I push the button for about 5 seconds nothing happens, except when I release it.
The optocouplers you bought are acceptable.
If you are using GPIO2 then you need to connect it this way. The off state will be high. When you want to activate the switch you change the port to provide a low. Normally high, Low to activate, wait for a second, change back to high.
GPIO2 needs to be high at reset for the ESP8266 to execute your code. If you had the led-resistor connected to ground it would be fighting the internal pull up circuit and the board may not start.
The transistor connection (orientation) I showed must be connected exactly that way. The arrow (emitter) must be connected to the ground of the circuit. The collector to the other side of the push button switch. (as shown)
As far as timing you could probably make it as short as a 100mS. Try a manual short press and see what it does. I would go for longer, just because it doesn't really matter.
As far as powering the whole unit from a mechanical relay. As long as the current required is within the capabilities of the relay, then I see no reason for it not to be done that way. But because that would be switching higher power then the additional relay, terminal connections, wiring, must be suited for the purpose.
With the optocoupler the switching is only a small current signal. The wiring can be much smaller. But if you go that route then make sure that there are wide clearances between the wiring on the LED side and the transistor side of the optocoupler. Treat them as two circuits that must not meet. Generous clearances.