Switching a battery analogic read with a mosfet, need info

Hi,
I need some info. I want to read the voltage of a 18650 battery every half-second, while it discharges thru a 10w resistor, to test it.

In my precedent project, I plugged the battery power directly in A0 on my arduino. It worked fine, but when no power is applied to the arduino 5-volt input and the tested battery is still connected, The arduino is somewhat powered (by the 18650).

My new project involves testing 2 batteries at the same time, and I don't want risk frying my arduino nano. I will protect my A0 input with a mosfet and a npn transistor (see pic).

Questions:

  • Do I need to add a diode to protect the mosfet? (like in picture)
  • Is the pull-down resistor still necessary?
  • What do you think of the overall design?

Thank you!

Edit: the pull-down resistor value is 3M, not 10k in the attached pic. Sorry

Hi, welcome to the forum.

That is far too complicated. The Arduino pins should always be protected against current going into the pins. The pins can have 1mA pushed into the pin or pulled from the pin, but no more.

For a single 18650 cell, use a resistor of 4k7 or 10k from battery (+) to the Arduino analog pin. That is enough to protect the Arduino, even when it is turned off.
For voltages of 12V, two resistors are needed as a so called voltage divider.
For higher voltages, extra protection might be needed, like clamping diodes.

So I just add a resistor to limit the current and I keep the pull-down resistor, and no voltage drop.

Thank you very much! I'll write that down.

Adding a resistor, with pull-down resistor ? I don't understand. I was talking about a single resistor and nothing else.

Info from Peter_n is correct.
The analogue inputs of an Arduino have a very high impedance (>100Megohm).
Using a single resistor between +battery and A-in has no effect on the voltage reading.

One thing to watch out for is the time it takes for the internal A/D sampling cap to charge.
Therefore it's recommended is to use <=10k.

Adding a 10-100n cap from A-in to ground is another trick when higher value resistors are used, but that could slow down readings. Not recommended in your case.

So simply use a 10k resistor between +battery and analogue in. Nothing else.
That will also protect your Arduino against a 10-12volt battery voltage when the Arduino is off.
Leo..

Ok, i'm a little inexperimented with that. Does this is better?

Remove R3.
Leo..

ok, I'll continue reading about the subject!

Thank you Wawa and Peter_n :slight_smile: