I've developed a simple sensor board based on the Attiny84a microcontroller which is able to communicate over a serial connection. I'm using an arduino bootloader and the SoftwareSerial library on pins 5 (RX) and 3 (TX). I would like to be able to keep the serial line attached while power cycling the sensor. But it seems that the Attiny84 is powered through the RX line of the Serial connection, which is pulled high by the other communication partner.

It seems the RX line is pulled to 3.4 volts when nothing is attached and I can measure 1.4V across the Attiny84's Vcc and GND pins when the serial line is attached. Apparently that is sufficient to turn it on, since my debug LED starts flashing dimly.

Is there a simple way to keep the Attiny84 off even when the serial cable is attached?

  • \$\begingroup\$ Series resistor on the data line? Or a load resistor on the power supply lines parallel to the AVR, but mind you your dataline will be loaded. It is caused by the protective diodes on the chip, you can't change that. \$\endgroup\$ – jippie Nov 3 '15 at 19:08
  • \$\begingroup\$ If you find a good solution I'd be happy to know, this has always bothered me and I have just lived with it. Basically by the time I had everything else on the circuit board, it would draw off enough power that the ATMega/Tiny would be below the reset threshold. \$\endgroup\$ – MadHatter Nov 3 '15 at 19:13
  • 2
    \$\begingroup\$ It is bad design practice, other chips may latch up and selfdestruct under these conditions (power on i/o pins before supply pins have power applied). \$\endgroup\$ – jippie Nov 3 '15 at 19:16
  • \$\begingroup\$ So you're saying a series resistor on the data line is bad design practice since the I/O pin is still pulled high? It seems the most simple approach and I can confirm that it works in my case. Out of curiosity, what sort of chip is it that could self destruct? \$\endgroup\$ – Simon Harst Nov 4 '15 at 21:53
  • \$\begingroup\$ What is the value of the pull up resistor? May I dare suggest that it's simply a matter of increasing it so that there is insufficient current to power the attiny? \$\endgroup\$ – kjgregory Nov 13 '15 at 1:06

Depending on the margins you have available, this might work for you. It allows the Rx signal to draw the ATTiny Rx input down to 0.6-0.7V, but does not allow current to flow back into the processor. The node "ATTiny VCC" is switched on and off with the processor. If this is 5V (rather than 3.3V) you need to size the resistor so that it doesn't cause backflow problems in the Rx circuit.

If 0.6V is too high to trigger a good LOW in the ATTiny, you might use a low-drop diode like a Schottky or a germanium.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Easy to implement and works like a charm in my case. Thank you very much. \$\endgroup\$ – Simon Harst Nov 4 '15 at 22:41
  • \$\begingroup\$ I think that diode will block current flow to the input \$\endgroup\$ – kjgregory Nov 13 '15 at 1:04
  • \$\begingroup\$ Yes, that's what it's for. \$\endgroup\$ – Daniel Nov 13 '15 at 3:27

This happens because there are internal protection diodes on the GPIO pins so any voltage that comes in is shunted to the internal power rail...

enter image description here

Even though these are little diodes, this chip uses so little power that it is often enough to run it. This is the source of one of the top-10 hardest bugs I've ever hard to find!

Method #1 - Pull ~RESET Low

As long as the voltage on the ~RESET pin is less than 0.2*Vcc, then the chip will stay in a reset condition and not running.

enter image description here

You can connect the ~RESET pin to the power supply pin and use a pull-down resistor to keep the ~RESET pin below the threshold when there is no active power supply. Note that you need the pull-down because there is an internal pull-up on the ~RESET pin.


simulate this circuit – Schematic created using CircuitLab

This method wastes a little current, but will keep the chip in a reset state when it is not actively powered.

Keep in mind that there will be a voltage drop across the diode.

Method #2 - Isolate Input Pins


simulate this circuit

Here we use the power supply to enable the input pin. If there is no voltage coming from the power supply, no significant current to flow into the input pin.

  • \$\begingroup\$ Are you saying by holding the system in reset that no power can back-flow? I am not sure I have found that to be true. \$\endgroup\$ – MadHatter Nov 3 '15 at 20:15
  • \$\begingroup\$ Power will still back flow, but the chip will not run - it will be in a RESET state. \$\endgroup\$ – bigjosh Nov 3 '15 at 20:16
  • 1
    \$\begingroup\$ No -1, but I don't think this is really addressing the problem, which is back-powering a chip via its I/O. It's just masking the symptom. \$\endgroup\$ – user1844 Nov 3 '15 at 20:27
  • \$\begingroup\$ Thank you very much for this informative answer! However it seems to me too that #1 doesn't tackle the problem at its root and #2 seems slightly more complicated than the diode solution discussed by Will Dean and Daniel, so I will try theirs first. \$\endgroup\$ – Simon Harst Nov 4 '15 at 22:01

If your comms speed is low-enough and your power-budget will allow it, you can often avoid this simply by adding a diode between the RX pin and the outside world (anode to the RX pin, cathode to the outside world), and then having a pull-up resistor on the RX pin (your micro might be able to do this internally).

Then the remote device can only pull the RX pin down, but the pull-up resistor will pull it back up.

You will probably want to use a schottky diode (e.g. BAT54), and you do need to think about the input-low (Vil) levels you'll get at the micro pin - check that they're still OK.

If you can't do it like this, you could use a buffer in that line - selecting a buffer which didn't have this protection-diode-to-VCC behaviour (e.g. 74LVC or one of the others like it - Texas Instruments call this 'Ioff' support - see this for example)

  • \$\begingroup\$ Uh....... jinx? \$\endgroup\$ – Daniel Nov 3 '15 at 20:29
  • \$\begingroup\$ You can't say "jinx" after 5 minutes :-) \$\endgroup\$ – user1844 Nov 3 '15 at 20:30
  • \$\begingroup\$ It did take me a bit to actually write my answer out and do the schematic... from my perspective it was simultaneous! \$\endgroup\$ – Daniel Nov 3 '15 at 20:31
  • \$\begingroup\$ Yes, I'm much too lazy to do the schematics. \$\endgroup\$ – user1844 Nov 3 '15 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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