using ATtiny13 to power on/off Node MCU

I was searching for following scenario:
power latching circuit to power on and off a mcu using a attiny (with the internal watchdog timer) instead of a push button.
I am able to program the attiny properly and also the node MCU.
I am able to do this example 5 Soft Latching Power Circuits For Arduino Or Any Microcontroller! - YouTube using a push button.
now i want to replace the push button with an impuls of the attiny.
Is ther any example where I could see how it works?
Maybe here are some forum mmembers who could explain me or even better give me a schematic how to reach that goal.

thank you so much

Is your power supply a low/high enough voltage to power the ATtiny directly, or would it need to be regulated? If I understand correctly, you want the ATtiny to be powered all the time.

Do you still want the nodeMCU to turn off the power at the right time, or do you want the ATtiny to do that?

Do you still want the nodeMCU to turn off the power at the right time, or do you want the ATtiny to do that?

it does not matter. It also would be ok if I let my attiny stay awake and hold power for about 10s and then just cut the power.

my power supply will be two 18650 li-ion cells. So I have two different voltages.
3.5V (one cell) which I use to power the ATtiny directly and both cells together (around 6-7 V) which I want to use to switch on and off the power of my node-mcu (esp8266).

the attiny is powered all the time. it goes into sleep mode after the work is done.

I think this would work. It would let the ATTiny power up the Arduino, but then the Arduino would maintain its power until it's ready to shut down. Of course if you want the ATTiny to shut things down, you wouldn't need the diodes or the connection to the Arduino output.

Hey,

thank you so much. that is excactly what I was looking for. It works great! thanks a lot! It's so easy but I have to learn a lot about these things.

One other thing you might want to look at. An 18650 is 4.2V when fully charged, and is pretty much discharged at 3.5V. If your ESP8266 board has a decent 3.3V regulator, you might try powering it from a single 18650, or two 18650s in parallel. If you put the 18650s in series, giving you a maximum 8.4V, you're wasting most of your battery power as heat. The linear regulator will drop the 8.4V to 3.3V, and all of that is dissipated as heat. The drop, and the wasted power, is much lower if you bring in 4.2V.

Then the question is the regulator's dropout voltage - how much above 3.3V it needs to regulate properly. That depends on the regulator, but even if you had to change batteries at 3.7V, you still might get longer battery life putting them in parallel instead of in series.

An additional benefit is that you could control the mosfet gate directly from the ATtiny, and wouldn't need the NPN transistor at all. You can't do that if the gate is at 8.4V, but you can at 4.2V.

first of all, at the moment, I have an solution that works. I do some Voltage monitoring (I still do now) or I use two protected li-ion cells to power the circuit. I know, that's not perfect but it works.

You are absolutly right.
that's a good Idea. The problem is, as far as i know, you can power it over the 3.3V pin with a maximum of 3.6V without damaging it.
So, how could I regulate the power of one (or several parallel) 4.x V-source to power the esp8266 with a maximum of 3.6V?
Is there any solution I could do?

Thank you so much for supporting me.

You wouldn't power it at the 3.3V pin. You'd use the same pin you're using now, which I believe is called Vin on the nodeMCU. That's the pin that feeds into the nodeMCU's 3.3V regulator.

The problem is that the regulator needs the voltage on Vin to be higher than 3.3V to regulate properly. How much higher depends on the regulator, and it can vary quite a bit. Some regulators only need 3.5V, while others might need 4.5V. So it depends on what regulator is used on your nodeMCU. It's really not likely that your regulator has the very low dropout voltage you would need. On boards like these, they often use the cheapest regulators they can find, so you would have to test it to find out. If you have a variable power supply, you could see what voltage at Vin still works. Or just see how long one battery will work. You would be looking to see when the voltage on the 3.3V pin starts to drop.

Another alternative would be using a very low dropout external regulator, and feeding its output directly to the 3.3V pin of the nodeMCU. But that would involve a number of extra parts.

If you can find the regulator, you could post the markings on it, and maybe we can figure out what it is.

Edit: Actually, you could run the 4.2V from the battery(s) through a regular diode, like a 1N4001, to the 3.3V pin. You wouldn't have a regulator at all, but the diode would drop about 0.65V, which would bring the 4.2V down to 3.55V, which is barely within the 3.6V limit. This is not ideal because as the battery discharges, the diode will continue to drop the 0.65V. A regulator would only drop what it needs to drop to maintain 3.3V.

Hey ShermanP,

after pausing a month and letting the circuit doing its work, I want to improve the voltage measuring of the TWO lipo cells.
At the moment, I just do the measuring over both cells so I get values about 7-8.5 volt.
If both cells are in the same condition, it's ok. but if one cell is a little bit weaker, it could be a problem.
So I want to measure both of them.
The problem is: the esp8266 has only one analog input which I could use to get the voltages. So I need a little additional circuit which I activate by setting the first one of two gpios on high then the second one to switch a transistor which switches the power of each of the cells to my A0 analog input one after the other.

Do you have a circuit example how I should do this circuit? I am able to do the measuring thing with the esp8266 and the switching of the gpios. but the part with the transistors is the difficult one for me.

thank you so much.

merry xmas!

I think the best thing to use would be a SPDT analog switch with power-off protection, such as this one:

https://www.digikey.com/en/products/detail/texas-instruments/TS5A3159ADBVR/936395

With discrete transistors, you run the risk of both of them being on, or partially on, at the same time. That's not possible with the chip version.

You would want to divide down the 8.4V to something below 5V before it goes into the switch.