Arduino Forum

Using Arduino => Project Guidance => Topic started by: coogle on Jul 26, 2017, 06:27 am

Title: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 06:27 am
Hello All!

I am hoping someone can help me out here. I'm trying to use an ESP8266 to open and close my garage door but I'm having some problems.

I'm trying to wire this into the hard-wired control panel inside of the Garage. This consists of two leads with ~16V across them that, when shorted out, triggers the door to open or close depending on it's current state. To be more specific, it appears that the control panel's three buttons basically have three functions:

1) Standard push button shorts the two leads, and door opens and closes based on state

2) Another standard push button shorts the two leads but there is a 10uF capacitor in the circuit so I assume this means it's "pulsing" the short at some frequency. This one turns on the built-in light bulbs of the opener

3) A third standard push button does the same thing as #2, except at a different frequency using a 100uF capacitor. (This is for the "lock" feature)

I figured I should be able to make this work pretty easily with a 2N2222 transistor and one of the 3.3V GPIO pins. My ultimate hope is I can, by pulsing my GPIO high/low to simulate the capacitor's in the original circuit, implement the three functions -- but honestly I'll be happy if I can just get the door to open and close which is a simple short to ground.

I'm attaching my schema and would love some advice. It seems like this should be working to me but I'm still wrapping my head around transistors so maybe I'm messing up.

(https://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220241)

(note my first upload was the wrong schema, corrected!)

Any help?

John

Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: INTP on Jul 26, 2017, 06:53 am
What problems are you having?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: scottyjr on Jul 26, 2017, 01:50 pm
This is a project I have in use. I used a tiny relay that has it's N.O. contacts across the local wall switch contacts. - Scotty
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: TomGeorge on Jul 26, 2017, 02:06 pm
This is a project I have in use. I used a tiny relay that has it's N.O. contacts across the local wall switch contacts. - Scotty
An excellent idea, you do not know what sort of signal is in those wires at the pressbutton and using a transistor may cause problems.
Use a normally open set of contacts on a relay in parallel with the button contacts, and get the ESP to switch the relay, that way the circuits are isolated from each other.
Tom... :)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 05:28 pm
I understand that I could probably easily solve my problem just using a relay, at least part of it -- however I'd really like to understand why the solution I came up with isn't working as much as I'd like to see something work at all.

To be specific: The circuit just doesn't work at all -- no door open/close or anything.

To help illustrate the problem and my goals, here is a schema of the original factory-manufactured control board that is typically installed. As you can see it's an extremely simple control board so I don't see any reason at all why this can't be replaced directly with all of it's features using any reasonable micro-controller.

So looking at this schema, and looking at my replacement, why is it that I can't seem to get this to behave the same?

(https://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220295)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: TomGeorge on Jul 26, 2017, 06:01 pm
Hi,
There would be more to it than what is in your schematic, where is the controller IC that controls the motor?

The main problem is that the 3 switches in  the circuit you have supplied is  switching the positive of the supply.
The addition of the transistor switching you want to use is switching from gnd or the negative of the supply.

The factory schematic must be more detailed than that simple switch diagram.

Can you tell us your electronics, programming, Arduino, hardware experience?

A relay would be your best and safest solution, for your limited knowledge of the circuit and experience.

Tom... :)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 06:20 pm
Sure!

So I've built a lot of IoT devices from 16 port smart relays to weather monitoring stations and feel pretty comfortable around a soldering iron. I'm formally trained in digitals, and recently wrote my own IOT foundation library now available from the Library Manager called CoogleIOT. For my day job I'm a programmer, core PHP developer with 20 years of C, PHP, etc.... I actually built exactly this sort of device for an automatic gate using an ESP8266-01 and it worked perfectly so I'm struggling to understand what I'm messing up here! In that case the gate's control board would open the gate in "exit" mode if you shorted a lead to ground and I used 2n2222 to do so.

