Self-powered Attiny13 with 2N2222

Hello everyone,

I am trying to setup a self powering Attiny (for battery powered remote purposes) with a 2N2222 NPN.

Thus, I created a sketch that sets 2N2222 base to high when the button us pressed so the transistor can keep the Attiny13 alive while completing the tasks.

void setup() {
  pinMode(PB4, OUTPUT);
  digitalWrite(PB4, HIGH);
  pinMode(PB1, OUTPUT);
  digitalWrite(PB1, HIGH);
  
  delay(3000);
  digitalWrite(PB4, LOW);
} 

void loop() {
}

After my tests, I get the correct logical state at the emitter pin during 3 seconds. But when plugged to the board, it's like there is nothing else than the switch is plugged.

Am I missing something ?

Thanks

In the picture I can see:
Reset pin (#1) is connected to GND. This would hold ATtiny13 in reset all the time.
GND pin (#4) is not connected to anything.

Similar question - take a look here:
http://forum.arduino.cc/index.php?topic=285286.msg2013521#msg2013521

Yeah I messed up the schematic, pin 4 is grounded and 1 is not connected

Normally you need 2 transistors (or MOSFETs).
This may work for low current needs (less than 100 mA):
pself1.png

pself1.png

I am not really used to transistor. I should havce listened in class 5 years ago. Now creating my home automation is way more difficult.

I ordered the following :
20×BC337 Bipolar (BJT) Transistor NPN 45V 800mA 100MHz 625mW Through Hole TO-92-3
20×BC327 Bipolar (BJT) Transistor PNP 45V 800mA 100MHz 625mW Through Hole TO-92-3
20×2N2222 Bipolar (BJT) Transistor NPN 40V 600mA 200MHz 625mW Through Hole TO-92-3
20×2N2907 Bipolar (BJT) Transistor PNP 40V 600mA 200MHz 625mW Through Hole TO-92-3
20×2N3904 Bipolar (BJT) Transistor NPN 40V 200mA 200MHz 625mW Through Hole TO-92-3
20×2N3906 Bipolar (BJT) Transistor PNP 40V 200mA 200MHz 625mW Through Hole TO-92-3
20×S8050 Bipolar (BJT) Transistor NPN 25V 0.5A 100MHz 1W Through Hole TO-92-3
20×S8550 Bipolar (BJT) Transistor PNP 25V 0.5A 100MHz 1W Through Hole TO-92-3
20×A1015 Bipolar (BJT) Transistor PNP 50V 150mA 80MHz 400mW Through Hole TO-92-3
20×C1815 Bipolar (BJT) Transistor NPN 50V 150mA 80MHz 400mW Through Hole TO-92-3

As soon as it's delivered, I will try to make it work with your drawing.*

Thanks

Am I missing something ?

In addition to the other problems, you need an appropriate base resistor for the transistor.

That omission will sooner or later destroy the ATTiny chip.

uxomm:
Normally you need 2 transistors (or MOSFETs).
This may work for low current needs (less than 100 mA):
pself1.png

Awesome circuit! A couple of suggestions:

  • The BC557 has an ABSOLUTE MAX IC of 100ma and the datasheet specs the ß at -2ma, and the Static Characteristic curve diagram stops at 50ma, this really doesn't seem a suitable transistor for this application [unless current demand doesn't go above, say -35ma]. The PN2907 [or even 2N2907] seems a better choice, at least for higher currents up to 100ma.
  • Since this is for a battery powered device, I suggest increasing the value of R1 a bit. One can argue that to turn a bipolar transistor "fully" on [i.e. saturated], one should set the base current in terms of ß=10. But, there's some wiggle room if one balances power loss, in the transistor, with current drain in the Emitter-Base leg. And, this is especially "wiggle happy" with cases of low power demand -- as is likely the case here. The reason for increasing the value of R1 is to reduce the current it drains away while this circuit is powered. But, if this is considered trivial, then no need to change it. Another way around this, is to use a P-Channel MOSFET, instead. The Source pin goes where the Emitter pin is, the Gate where the Base is and the Drain where the Collector is -- then add a 100k resistor from the Source to the Gate. Then there will be no wasteful current path. Plus, a MOSFET can be chosen to have FAR less voltage drop, and so it will not heat up at all. The SFT1342-W looks like a good choice. Relatively inexpensive, logic level [gate threshold of -1.2V to -2.6V], RDS(on) of 96mΩ at VGS = -4V [and even at VGS = -2.5V the VDS is -0.1V at a Drain current of half an amp! And at VGS = -5V, the VDS is more like 20mV at half an amp] and, its a 60V transistor, so plenty of headroom :wink: True, it's a transistor designed for much higher currents [up to -12A], but it has a very low channel resistance, thus it will drop very little voltage at the small currents likely involved here. I looked at smaller, (TO92, for instance) MOSFETS but I kept seeing RDS(on) in the the 10Ω range. At 100ma, that's a voltage drop of 1V! And, I couldn't find anything that wasn't SMD in the ish range, that were truly Logic Level (with gate threshold below -4V). Since this one is less than a dollar, then why not? It probably has a higher gate capacitance, but switching speed is not a requirement -- thus no need to worry about high gate drive current -- and that 1k resistor in the Gate leg will fix the max current to 5ma.

ReverseEMF:
The Source pin goes where the Emitter pin is, the Gate where the Base is and the Drain where the Collector is --

If you connect the P channel mosfet that way does not the body diode always conduct? It's not better swap drain ans source?

Ciao, Ale.

EDIT: sorry, I should think more before post, you circuit is OK.

ilguargua:
EDIT: sorry, I should think more before post, you circuit is OK.

No problem -- that confuses me, too :wink:

Hi everyone

I was not able to make it work.

The code is still the same.
The breadboard looks like this :

Sorry this is a bit messy..
Can you help me? It's making me angry now :confused:

Post a hand drawn diagram of your current circuit (not a Fritzing mess, please).

Here is the drawing :

Resistances are somewhat different but remain in the same range of the original solution.

Thanks for your help.

Ok guys hmmmmm don't hit me ok ?
I got bad eyes and mixed up the BC337 and BC227.

My radio remote is working

Just a small comment, I removed the resistor between Arduino VCC and Arduino Output because the appliance kept drawing current after pin shutdown. Now it works and shuts down correctly.

Thanks for your help. I still need to figure out why it's working (magic)

-- Removed, because, as MarkT pointed out, it just won't work! Oops!

The first solution is probably better for my case since I will add several buttons and put some diodes and check which button was pressed.

Thanks

ReverseEMF:
Here's another way to do it (possibly a little tricker for the nubie):

That circuit can't work for a power MOSFET which has a body diode, since that would simply conduct all the time. A signal MOSFET (no body diode) won't have a low enough Rds(on) for most cases I fear.

As stated previously normally you need 2 active devices to perform this task.

Hello,

Here is the final sketch :

The output device is a 433Mhz radio transmitter.

Thanks for your help gentlemen.

Good to hear that it is working.
Thank you for posting the final solution.