1
\$\begingroup\$

My issue is how to build the circuit and what is the most efficient one to trigger a MCU from the alarm of the RTC DS3231.

For the momment I have built the one in the picture below (using a P-channel MOSFET IRF9540):

microcap simulation

(The blue rectangle simulates de RTC, the battery with 0V is the SQW pin and the red rectangle is the Rasberry Pi.)

The problem is that during startup the RDS drop is causing it to it die when it reaches a mA peak (because I imagine it has 4.7V instead of 5V). Is this correct? Can I improve it?

I have tried also to put the P-channel MOSFET before the DC-DC, but is not working, the DC does not convert, the red LED is OFF, I dont know why.

ps: I know how to trigger the alarm, program the RTC, etc.

pps: I used the circuit from https://www.raspberrypi.org/blog/build-low-power-clock-controlled-devices/

\$\endgroup\$
8
  • \$\begingroup\$ Ah, le me see. (1) So you have a 3V3 RTC DS3231 which outputs a 3V3 logic High/Low alarm signal which used to to switch On/Off a P-channel power MOSFET IRF9540. (2) You want the IRF9540 in turn be used as a high side current switch to switch On/Off the 5V power supply for the Rpi. Pleast let me know if I understand your problem correctly, before I move on to suggest how to troubleshoot. \$\endgroup\$
    – tlfong01
    Commented Aug 24, 2020 at 8:24
  • 1
    \$\begingroup\$ Yes exactly, and for info the 5v power supply they come from the output of a DC DC converter step up, whos input is a Li-ion bettery 3.7V model 18650. (When I meant I tried to put it before the DCDC converter is this one) \$\endgroup\$ Commented Aug 24, 2020 at 8:59
  • \$\begingroup\$ Ah, thank you for your confirmation, and give me more details on your 5V power supply. Let me think about it and come back to you later. Cheers. \$\endgroup\$
    – tlfong01
    Commented Aug 24, 2020 at 9:03
  • \$\begingroup\$ Your spec can be boiled down to the following: How to use a 3V logic signal to switch on/off a P-Channel power MOSFET which in turn switches on/off a 5V power supply for Arduino, Rpi, or ESP32. I mean the DS3231 is not relevant, any 3V signal can do. Let me draft an answer below. \$\endgroup\$
    – tlfong01
    Commented Aug 24, 2020 at 9:38
  • 1
    \$\begingroup\$ The power supply is the following: 3.7Volts Li-Ion Battery 18650 (orbtronic.com/content/sony-VTC6-datasheet-specs.pdf) ---> DcDc StepUp converter (2V to 5v to 5V) amazon.fr/gp/product/B07SSXVHP8/…. \$\endgroup\$ Commented Aug 24, 2020 at 9:38

1 Answer 1

1
\$\begingroup\$

Question

How to use a 3V logic signal to switch on/off a P-Channel power MOSFET which in turn switches on/off a 5V power supply for Arduino, Rpi, or ESP32?


Answer

(1) I must first point that you don't use DS3231's Square Wave Signal to switch/trigger the power MOSFET or other devices. You use the interrupt signal.

(2) To switch/trigger a power MOSFET switch, either P-Channel or N-Channel can do the job, as shown in the following schematic.

mosfet switch ds3231


Discussion, Conclusion, and Recommendation

(1) Using DS3231 to control the power MOSFET which in turn to switch on/off might not be a very solution. My usual trick is to use DS3231 interrupt to direct switch on/off the LM2596 PSU through its power on/off switch pin. See Appendix B for more details.

(2) Using P-Channel or N-Channel power MOSFET, High or Low side switching?

I usually prefer NPN BJT and N-Channel power MOSFET for switch, because (a) more EE guys prefer NPN and N-Channel so you will find more tutorials to follow, and circuits to copy, (b) N guys are more efficient, (c) In case you need to ground complicated circuits, N-Channel and NPN BJT low side switch can ground easier. On the other hand, high side mosfet switches "floats" in the air, so not so easy to make a common ground.

(2) The Sony 18650 tech spec is the best I can google.

(3) The OP's step up regulator is interesting. I bought one long time ago but never tried it, because my projects don't have any space problem. I usually use 18650 x3 or even x4 and step down to 5V. The switching power supply regulator has a very high, or 90% efficiency, so your PSU does not loses that much energy, but lasts 3 or 4 times longer.

(4) I think the OP's design is very good. My suggestions are a bit subjective. The OP need to do engineer trade offs and cost benefit/risk analysis. It is a good learning experience and fun trying different approaches, compare and contrast.


References

