Powering ESP with a Low-Level trigger

Thread Starter

MMM**MMM

Joined May 30, 2022
91
You didn't mention that before. So exactly how long do you need the ESP on?
I understand that I already mentioned this requirement in the previous thread. The focus was on achieving the same functionalities of the design, but for a normally open switch. One of these functionalities is enabling the ESP to power itself by sending a high signal and shutting down by sending a low signal.

Now, the crucial question is, how low should the ESP be powered on? The goal is to ensure it remains on as long as it does not send a low signal to a specific circuit, which would cut off the power, similar to the approach used in the previous design.
 

Thread Starter

MMM**MMM

Joined May 30, 2022
91
This circuit gives appx a 1 second pulse. Increase C1 for longer. Current drain 1ua with reed closed.
Zero current after pulse and switch open.
View attachment 298622
First, I simulated your circuit and observed that it does not last for more than a few milliseconds. There is a minor delay (1-2 ms) that occurs when the switch is opened, although this will not have any impact on my application. I simply noticed it during the simulation.
1689800503132.png


Okay, that's great and it seems like we are making progress towards finding a solution. However, there is still one issue that needs to be addressed - the ESP needs a power source in order to function properly. We have considered using a capacitor as a solution, but the one shown in your schematic didn't work as expected.

I think using a larger capacitor (typically in the range of mF) can provide a good solution, allowing the ESP to power itself for a few seconds. This will give us enough time for the device to connect to the internet and send a notification.

The ESP is a device that enables us to connect to the internet, which is essential for sending notifications. In order to establish this connection, it needs to first connect to a wifi network. This connection process usually takes around 30 seconds, although in most cases it takes less time than that.

To address this issue, we have two options. The first option is to use a large capacitor, which is not practical due to its size. The second option is to accept that there may be instances where door openings are missed due to the fast discharging of the capacitor, which is also not practical for safety reasons.
 

djsfantasi

Joined Apr 11, 2010
9,237
When either S3 or S4 is closed, the ESP is powered on. Similarly, if only S4 is closed, the ESP is powered on as well. The ESP is only powered off when both S3 and S4 are open.
S3S4Power
openopenOff
openclosedOn
closedopenOn
closedclosedOn

This can be accomplished with the outputs diode wired in parallel

Please note that S4 is not a physical switch, but rather serves as a way to simulate a high signal sent by the ESP. On the other hand, S3 is a reed switch that is normally closed.
Since S3 is the output of a GPIO, a pull-down resistor can be added to the OR output so when the ESP is off, S3 will be off. A P Channel Logic-Level MOSFET paired with an N Channel logic level MOSFET can power on/off the ESP.

You can invert the logic with a pull-up resistor on the output of S3 (before the diode). The reed switch is an NC switch and connects to ground.

In this case, the MOSFETs are normally grounded and pull no current or minimal current is drawn from the pull-up/down resistors. Resistance values of 100kΩ will draw 66μA…

The OR output goes to a P Channel Logic-Level MOSFET paired with an N Channel logic level MOSFET to power on/off the ESP.
IMG_5609.jpeg
 

djsfantasi

Joined Apr 11, 2010
9,237
S3S4Power
openopenOff
openclosedOn
closedopenOn
closedclosedOn

This (OR function) can be accomplished with the outputs diode wired in parallel

<omitted>
You can invert the logic with a pull-up resistor on the output of S3 (before the diode). The reed switch is an NC switch and connects to ground.
You can invert the logic with a pull-up resistor on the output of S3 (before the diode). The reed switch is an NC switch and connects to ground.

<omitted>
In this case, the MOSFETs are normally grounded and pull no current or minimal current is drawn from the pull-up/down resistors. Resistance values of 100kΩ will draw 66μA…
Oh. I re-read post #37…

Perhaps you could use a delay-off relay OR an 8-pin microprocessor to emulate an output only for n seconds until S4 changes state again.

Nevermind, I missed a lot of posts. I’m out.
 
Last edited:

Reloadron

Joined Jan 15, 2015
7,890
Where are you located? I can buy NO, NC reed switches including the magnet and mounting screws just about anywhere including Amazon and my local Lowes or Home Depot. They look like this. I see no need for all sorts of additional circuitry for inverting anything. Most will handle 500 mA which is more than enough for your ESP8266 module. This is where it helps to know a location so people can better suggest where to get a part you want or need. If you want more current just use a MOSFET but I see no need.

Ron
 
Last edited:

Sensacell

Joined Jun 19, 2012
3,785
A more complete solution would be to have the ESP latch itself ON via an IO pin when a narrow pulse triggers it, then complete the process of sending the data and shut itself down.
This would be the optimal energy use scenario, also avoiding the need for a large capacitor in the trigger circuit.
 

Thread Starter

MMM**MMM