Where I am weak is it's been maybe 20 years since I've had to try to build circuits from simple component parts. I have a pretty decent understanding of how they work conceptually but I'm trying to regain the functional knowledge -- hence I am not so much interested in just solving my problem with a relay and more interested in understanding why I'm failing. I'm happy to read and have -- but I've hit a wall here.

You're absolutely correct the schema I provided is the circuit board that plugs into the two leads coming from the garage door opener itself mounted in the rafters. I mean, the "inside" controls for the garage which let you open/close the garage door and turn on the lights, etc. from within the garage. I am trying to replace that control panel with a WiFi device (and separate from this conversation add some reed switches to detect open/close, etc).  In the sense that there are two wires coming from the garage door opener in the rafters, and there is 16V across them which plugs into the schema I provided yes -- that schema is 100% complete. Obviously the garage door opener in the rafters has a lot more circuitry in it to actually do something with the signal produced from the control panel!

John
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 06:28 pm
As you can see from the attached, I'm basically trying to replace this board with an ESP8266-12E to at a minimum replicate the function of the "Command" / Open button which, other than an LED and resistor in the way just shorts to ground as described. Ideally I'd like to simulate all the buttons (the other two modulated by a 1uF and 22uF cap). From there I can add two reed switches to two other GPIOs and control all of it over MQTT.

