Review of my voltage divider circuit

I'm going to make a circuit that measures voltage of 12V car battery. I'm going to use an Wemos D1 Mini with built in ADC. I have read that i only need to use one resistor for A0 for that?

My calculation is that i'm calculate for 20V maks input on A0 pin for being safe.

Will the following chematic work? Some recommended changes maybe?

Reference, please

If you use the high value resistor, it will limit the current flow into A0, and the diodes that protect the pins should clamp the level to Vcc (5V in this case). When A0 sees more 5V, it will always return 1023. Is that what you are expecting?

If you want actual measurements, than use a 2nd resistor so that A0 sees 5V when 12V is applied. Adding 1M from A0 to Gnd will result in:
Vout = Vin * R2/(R1 +R2)
= 12V * 1,000,000 x (1,500,000 + 1,000,000) = 4.8V.

If you are using this in a real vehicle, keep in mind that 12V on a battery will be higher when the car is running as the alternator output is higher (like 14.2V), to charge the battery (and a fully charged battery might measure over 13V), and there can be nasty spikes from other circuits also, so some additional protections might be needed at the A0 pin.

Wawa wrote this here:

1 Like

So you see that the WeMOS D1 Mini already contains a 220k/ 100k divider to reduce a 3.3 V maximum input to 1 V. For a 12 V car battery, you need to allow for the charging voltage up to 14 V, so you need to increase the "top" resistance to 1.3M (or more). 1.1M would probably do or 1.2M, though your 1.5M would allow for higher voltages (up to 16 V).

I'm not sure i' understand what you saying here....

Do i need to use that when the Wemos D1 Mini allready have an built in divider?

Yes, i know. I wrote that the A0 getting 20V (or so)

Ok, I was not aware of the board having its own voltage divider already.
The extra 1.5M will then add to the dividing down:
12V*100,000/(1,500,000+220,000+100,000) = 0.659V

So the extra 1.5M would seem not to be needed.
But something is needed for sure, as 20V in yields 6.25V at A0, which will damage the pin or its diodes.

@CrossRoads The ESP8266 analog input can not read up to VCC but up to 1V.

@Bjerknez, the answer to your question is: Yes, you can use the 1.5 MĪ© to measure 12V.
Sadly, the ESP8266 analog input is not accurate. I don't know if you can reach 200mV accuracy. With an Arduino Uno that would be no problem.

What is the reason for using a ESP8266 based controller?

Thanks.. Tom.... :grinning: :+1: :coffee: :australia:

Because i want to observe the voltage via wifi and the Blynk app :slight_smile:

My calculation falls down to 1.5Mohm when max 20V in?


Okay, well ESP32 has a 12 bits ADC resolution.

Tom... :grinning: :+1: :coffee: :australia:

I know, but does ESP32 have built in Divider like Wemos D1 Mini?

One more question:
Is there any safety advice i should take regards to the chematic over? Diodes etc?


No it doesn't, but its only one more resistor than you need with the Wemos to make a full potential divider.

Tom... :grinning: :+1: :coffee: :australia:

This would seem pretty close if I understand you correctly.

As per #5. :sunglasses:

Should calculate for max resolution (with safety in mind).
With a single 1.2Meg (standard value) series resistor you can measure to 3.2+12=15.2volt.
I doubt that ~1.8uA (calculated) pin fault current @ 20volt can do any harm to the pin.
Could always add a 100n ceramic cap from A0 to ground, to catch voltage spikes.

I will add an 100nF capacitor :slight_smile:

I'm also going to swap Wemos D1 Mini with an ESP32. I know that i have to add one resistor regards to the divider because of that.

I will update the chematic in my first post soon :slight_smile:

You must have good reasons for that.
The ESP32 is AFAIK not suitable to measure absolute voltages.

I hav done that before and it works fine :slight_smile: