Trying to power a microcontroller through a load switch with the output from a PIR sensor (HC-SR501)

Thread Starter

FranciscoB

Joined Feb 8, 2014
94
The PIR outputs a 3.3V signal, it goes HIGH when motion is detected. It remains HIGH for up to 7min (defined by the user).

I have a few logic level mosfets: AO3401 (P) and AO3400 (N).

I am not sure if it's better to use a high-side or low-side switch and what is the best configuration (this is for hobby stuff only). Maybe just one N-Channel on the low side?

Basically, the PIR would turn the microcontroller ON, it would send me a message and stay ON until the PIR output goes LOW, after a few minutes.
 

Attachments

ScottWang

Joined Aug 23, 2012
7,397
Maybe 2.87V is not enough voltage level to activate a logical level NMOSFET, so you can try to use an NPN transistor to replace it.
 

Ian0

Joined Aug 7, 2020
9,674
Why not power the micro directly, and use the PIR output to wake it up form deep sleep?
That way, you can put it back into deep sleep if it finishes its task before the PIR times out, saving even more power
 

Thread Starter

FranciscoB

Joined Feb 8, 2014
94
Why not power the micro directly, and use the PIR output to wake it up form deep sleep?

Because the quiescent current of the PIR is around 70uA and this is a battery powered project.

The microcontroller pulls close to 2mA in deep-sleep, hence keeping it off while doing nothing is the best option in this case.
 

BobTPH

Joined Jun 5, 2013
8,813
Because the quiescent current of the PIR is around 70uA and this is a battery powered project.

The microcontroller pulls close to 2mA in deep-sleep, hence keeping it off while doing nothing is the best option in this case.
What micro? That is way high. I use a PIC24 in deep sleep as a remote and a small battery lasts a year. If it drew 2mA it would last a few of days.
 

Thread Starter

FranciscoB

Joined Feb 8, 2014
94
ESP-32Cam development board. The ESP-32 bare chip deep sleeps at a few microamps but this development board has a few components consuming power that can't be disabled .
 

splud

Joined Jun 30, 2013
38
IMO, dev boards are best used for quick prototyping, then use the bare IC on a purpose-made circuit. Devboards (not necessarily the one you're using, but as a general rule) often use linear regulators, have USB serial interfaces, and other components (including power indicator LED which may be lit constantly), which make them ill-suited for direct use in battery powered projects.

I trust the project is not going to live on a breadboard? There are serious reliability issues with that.

I don't know all your voltage rail requirements, but if you have a 3v3 switchmode in the mix, you can mod the PIR module to eliminate the diode and the onboard linear regulator and run it directly from 3v3 (vs. the 5V minimum they generally require). That would be especially beneficial if the ESP where directly powered from 3v3 (which you may be able to do with your devboard by providing it on a 3v3 pin, which may exclude the 5V usb serial from being powered, reducing the consumption of the devboard, incl when in sleep). You indicated this is running from battery, so if all your gear can run at 3v3, you're capable of running off of a 1S Lithium chemistry cell, whether NMC or LFP.

I expect that in the power circuit early in this thread, the "camera" is inclusive of the ESP module.

BTW, if you use an NPN BJT to pull the gate of the P-MOS down, you won't need a pulldown on the output of the PIR, because unlike a FET, a BJT doesn't have gate capacitance to bleed off. Instead, you'd use an appropriate base resistor for the NPN to limit current. Doing this means you have closer to 3v3 at the base of the transistor, whereas the 10k pulldown drops the gate voltage. Also, you could use a 100k pullup for the PNP gate, which means you're sinking less current with the N-channel device to switch it on. If you were doing PWM, the slight change in switching speed would be more of an issue.
 

Thread Starter

FranciscoB

Joined Feb 8, 2014
94
Thank you for your very objective and practical suggestions!

IMO, dev boards are best used for quick prototyping, then use the bare IC on a purpose-made circuit. Devboards (not necessarily the one you're using, but as a general rule) often use linear regulators, have USB serial interfaces, and other components (including power indicator LED which may be lit constantly), which make them ill-suited for direct use in battery powered projects.
This is the case of the ESP-32Cam, hence opting to keep it turned off until it's time to do something. Trying to disable those components and still make the camera work would take a long time, not sure if it's even possible.

I trust the project is not going to live on a breadboard? There are serious reliability issues with that.
I'm in the process of giving it a proper home, please see attached photos.

I don't know all your voltage rail requirements, but if you have a 3v3 switchmode in the mix, you can mod the PIR module to eliminate the diode and the onboard linear regulator and run it directly from 3v3 (vs. the 5V minimum they generally require). That would be especially beneficial if the ESP where directly powered from 3v3 (which you may be able to do with your devboard by providing it on a 3v3 pin, which may exclude the 5V usb serial from being powered, reducing the consumption of the devboard, incl when in sleep). You indicated this is running from battery, so if all your gear can run at 3v3, you're capable of running off of a 1S Lithium chemistry cell, whether NMC or LFP.
I've modified the HC-SR501 to 3.3V for past projects and got reliability issues, namely non-stop false triggers. There's more testimonies online about this behavior. I found that running both the PIR and ESP-32Cam at 5V gives me consistent results (usb power, 18650 powerbank, 4xAA batteries, 2 or 3 AA boosted to 5V). It's not the most efficient way but it saves me time debugging power supply problems.

BTW, if you use can NPN BJT to pull the gate of the P-MOS down, you won't need a pulldown on the output of the PIR, because unlike a FET, a BJT doesn't have gate capacitance to bleed off. Instead, you'd use an appropriate base resistor for the NPN to limit current. Doing this means you have closer to 3v3 at the base of the transistor, whereas the 10k pulldown drops the gate voltage. Also, you could use a 100k pullup for the PNP gate, which means you're sinking less current with the N-channel device to switch it on. If you were doing PWM, the slight change in switching speed would be more of an issue.
I followed your suggestion and it worked with an LED+Resistor as load but when I replaced it with the camera, I kept getting a brown out error. I used a 2N3904. The PIR board has a 1.5K resistor, therefore I just connected the output to the base of the 3904, with the collector connected to the gate of the p-mosfet.
 

Attachments

Top