i have a small project where i just sucessfully destroyed my frist of 5 Digisparks (Attiny85). enter image description here

In the Picture you see the Cirucit. I have 2 Liion cells connected in series to get high enough voltage to step it down to constant 5V. To these 5V some Neopixels and a Digispark controller are connected which will set the color for the Neopixels. A0 and A1 measure the Voltage of the Cells to signal the user if the Voltage is to low so it can manually be switched of. While prototyping it i didnt have the 10k resistors in there.

Now what happend: While connecting the cells after each other the Controllers LEDs already lit up with the Frist cell. I guess it was powered trough the A0 pin (again i didnt have the 10k resistor in there), so i guess the internal IO Protection diodes conductet the voltage trough and this way the controller got damanged. Since this happend it wont turn on Anymore.

The problem: since i have really small space i cant use a multiple pole switch to also remove the voltage from the IO pins and therefore i will always have voltage von A0 and A1 while there is no 5V Supplyvoltage. I would guess that the Series resistance on the pin would be enough to Limit the current trough them and this way protect the controller from damange. But i dont really have experience with that and hope that you guys can give me some hints what could also be a problem or what could help :) I really dont want to destroy a second one xD

Thanks in advance and have a nice day :)

  • 1
    You are correct in your analyses of the original problem. The 10k resistor should be fine, as it would only let through 0.4mA. Though it's not exactly elegant. This current might be a problem for the bottom battery, if it's left turned off for a long time. As it would slowly drain the battery.
    – Gerben
    Commented Jun 30, 2020 at 14:57
  • @Gerben I thought the analog inputs on most Arduino boards were capacitive, so the current flow is near zero? (I guess if the board is off, the pin might be operating as a digital output on LOW, which would connect it to ground.)
    – Duncan C
    Commented Jun 30, 2020 at 17:13
  • Normally in this situation you would isolate the connections to the batteries with P-channel MOSFETs and only switch them on when you want to sample the voltage.
    – Majenko
    Commented Jun 30, 2020 at 18:23
  • @DuncanC the problem here were the clamping diodes inside the IC on each IO pin. So the 3.7V was going into the pin, though the clamping diode, to Vcc. Powering the entire circuit through this diode. This can work for a few milliamps, but with the LED strip, the diode won't survive for long.
    – Gerben
    Commented Jul 1, 2020 at 14:10
  • That makes sense. I forgot about the clamping diodes providing a path for inputs going to VCC.
    – Duncan C
    Commented Jul 1, 2020 at 17:06

3 Answers 3


For this I would recommend isolating the power from the batteries with P-channel MOSFETs and only switching them on when you want to sample the voltage. This means that there is no power consumption at all (aside from an absolutely minuscule leakage current) when turned off.

The whole setup would require 4 MOSFETs - two P-channel and two N-channel. They don't need to be big, since the currents involved are very small, but they do need to have "logic level" thresholds, ideally < 1.5V (-1.5V for the P-channel).

The basic circuit looks like this:


simulate this circuit – Schematic created using CircuitLab

The circuit is made up of two identical segments - M1+M3 and M2+M4. The operation is fairly straightforward:

  • M1 (M2) is kept in the OFF state by R1 (R2) pulling the gate up to source.
  • M3 (M4) can pull the gate of M1 (M2) LOW turning it on and allowing current to flow
  • Any GPIO pin (D7 in this example) can control both M3 and M4 together
  • R5 keeps M3 (M4) off when there is no power - otherwise it floats.
  • R3/R4 are your existing voltage divider.

The purpose of M3 and M4 is to both turn the GPIO (D7) into "open drain" so that it's either pulling down or floating high (rather than driving high at 5V) and to isolate the two pullup gate voltages. The same effect could be achieved by two diodes and one MOSFET but it's simpler to just use two MOSFETs and not have to get diodes as well.

  • Wooow, didnt expect such a detailed answer, thanks very much.
    – KidCe
    Commented Jul 1, 2020 at 0:07
  • Sendt out the last comment before i wanted xD so here the rest: Now i have to order some common logic level mosfets :') Since im using a mechanical switch to turn off the power i guess i would still have to assure that Pin D7, in this example, would be low when i switch off, because if not it would still be connected to the pin for a split second. Any thoughts on this ? :)
    – KidCe
    Commented Jul 1, 2020 at 0:15
  • You can keep the inline current limiting resistors for that.
    – Majenko
    Commented Jul 1, 2020 at 8:09
  • Also you would only have the FETs turned on briefly when you're doing the reading of the battery voltage, and off the rest of the time.
    – Majenko
    Commented Jul 1, 2020 at 8:15

As a general rule, you should not apply a higher voltage to the logic pins of digital ICs than you do to their power pin. This means that if you disconnect power, you must also shut off voltage to the logic pins.

Failure to follow that rule will often destroy an IC.

I don't know about the specifics of the inputs on your DigiSpark. 10K resistors will certainly lower the current that is able to flow into those pins, but you would still be breaking the "don't put more voltage into an input pin than you put into the VIN pin" rule.


If all you are doing with A0/A1 is 'signalling the user that the voltage is too low for continued operation', then consider the following:

  • remove the lead from the top of the lower battery entirely
  • instead of the 1/1 voltage divider, use something like 10/1 (i.e. a 680K on top and a 68K on the bottom to provide a large series resistance (making the steady-state current drain on the battery negligible). This will also put the nominal full-charge voltage as measured at the ADC input well within the DC voltage range of the Digispark at a small cost in accuracy. The specs for the ATiny85 ADC input impedance is something like 100 MegOhms, so the accuracy drop from using a 680K series resistor shouldn't be more than a few percent. Use a variable power supply to calibrate the A/D setup so your controller will alert the user when the battery stack gets low. If you don't have a variable power supply, consider something like this


  • Jeah, measureing only the top cell is great if you always use "married cells" and have some puffer for inaccuarcy, but since i plan to make the Cells swappable i think in my application i should always monitor both cells.
    – KidCe
    Commented Jul 1, 2020 at 14:47
  • Miss-matching battery types is usually a very bad idea, but if you must, measure both voltages with high-ratio voltage dividers as described above in order to make the current drain through the divider comparable to the self-discharge current of the batteries.
    – starship15
    Commented Jul 1, 2020 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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