Motion Sensor With LDR

Discussion in 'The Projects Forum' started by HappyHippo, Sep 24, 2014.

  1. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    I wanted to make a motion sensor that switches on a LED only when it's dark. Eventually, I'll replace the LED with several LEDs. The project has been done a lot of times. At first, I didn't have the R4 resistor. In that case the LED was always lit. So I put a resistor R4 = 10k. In that case the LED seems to blink on and off about every 5 seconds. So I changed R4 = 1K. Now it seems to work better; however, the PIR still seems to detect motion in the light, even though there is insufficient voltage and current to Q1. Seems like since the GND pin of the PIR is open when it's light, the PIR shouldn't be able to function. But it is. When it's dark, everything works ok. motion-sensor.png
     
  2. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    I doubt that happens reliably in your circuit. The LDR resistance would have to drop dramatically to keep Q1 from conducting.
    Try inserting a 2.7V zener diode in series with Q1 base (with diode anode connected to Q1 base).
     
    Last edited: Sep 24, 2014
  3. jjw

    Member

    Dec 24, 2013
    173
    31
    Also Q2 base current should be limited.
    About 2.2k resistor from pir output to R4 and Q2 base junction.
     
  4. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    I'll have to order the Zener, don't have one. But when it's dark, the voltage at Q1 to ground is 0.6V; when it's light, it's 45 mV. So that's why I thought there was no conducting going on when it's light.
     
  5. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    When I put a 2.2k resistor between Q2 base and the PIR output - R4 node, the PIR still detects motion when it's light. Also, I think I may have mistaken the blinking business in my original post with the stabilization that the PIR sensor does. It seems if I wait a couple minutes, the blinking stops. Then only the PIR detects legitimate motion. But again, the circuit was set-up to NOT detect motion when it's light. There are evil spirits afoot here.
     
  6. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    Also, if I completely connect the LDR part of the circuit from the Q1 base (so there can be no current flowing into the base), I still get motion detected when it's light.
     
  7. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    I assume you mean'disconnect'? If that leaves the base floating there may be enough leakage current to allow the PIR to function. Excessive leakage current could also mean the zener would not provide a solution. Try a direct short between Q1 base and ground to see if that disables the PIR.
     
  8. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    Thank you - I did mean disconnect. I found that if I remove the circuit past the PIR output, the PIR will only detect motion when it's dark. So it works correctly. That is, the output goes to 3.3 V when there is motion only in the dark. So the problem is in the part of the circuit to the right on the original post.

    motion-sensor-no-led.png
     
  9. Sensacell

    Well-Known Member

    Jun 19, 2012
    1,134
    268
    The switching action of the Q1 circuit is 'soft' - it has an undefined level where the transistor is not on or off- in this state, the PIR behavior will be very unpredictable. Why not arrange the circuit so the LDR prevents the LED from turning on. Leave the PIR connected to a stable voltage.
     
  10. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    Using Q1 to disconnect the PIR pin 3 from ground must allow some current to flow via pin 2 to Q2 base regardless of the PIR being triggered. A better approach might be to ground pin 3 permanently and rely on selectively switching the output from pin 2 using the LDR. Like this:
    PIR-switched-LED.gif
     
  11. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    wouldn't the PIR sensor be ON all the time then? I only wanted it to be on when it was dark.
     
  12. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,813
    1,105
    If you want to actively switch the PIR (presumably to save power?), some hysteresis needs to be introduced so that the PIR is definitely on or off, not in some intermediate state as Sensacell pointed out. This will involve a few circuit additions. You might also want to have some adjustment so that the light/dark switching threshold can be selected.
     
  13. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    I found that if I rearrange the circuit like attached. It works as I wanted, except the input voltage to the PIR (pin 1 to pin 3) drops to about 2.4V when motion is detected. When no motion is detected, that measurement is 4.95V. Then, when motion is detected, the LED is very dim Maybe there is not enough current coming into the PIR?
    motion-sensor-gnd-mod.png
     
  14. jjw

    Member

    Dec 24, 2013
    173
    31
    The base resistor R1 is too big.
    The PIR gets about 0.2 -0.4mA current.
    But if you lower the base resistor you have again the problem with PIR working in the light.
     
  15. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    I had to use that large of resistor because of what you say, I only wanted the circuit to work when it was very dark. What if I amplify the current with another transistor after Q1?
     
  16. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    I replace the 2pN2222 transistor for Q1 with a BC547C one. The input voltage is more stable now, only drops 0.1 volts when motion is detected. I still have to boost the current to the LED, since it's very dim. Any ideas?
     
  17. HappyHippo

    Thread Starter New Member

    Aug 19, 2013
    11
    1
    OK. I replaced Q2 with a MOSFET and still the LED was very dim. So then I replaced the LED and there was light. So I took out the MOSFET and replace Q2 with a BC547C as well. I lowered the LED resistor to 220 ohms. I looks like it works now. Nothing happens when it is light. Voltage to PIR comes on when it is dark. Output to PIR activates when motion is detected and LED lights up. So the circuit is shown below. I knew I could do this with an Arduino but I wanted to try it with no microcomputer. By the way, I wanted to measure the voltage consumption and accidentally hooked up my DMM wrong. I blew the fuse on the 400mA port. It costs $15 to replace the 400mA fuse, if you can believe that.

    Thanks everyone for your comments. If you see anything wrong with this circuit, let me know as well. I'm a ChE, not an EE, so my electronics knowledge needs improvement (which is why I'm doing these little projects).



    motion-sensor-gnd-mod2.png
     
    Raju Reiki G M likes this.
Loading...