(https://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220304)
(https://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220306)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Jul 26, 2017, 06:58 pm
I guess the easiest way out would be to replace those buttons by transistors (check the voltages - then solder the transistor emitter and collector to the respective sides of the switch, and connect the basis to your ESP8266 with appropriate resistor, 1k would do).

Also connect the ground to your ESP's ground - but it's not necessarily the case that the ground is connected to this board at all.

That failing: follow the wires of that PCB and draw out an accurate schematic of it, then try to rebuild that. Again be aware that the two holes (screw connectors?) may not be Vcc or GND, but be part of another circuit.
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 07:05 pm
That's exactly what I did (see my original circuit) and it isn't working :) 1k resistor connected to GPIO to 2N2222 base, and the Collector attached to the V+, Emitter connected to V-. ESP8266's ground also connected to V- of the leads.

That doesn't implement all three buttons, but it *should* as far as I can tell implement the "open" / "command" switch which just shorts to ground.

It's worth noting that in my testing if I connect the base of the 2n2222 to V+ (through the 1k resistor, leaving the C and E the same) instead of to my GPIO, it works.

John
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: Riva on Jul 26, 2017, 07:09 pm
I don't think your schematic in #4 is correct as you show the command button closing through the LED/resistor but the PCB shows a direct connection to GND? when the switch closes. Also the capacitors have there negative terminals connected to each other and not to ground as you show.
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 07:25 pm
The command button traces are a bit hard to see, but there is a trace between the command button on top (bottom leads) to the LED, which goes to the resistor which goes to V-.

Perhaps one big assumption I am making here that you've pointed out with the capacitor comment, is that I am assuming V- and ground are the same thing and they aren't? That said, looking at my schema in #4 if you assume the "power" is the V+ and V- (which measure 16V across them), it is correct. Consider the "power" just a representation of those two leads.

Attached is a revised schematic which more accurately represents the board (power removed) and what I'm trying to replicate using an ESP.

(https://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220318)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Jul 26, 2017, 07:42 pm
I think this is the correct schematic of that PCB:
(http://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220321)
The interesting bits:
- two switches are in series with a capacitor, one switch just connects the two points,
- there's an LED + resistor in parallel with the switches (it doesn't appear to be switched by the button S1).
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 07:51 pm
Opps you are correct on the LED my mistake! It doesn't really have an effect on the circuit.

You are also correct on the three switches. One shorts the two leads directly and the other two short the leads but use a capacitor to create a signal. The rate of discharge of the caps determines the behavior interpreted by the garage door base.


The question still remains however, which is how to replicate this circuit using a microcontroller?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: INTP on Jul 26, 2017, 07:55 pm
What do you mean replicate it? Complete replacement so you just have the bell wire running to your ESP circuit and no panel?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 07:57 pm
Well my goals are sort of incremental here.

Primary goal: Open and close the garage door from ESP8266 GPIO by closing the "Command" switch momentarily.

Secondary Goal: Implement the other two features as well by recreating the single produced by the switch/cap combinations of the other two switches.

The intent is a complete replacement of this circuit board. If anything, I will (separately) add a different momentary switch across the leads to open/close the door in the event the ESP8266 crashes or whatever.
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: INTP on Jul 26, 2017, 08:01 pm
So make your own board with identical components and use optocouplers in parallel with the buttons so you maintain manual control and you isolate the ESP from the higher voltage the garage opener works at.
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Jul 26, 2017, 08:03 pm
It doesn't really have an effect on the circuit.
I wouldn't be so sure about that.

Quote
You are also correct on the three switches. One shorts the two leads directly and the other two short the leads but use a capacitor to create a signal. The rate of discharge of the caps determines the behavior interpreted by the garage door base.
How did you figure out that part? Did you attach a scope to it to follow the signal in time and see what it really does?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 26, 2017, 08:22 pm
No I just deduced that because it makes sense. All three close the two leads, one of them closes the two leads directly, the other two do so but first they must charge a cap. The result on the leads would be a waveform of signal, would it not? (btw, if you just short the leads together it closes the door -- so yes, the LED placement was wrong in my schematic, but it probably didn't matter in this case).

The rest of the circuit doesn't know anything else besides what's happening on those two wires. I suppose it could be doing something a lot more complicated but that seems way overkill. Either way that was a secondary concern for me (as I don't use either feature besides open/close) so I was going to play with that once I got the other part working.

I ordered some octocouplers and I'll play with it that way. You are absolutely correct probably the best answer here is to use them in place of switches and keep the caps,etc. as they are in my board. I've got enough GPIO pins on the ESP8266 to use three of them and still have my reed switches. I may or may not bother implementing parallel momentary switches for all three -- like I said I don't really care about two of them.

To answer my original question, which is why my transistor solution didn't work -- is the answer then because I incorrectly assumed that the V- lead was ground?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: Riva on Jul 27, 2017, 09:41 am
What about your code? How long are you powering the transistor on/off for as this will affect the action taken as a button press.

Are the switches momentary close or momentary open (or a mixture of both)

Do you need a resistor in the emitter or collector line to limit current through the transistor?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 28, 2017, 11:29 pm
Hello all!

This has been much more difficult than I expected!

Update: So I went off and ordered some optocouplers per the suggestion of INTP and created the following circuit with it. Unfortunately it does NOT work!! Please see the attached schema of what I've built.

I measured the voltage across the V+ V- leads of the garage door wires and it is actually about 22V DC across the leads. When I activate the optocoupler it drops to 0.5V but the garage door doesn't open.

Considering the original control circuit it seems to me, all I should have to do is short out these two contacts! Is it possible that the 0.5V is causing the control board not to recognize the short? Is there something I can do to here I'm missing?

Again I'm just as interested in why this doesn't work as a solution (i.e. just use a relay).

(https://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220548)

Thanks!

John
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 28, 2017, 11:38 pm
What about your code? How long are you powering the transistor on/off for as this will affect the action taken as a button press.

Are the switches momentary close or momentary open (or a mixture of both)

Do you need a resistor in the emitter or collector line to limit current through the transistor?
The switches are both momentary close, and my code sets the trigger pin to HIGH for 1 second. For what it's worth, if I short the leads to the opener there is no delay (as soon as they short the door closes) so it should be plenty of time.

Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: INTP on Jul 29, 2017, 01:39 am
Yeah, the duration doesn't matter for button press for the 'open' command. That is, unless you can press it super duper quickly to trigger the other commands that are controlled by caps on a DC (I.e., nothing passes a cap in DC, but there is a little bump)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: TomGeorge on Jul 29, 2017, 02:18 am
Hi,
Can you put your DMM across the RED and WHITE terminals and record the DC voltages and record the AC voltages when you have no buttons pressed and each button pressed?

Hold each button for 3 or 4 seconds please.

Thanks.. Tom.. :)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 29, 2017, 05:16 am
Yeah I'll hook up the original board and take those measurements tomorrow and post. It's really quite confusing! Nothing about this circuit looks at all complicated..
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: TomGeorge on Jul 29, 2017, 05:19 am
Hi,
Sending three different instructions down two wires can get complicated, your button board may work on a current rather than voltage basis.
Or AC/DC.

Tom.. :)
PS A relay would be easier.   lol... :)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Jul 29, 2017, 06:37 am
Again I'm just as interested in why this doesn't work as a solution (i.e. just use a relay).
If you have the complete schematics of the rest of the control system, we may be able to understand why it doesn't work.

As per other posters, I'm also suspecting that there's an AC involved. Three buttons on two leads, two capacitors - there's some trickery behind this that I don't know. Having AC of course causes problems with your optocoupler, which effectively is a diode as well.

So just thinking about this: what happens if you take two diodes in parallel, opposite biased, and use that to short the leads? Then of course you still have the 0.7V or so drop, but at least AC passes more or less unhindered. If that works, it should also work by using two optocouplers to replace a push button.
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Jul 29, 2017, 06:38 am
PS A relay would be easier.   lol... :)
And a lot less fun :-)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Jul 31, 2017, 07:29 pm
Thank you all for your ideas and suggestions so far!

