Motion Sensor Ciruit - Page 1
Forum section: electronics / projects

author: Neutronoman
author_rank: Newbie
timestamp: March 03, 2016, 04:19:58 pm
content: Please comment on this circuit. It's not working, and I don't know why.The power supply is 5vdc. The motion sensor output is 3vdc. I thought 3vdc would be enough to turn on the 2n2222 transistor, but the led is barely lighting up.My actual goal is to use a relay with a 5vdc coil and 120vac contacts to light up a porch light. With the relay in place, if I bypass the motion sensor and put 5vdc to the transistor base my light bulb lights up just fine.I switched to the led for testing purposes.

author: Photon939
author_rank: Regular Contributor
timestamp: March 03, 2016, 05:31:30 pm
content: You should have a current limiting resistor on the base of the transistor. If you're using an NPN as the schematic shows, the transistor and LED should swap positions.Seehttp://www.electronics-tutorials.ws/transistor/tran_4.htmldown at the "basic NPN transistor switching circuit"

author: Neutronoman
author_rank: Newbie
timestamp: March 04, 2016, 06:29:16 am
content: I did as you suggested, and that helped a lot. Now I'm getting the full 5vdc through the transistor and the LED lights up brightly. So then I swapped the LED out for the 5vdc relay that I actually want in there, and I expected it to work, but it didn't. I can activate the relay using the 5vdc from the power supply, but not through the transistor. If I have power to the relay going through the transistor, I can jump start it using direct power, then remove that direct power, the relay will stay on until the transistor turns off.It seems obvious that the problem is low current through the transistor. How can I fix that problem?Thanks

author: Photon939
author_rank: Regular Contributor
timestamp: March 05, 2016, 12:46:23 am
content: Quote from: Neutronoman on March 04, 2016, 06:29:16 amI'm not sure how much current that output pin of the motion sensor is capable of, but you either need a lower value base resistor to allow more current or a darlington transistor setup to get enough gain to drive the relay.

author: uncle_bob
author_rank: Unknown
timestamp: March 05, 2016, 01:11:10 am
content: HiHow much current does your relay pull at 5V?How much current can your transistor handle?How much gain does your transistor have?What kind of signal does your motion sensor put out?What value base limiting resistor did you pick?=======Let's say that your relay pulls an amp (only a guess) to actuate.Let's say that your transistor will handle 10A (again a guess).Let's say your transistor has a gain of 10.So you need 100 ma into the base of the transistor to get things to work (1A / 10 = 100 ma).If your numbers are different, plug them in instead.Say that your sensor puts out an HCMOS logic signal. Thus it has a maximum of 2ma that it will deliver. You need 100ma and you have 2ma. Now you need 50X the gain, so you need two more transistors (if they each have a gain of 10). That assumes that the base limiting resistor is not what bottlenecks things.Again, if your numbers are different ....Bob

author: alsetalokin4017
author_rank: Super Contributor
timestamp: March 05, 2016, 01:12:33 am
content: What is the part number of the sensor? We can check its datasheet to see how much current the output pin can provide.Regardless of that, if you use a second transistor (in the Darlington arrangement mentioned above) this should solve your problem. Or better yet, use a logic-level mosfet instead of the second transistor.

author: Neutronoman
author_rank: Newbie
timestamp: March 05, 2016, 04:28:55 pm
content: Quote from: uncle_bob on March 05, 2016, 01:11:10 amI tested the relay and it pulls 60ma at 5vdc.The transistor is a 2n2222a and will handle 600ma.Gain(hfe) on the 2n2222 listed on the package is 200.I bought the small motion sensor module from Banggood and don't have a datasheet and have no information about the output current, and only know that it's 3 vdc.The resistor is 48 ohms.I had tried a Darlington transistor pair earlier and it didn't work. Now that I have other problems solved, the Darlington pair did work. For my own better understanding I plan to keep working on getting all the information you asked for and doing the math despite the fact that it already works without doing that.Now I'm working on getting the photocell to shut off the circuit during daylight. Once I accomplish that I will be ready to put this project into service.I greatly appreciate the help I have received here. Couldn't have done this without it.

author: uncle_bob
author_rank: Unknown
timestamp: March 05, 2016, 04:54:35 pm
content: HiOk at 1V the gain of the 2N2222 is rated at 50 (gain goes down as voltage drops). Saturation likely will require a bit more current.So: the 2222 should do the job with between 1 and 5 ma into the base. If the sensor pulls fully to +5V, about a 1K base limit resistor should work. Anything less than that is un-needed if it pulls to +5. It may work with a resistor as high as 4.7K.Bob

author: Neutronoman
author_rank: Newbie
timestamp: March 06, 2016, 04:18:25 pm
content: Hmmm. I wonder why they didn't put the gain on the package. I would think that is important. I also checked the datasheet and didn't see that number. Datasheets are complicated and I have a hard time understanding them. But since it seems that hfe is not gain, then what is hfe?I guess I need to watch some more instructional videos on transistors.Thanks

author: uncle_bob
author_rank: Unknown
timestamp: March 07, 2016, 12:53:14 am
content: Quote from: Neutronoman on March 06, 2016, 04:18:25 pmHiTransistors, regardless of what you call the gain, have a number of things going on:1) The current through the collector changes, the "gain" is different at different current levels.2) The voltage between collector and emitter changes, the "gain" changes as a result.3) The temperature of the device changes, the "gain" changes as a result4) You buy 100 parts and look at them, some have more "gain" some have less5) You buy the same part number from different vendors, again there is a difference in "gain".6) You decide you want < 0.7V between collector and emitter, "gain" is different in this region.7) You vary the frequency, the apparent "gain" gets lower as frequency goes up.That's the "easy stuff" before you get into the weird part of things.It is rare to find a transistor data sheet that characterizes the part under every possible condition. If you find a data sheet like that, it probably is on a part you can't afford. All of the common parts are fairly loosely spec'd. That makes them easy to produce. Easy = low cost. Low cost = we like to use them.Bob