(1) IRF9540, SiHF9540 P-Channel Power MOSFET (Vgs(th) = -2V min, -4V max, Rs(on) = 200mΩ @Vgs -10V) datasheet - Vishay

(2) DMP2008UFG P-Channel Power MOSFET (Vgs(th) = -0.4V min, -1.0V max, Rs(on) = 17mΩ @-8.3A) datasheet Diodes

(3) Sony 18650 Lipo Battery Spec

(4) Amazon USB DC-DC Converter 0.9V - 5V Boost to 5V 600MA Step Up Power Supply Module

(5) DS3231M ±5ppm, I2C Real-Time Clock Datasheet - Maxim


Appendices

Appendix A - DS3231 Testing Notes

I am reading my old post to show (1) how to use Rpi OS's DS3231 DT drivers and also (2) basic python program for setting up and also how the program the interrupt for alarming external devices as asked by the OP. I have also used a scope to display the DS3231 1Hz and 32kHz wave forms and found them a bit noisy.

Rpi3B DS3231 pythonProgramming Notes

(1) https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=77158&p=1350076&hilit=DS3231+tlfong01#p1349687

(2) https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=77158&p=1349937&hilit=DS3231+tlfong01#p1350076

(3) https://www.raspberrypi.org/forums/viewtopic.php?f=37&t=77158&p=1349937&hilit=DS3231+tlfong01#p1349687


ds3231 setup


Appendix B - Using DS3231 interrupt signal to switch on LM2596 PSU for Rpi

Using High/Low side power MOSFETs to switch on off PSU might not be a very good solution. One trick I always use is to use DS3231 interrupt signal to switch on/off the LM2596 PSU, or using the interrupt to switch on LM2941 current switches.


Rpi freezes every now and then, how to fix it with a watchdog?

I modify ordinary DC-DC (12V to 5V) PSUs' so that any Rpi or MCP23x17 GPIO pins can power on/off the LM2956/LM2947 voltage regulator chip of the PSU. (LM2941 can be used for 1A current switches, LM2596 for 5V 3A PSU. The on/off pin is also connected to a push button, for manual power on/off testing.)

Actually each of my 7 Rpi3B+'s is connected to a cheapy DS3231 Real Time Clock Module which has a hardware interrupt pin to reset PSU, Rpi, or other devices.

Now the external DS3231 RTC wakes up everybody in the morning, and switches off lights at midnight, so everybody goes to bed.

lm2596 psu

lm2941 current switch


End of Answer

\$\endgroup\$
5
  • 1
    \$\begingroup\$ The SQW output of the RTC is active to level low so the chanel N in your picture is not doing the job. Also, I want to suply with just one 3.7 volts Li-Ion battery \$\endgroup\$ Commented Aug 24, 2020 at 9:57
  • \$\begingroup\$ #user8920367, Ah, I remember the 32kHz square wave signal is an optional always on/off signal for timing to binary count down to precisely 1 second (I forot the details, need to read datasheet). It is only the DS3231 low active interrupt alarm signal to trigger/switch on the power MOSFET. I am not very sure. I need to read the datasheet to confirm. Many thank for pointing out my possible careless mistake. Ah, locking down supper time. See you late this evening or tomorrow. Cheers. \$\endgroup\$
    – tlfong01
    Commented Aug 24, 2020 at 10:09
  • \$\begingroup\$ Just now I read the datasheet (Ref 5 of my answer's reference list) to confirm. (1) I found that I made a mistake. 32kHz square wave is an optional always on signal for timing. My apologies. (2) For the alarm signal thing, the datasheet's INT/SQ pin description says that you can config either INT or SQ. I always use INT, but never SQ. So I might have made another careless mistake. My apologies again. You might like to confirm and I will correct my answer accordingly. Supper time. See you later. \$\endgroup\$
    – tlfong01
    Commented Aug 24, 2020 at 10:20
  • 1
    \$\begingroup\$ You cannot really use a low side switch for this, as that would drastically complicate safely managing the I2C connection in the switched off state. And as mentioned previously please read the guidelines on what constitutes an "answer" on a stack exchange site - the majority of the content of this post is another of your excessively "chatty" off-topic posts, at least this one does contain a tiny bit of technical solution proposal responding to the actual question, but that is largely mistaken. \$\endgroup\$ Commented Aug 24, 2020 at 13:42
  • \$\begingroup\$ Thank you for pointing out my ignorance in using low side switching MOSFET for I2C devices. I never thought aobut that. I need to google and study more before I make an apology and suggest replacement answers here. \$\endgroup\$
    – tlfong01
    Commented Aug 24, 2020 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.