Using ESP8266 / Arduino and 2n2222 for Garage Door

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.

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

Any help?

John

What problems are you having?

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

scottyjr:
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... :slight_smile:

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?

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... :slight_smile:

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

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.


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.

That's exactly what I did (see my original circuit) and it isn't working :slight_smile: 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

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.

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.

Screen Shot 2017-07-26 at 1.23.59 PM.png

Screen Shot 2017-07-26 at 1.23.59 PM.png

I think this is the correct schematic of that PCB:
schematic.png
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).

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?

What do you mean replicate it? Complete replacement so you just have the bell wire running to your ESP circuit and no panel?

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.

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.

coogle:
It doesn't really have an effect on the circuit.

I wouldn't be so sure about that.

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?

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?

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?