0

I am a newbie and have followed a tutorial to build a battery level indicator as below the basic design

Please suggest any changes I'll need to make to make the circuit useful with a 48V battery as the above circuit is tested with a 12V one. Thank You.

2 Answers2

2

You have a voltage divider there, which would give (if the pre-set pot was set to the maximum):

Vout = (Vin * R2) / (R1 + R2)
Vout = (12 * 10000) / (100000 + 10000)
Vout = 1.09

Thus a 12V battery would present 1.09V at the analog input.

This same wiring would seem to be in range for a 48V battery:

Vout = (48 * 10000) / (100000 + 10000)
Vout = 4.36

Since the analog input can handle up to 5V, then that should be OK. However I would test the voltage divider output first with a multimeter to make sure it doesn't exceed 5V - before connecting it to the Arduino.


You would probably need to change the code to test for different ranges of input voltages, other than what is used for the 12V battery.

Nick Gammon
  • 38,184
  • 13
  • 65
  • 124
  • 2
    Also, if you are using a 3-pin trimmer/pot, be sure to short the central pin to the "unused" one. In this way, if dust/dirt collects on the resistive element, or in case of a major failure, the maximum resistance of that trimmer will be 10kOhm, and not "infinite", avoinding feeding a destructive 48V to the digital input. – next-hack Sep 03 '17 at 07:31
  • Good idea. You don't want the pot to go open circuit as you turn it as it hits specs of dust. – Nick Gammon Sep 03 '17 at 07:34
  • That's great! Edited because I figured it out. – Abhishek C. Gidde Sep 03 '17 at 09:26
  • You might also want to connect a 5V zener diode between the voltage sensing pin and ground. That way if you exceed 5V the zener will shunt the excess voltage to ground and protect the pin. – Duncan C Oct 15 '20 at 19:15
1

To get a smoother switch from one level to another you could introduce another resistor and use analogWrite() to dim one LED and make next brighter.

Ref.: https://www.arduino.cc/en/Tutorial/PWM

enter image description here

MatsK
  • 1,356
  • 1
  • 11
  • 24