Neopixel and PIR sensor with a 9v battery?

Hello,

I am facing a problem and cannot figure out the problem. The goal is to turn on the LEDs when movement has been detected. Functionally, the flow performs these steps:

  • Initialize the pin of the PIR sensor
  • Read the PIR sensor
  • If the value is HIGH, turn on the LEDs, otherwise turn them off

When the microcontroller is powered by USB, everything works fine: the sensor detects movements and the LEDs are correctly on and off.

When I use a 9v battery, it doesn't work ...

I did a series of tests to try to locate the problem:

  • Read the sensor but do not use the value, and turn the leds on and off: it works -> I suppose the 9v battery is providing enough power?
  • Switch on only 1 LED instead of 24: does not change the situation

In attached the schematics and the source code: For convenience, I placed the normal behavior in loopNormal() and my tests in loopDebug().

I must be missing something on the electronic part, but I'm too newbie to figure out what...

Thanks for your help!
Serge

DarkLED-BugWithBattery.ino (1.22 KB)

When I use a 9v battery, it doesn't work ...

How much current does the circuit require ?
Can the PP3 battery provide enough power for the required time ?
Have you tried measuring the battery voltage with circuit connected ?
Can the microcontroller board 5V output provide enough current to power the circuit ?
Have you tried measuring the 5V output with the circuit connected ?

  • Switch on only 1 LED instead of 24: does not change the situation

But your diagram shown only 12 LEDs?
I know why, the pile of crap known as Fritzing doesn’t have that part. That is one of the reasons why physical layout diagrams, they are not schematics, are despised here.

I suppose the 9v battery is providing enough power?

That is probably the problem although measuring the voltages will tell you that because if you draw too much current from a battery the voltage it produces will drop.

Also a battery has a high output impedance which you can lower by placing a largish capacitor ( 100uF) between the Vin and ground of your Arduino.

Hello,

Thanks for your hints: it helped me to find the cause. In fact, my 24 LEDs draw too much current: the consequence is that the PIR is always reset, restarting by providing a HIGH value.

Even with 2 capacitors to decouple the PIR sensor from the LEDs, I have the same issue until I reduce the number of leds used.

I will now have to figure out how to fix that, but now, I can focus on a problem.

Cheers!
Serge

Th 9V battery is nonsense, as is powering through the regulator. Three AA alkaline batteries or four NiMH rechargeables should provide just enough voltage for the NeoPixels.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.