Joined May 30, 2022
91
A more complete solution would be to have the ESP latch itself ON via an IO pin when a narrow pulse triggers it, then complete the process of sending the data, then shut itself down.
This would be the optimal energy use scenario, and avoid the need for a large capacitor in the trigger circuit.
YES, this is exactly what I'm looking for. As mentioned in the previous thread, the circuit already fulfills the function you described. However, the issue lies in the usage of a normally closed switch, whereas I would prefer to utilize a normally open switch as it is readily available to me.
 

BobTPH

Joined Jun 5, 2013
11,516
Why do you need to power on the ESP when the door is opened? Micros can go into a sleep mode that uses power insignificant compared to battery self discharge. Typically, applications have the micro running all the time and sleeping when there is nothing to do.
 

Thread Starter

MMM**MMM

Joined May 30, 2022
91
Why do you need to power on the ESP when the door is opened? Micros can go into a sleep mode that uses power insignificant compared to battery self discharge. Typically, applications have the micro running all the time and sleeping when there is nothing to do.
The sleep mode of ESP consumes 20uA of power, while the power-off mode consumes less than 5uA. Therefore, theoretically, the battery would last four times longer in the power-off mode. To conserve power, I only need to activate the ESP when the door is opened to send a message, after which it can be powered off completely instead of just being put to sleep.

Please refer to post #50 as it contains the exact information that I require.
 

sghioto

Joined Dec 31, 2017
8,634
I only need to activate the ESP when the door is opened to send a message,
But the door must stay open long enough to send that message without a timed latching circuit.
Here's the previous circuit with a latched time delay set by the values of C2 and R3. Appx 10 seconds.
1689823600052.png
 
Last edited:

Sensacell

Joined Jun 19, 2012
3,785
The one bit of information you need to know is the Power-On-Reset start-up delay of the ESP.
The ON pulse needs to be longer than this by 50-100% to be safe.

The first thing the code must do is set an IO pin high, the KEEP_ALIVE signal, which should hold the power ON.
When the code finishes the task, the KEEP_ALIVE line is set low and the power goes off...
 

Thread Starter

MMM**MMM

Joined May 30, 2022
91
But the door must stay open long enough to send that message without a timed latching circuit.
Here's the previous circuit with a latched time delay set by the values of C2 and R3. Appx 10 seconds.
View attachment 298646
You are getting closer to the solution. The timer circuit's primary purpose is to maintain the ESP's power supply for a specific duration (potentially a few seconds or longer). However, the essential element that completes the circuit is the latching circuit, where the ESP sends a KEEP_ALIVE signal, as mentioned in post #55. Subsequently, it sends a low signal to initiate the shutdown process.

The ultimate goal of the final circuit is to power the ESP under the following conditions: when the switch is open, when the KEEP_ALIVE signal is high, or when both conditions are met simultaneously. Additionally, to address any startup delays, the timer circuit will ensure that the ESP remains powered on for the required duration. Finally, when the switch is closed AND the KEEP_ALIVE signal is low, the circuit will effectively power off the ESP.
 

sghioto

Joined Dec 31, 2017
8,634
Follow up to Sensacell's idea. The circuit provides a 1 second pulse with the components listed as verified when testing on my breadboard.
This is assuming that the ESP draws no more then 1.5 ma on startup.

1689862239088.png
 

BobTPH

Joined Jun 5, 2013
11,516
I only need to activate the ESP when the door is opened to send a message, after which it can be powered off completely instead of just being put to sleep.
Easily accomplished via software, with a small hardware assist. If I had the time I could shoe you.

You are fixated on one solution, when there are many ways to do this. You do not need a normally closed reed switch.

Edited to add: I just saw the @Sensacell post. That is the kind of thing I was thinking of.
 

Thread Starter

MMM**MMM

Joined May 30, 2022
91
Follow up to Sensacell's idea. The circuit provides a 1 second pulse with the components listed as verified when testing on my breadboard.
This is assuming that the ESP draws no more then 1.5 ma on startup.

View attachment 298669
The ESP GPIO is functioning effectively now, as it can send a strong KEEP_ALIVE signal to sustain its powered state. Conversely, it can transmit a low KEEP_ALIVE signal to initiate a shutdown. However, we encounter a tiny issue due to the utilization of a normally closed switch. If we could instead employ a normally open switch, all operations would be successfully accomplished. I have conducted a circuit simulation which operates smoothly with a normally closed switch. However, when I open the S12 switch, the ESP is no longer receiving power.

1689871172507.png
 

Thread Starter

MMM**MMM

Joined May 30, 2022
91
Easily accomplished via software, with a small hardware assist. If I had the time I could shoe you.

You are fixated on one solution, when there are many ways to do this. You do not need a normally closed reed switch.

Edited to add: I just saw the @Sensacell post. That is the kind of thing I was thinking of.
Yes, precisely what Sensacell mentioned is exactly what the initial design accomplishes in the previous thread (as mentioned in the first post #1). The basic latching circuit depicted in that discussion utilizes a normally closed switch. Our objective is simply to substitute a normally open switch for it.
 
Top