Discharge delay circuitry with GPIO HIGH

Hello there,

I am a novice in circuitry. My problem sums up to the fact that during boot my NODE MCU changes my GPIO pin from HIGH to LOW for approximately 200ms which are more than enough to ruin my project since that pin is the one that holds ON the entire system. I have tried to use other pins but they contradict with the rest equipment which includes a card reader and therefore specific pins for its use. I have tried every other combination and nothing works for me so I want to introduce a CAP to give me that extra ms I need. I put together a scetch to give you an insight of my idea.

PS: The realy is soon to be replaced with a mosfet. Just waiting for supplies

And here is a suggested solution of mine with which I am not comfortable at all since I don't have a clue. Just bits and pieces put together.

Thank you for your honesty, which , quite frankly, is very rare here. Most newbies try to conceal their
ignorance. It's refreshing to find someone with the guts to say they have no clue.

Regarding your request.
Your schematic is all wrong (no surprise there)
First things first: A transistor requires a base resistor to avoid damaging the base junction.
Transistors are current controlled devices (unlike mosfets which are voltage controlled)
When using a transistor the first step is alway read the datasheet to get the necessary
A. Continuous current rating
B. Current transfer ratio (hfe , expressed as a ratio, thus
an hfe of "100" means the collector current will be approx
100 times the base current.
C. To choose a base resistor, you need first to know how much
collector current you need. Let's choose 100mA for your example.
D. Let Ic = 150mA (0.150A)
Let's use a 2n3904

If we use assume an hfe of 200 and devide 150mA
by 200, you get 75mA (0.075A). If we round that up to 1mA
(0.001A), then the base resistor needs to be (5V/0.001A)=5000ohm.
To guarantee saturation, well use 1000 ohm , which will increase
the base current to 5mA (0.005A).

E. The load is your capacitor (let's choose 1000uF)
The collector is connected to +5V, the base is connected to the
1k resistor which is connected to the GPIO. The emitter is
connected to the capacitor "+" terrminal . The capacitor "-" terminal
is connected to the arduino GND. When you turn on the transistor
it will charge the cap. The problem is that if the cap is completely
discharged, when you turn on the transistor, the current inrush will
pull down your arduino +5V line , causing the arduino to reset. To
avoid that you can PWM the transistor , starting with a very low
value , like "10", then delay 300mS and then increase it by a factor
of 5 and then , delay 300mS and increase by a factor of 10 until
the duty cycle is 100%. Wait 60 seconds to charge the cap that
way and then it will be fully charged. The "+" terrminal of the cap
is connected to the GPIO you want keep high during boot. The
only thing missing now is the relay to separate your GPIO from the
charging circuit so you can control when that GPIO is connected
to the cap. Insert the relay contacts between the charging circuit
and the cap (common to charging circuit, N.O. contact to GPIO.
When you energize the relay, the contacts will close connecting
the charging circuit to the cap. Then all you have to do is write
your code to control when you charge the cap.

P.S.-Destroy the schematic you posted and don't show it to anyone.
Also , if you buy a 5V relay module you won't have to add a transistor to turn on the relay because that's already built into the relay module.

Thank you for your analytical reply. I had no time to send the revised schematic so I sent an old one. The values lesson is much appreciated.Thank you sir. The selection of a transistor alone is a victory for me.Before I change my code I want to highlight the purpose of the relay.

Once the button is pressed the arduino powering circuit closes causing the relay to turn on thus allowing D8 to go HIGH and maintain the loop of the GND line. It is kind of a latching power ON circuit. Then by code I send a LOW through D8 if I want to power off the MCU. There is an IF statement that puts the mcu to sleep.When the device resets the problem occurs.

Edit: I just saw your schematic. Thank you very much sir!

Once the button is pressed the arduino powering circuit closes causing the relay to turn on
(thus allowing D8 to go HIGH and maintain the loop of the GND line)

It is kind of a latching power ON circuit.

Then by code I send a LOW through D8 if I want to power off the MCU.

There is an IF statement that puts the mcu to sleep

When the device resets the problem occurs.

If you use the N.C. contacts of the relay to power D8 then it will be HIGH when the relay is OFF,
so you don't have to worry about the Relay GPIO going LOW during boot. Then if you want to turn OFF
D8 , just turn ON the relay , opening the contacts. This guaranatees that D8 will remain HIGH during boot
because you are using Negative logic . (The relay is Active LOW).

Yes I rejected this possibility because my goal is power on my device when the button is pressed and not the opposite. Unless I can place the button elsewhere. The circuit is destined to be an alarm system. I also incorporate logic gates to hold the state of my external wake up HIGh once it resets. Moreover, I am waiting for supplies to add a HT112 D-E accompanied by an rf transceiver and a NOT gate built by a transistor to signal when a pir detects movement (without having the need to use a second μC at the pir sensor).

Sorry I got carried away.just wanted to share my project with you

Why not have it controlled by a Flip Flop so it stays
off until you trigger the FF on with the button.
That way it won't get pulled low during bootup,
because the FF is powered by the 5V and not a GPIO.

Let me explain the logic since I am having a little bit of difficulty with the external wake up of the unit.
2 Input OR gate -->reed switch circuitry LOW signal - MCU wakes up -->Gate output “RST”
–>GPIO (gate pin) outputs HIGH as soon as mcu wakes up

0 0 -->0 awake
0 1 or 1 1–>1 so we successfully latched on HIGH.Saying a potential burglar keeps on opening and closing the door(making the mcu constantly reseting-taking advantage of my entry time delays) or maybe leave it in a place where the breeze could make reed switch floating he can no longer reset the unit.

i am currently having one issue left with pulsing LOW to RST with my reed switch. I use a power source along with a resistor and in between the base of a 2n3904 I have placed my reed switch. Then I connect RST to GND (collector to emitter). The problem is that when I open the switch the unit resets as expected but the scetch is not excecuted as expected.

#1Edit: I have found that boot fails if gpio 0 is pulled high which happens to be my Power circuit pin I was asking help with… I am out of pins and patience

I'm sorry but I need a schematic and your
code. I don't know why you are doing a reset
right after wakeup. Also don't know why you aren't
using an interupt to wakeup. To my knowledge
"wakeup" means wakeup, not wakeup and reset.

In addition your schematic and your code we
need your design criteria defining the algorithm
of the code. (in order to verify that the code
you post does what you say it is supposed to do.
(preferably in outline form)
What we need to know is what is connected to
what, in schematic form.(if possible)
If you can't draw then just list the devices and
where each pin goes .
Q1 2n2904
b: to ....
c _to ....
e__to ....

Then we need the Truth Table:
THEN ( do action)
THEN (do some other action)

I'm not an alarm expert but in my mind you
only need one trigger to set off an alarm.
Don't wait passively counting the reed switch
triggers. If it triggers once you turn on the siren.
Software is not my area of expertise. I'll look at tge schematic but someone else will have to look at your code.
Looking back over your post from the beginning,
your presentation of the reason you're
posting is all wrong.
The standard procedure is to start at the
BEGINNING , not in the middle of a circuit.
And if you don't know electronics PLEASE
don't try to guess here on the forum.
At any given time of any day there is literally
centuries of experience if you add up the
years of electronics experience of the
forum members reading these posts.
I have 40 years myself and I'm nowhere
near the most knowledgable since I am only a technician and probably 30% or more of the
members are EE engineers. I'm telling you
this because what annoys us the most is
posters trying to guess how to draw a svhematic instead of Googling "transistor driver" or
simply asking "How do you make a circuit
that does this:(explanation)."
Start over. Give us ALL the information
in one post.

  1. Project objective
  2. schematic (if you can draw it)
  3. code
  4. Explanation of what you know about the
  5. Your last post is very hard to follow,
    especially when you start describing the circuit:
    (collector to emitter ????!!!!) ( what the heck does
    that mean ?)
    If you don't know how to design , don't even try.
    Just state you don't know how and want to
    know how. Your first schematic was a disaster
    but you at least admitted you didn't have a
    clue, which, quite frankly, very few posters
    have the guts to do.