So it turns out whoever thought of AC here was right. I hooked the original control board up and this is what I found:

33V AC across the Red and White leads with no buttons pushed

~0.7 AC across the Red / White leads with open/closed pushed

~27V AC across the leads with "Light" pushed

So based on this, in theory, I should be at least able to get the open/close working with a combination of two optocouplers triggered at the same time across both leads.

Here's the next question though -- we are quickly leaving my world of understanding so this is a lot of fun! I have many questions now. Let's start with this one..

I'm super confused as to how the polarized components (i.e. both caps and the LED) are functioning in this AC circuit. The LED I sort of get (it's only being lit by the current going in a single direction since it's a diode), but I'm very confused on the caps play into this..


Either way, how could I use optocouplers to address this? I figure if I can get open/close working the rest will work fine if I put in an appropriate cap on the red lead.

John
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Jul 31, 2017, 07:49 pm
Maybe the LED is even running on DC while the rest works with AC - you can superimpose one on the other. That's how you can do power over ethernet, for example. The AC signal and DC power supply don't interfere.

Capacitors let AC signals pass, while blocking DC signals. Different values of capacitors have different impedance (resistance) to different AC frequencies. Maybe they have a second pair of 1 uF/22 uF capacitors in the main control so they can see which signal is passed through?
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Aug 01, 2017, 09:49 pm
Hmm, So I've given this a chance and I'm having some problems with the circuit I need to build to solve my problem. Could someone give me a hand?

How exactly could I go about setting up a circuit using optocouplers that allowed me to replicate this control board's features? I feel like I will need at least two optocouplers just for open/close but I'm not sure.

I came up with this circuit but I feel like this isn't correct. Any help would be very much appreciated!

(http://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=220989)
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: wvmarle on Aug 02, 2017, 05:14 am
You're right, definitely not correct: those optocouplers don't do anything this way as both sides are linked together.

Basically what you should do is take the circuit I drawn before, and replace the switches with optocouplers. Then you still have the problem that you're apparently switching AC so you would need two optocouplers in parallel (with the emitter/collector reversed) for each switch, so six optos in all.
Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: coogle on Aug 02, 2017, 10:02 pm
Okay I think I got what you mean... does this schema reflect what you were suggesting?

(http://forum.arduino.cc/index.php?action=dlattach;topic=491431.0;attach=221121)

Thank you by the way for all of your help (everyone!)

Title: Re: Using ESP8266 / Arduino and 2n2222 for Garage Door
Post by: johandb on Jun 04, 2019, 03:01 pm
Please do not stop here, I would like to know the end of this story after making for such gripping reading.

Did the complex opto-coupler scenario work at least for the open/close part of the switch?