Arduino Voltmeter

Arduino Voltmeter Banner
I’ve been experimenting on ADCs alot recently and I suddenly thought of doing this small experiment. I’ll try to turn my Arduino into a voltmeter by using its’ analog input and the very powerful map() function.

I’ll be using a HD44780 character LCD to display the voltage output and a 10k potentiometer to vary the input voltage going into the analog input. The Arduino analog inputs can only take in maximum of 5 Volts. Any higher than that you’ll risk burning the Arduino.

Here’s the code :

That’s what I love about Arduinos, it is really really simple to program. The Arduino library is huge and you will often find what you need in the library without having to write your own. Oh yeah, this is the circuit and I’ll compare the readings with my trusty voltmeter in real-time.

I’m starting to like the Arduino Nano and I find myself using it more often than my Uno. If you haven’t read my previous posts about Arduinos, I do have two Arduinos, the Uno R3 and this, the Nano V3.0. First, is because the Nano plugs into a breadboard which is perfect for prototyping and secondly, the Uno R3 is expensive and I don’t want to risk ruining it if I did anything silly.

Without further ado, this is a video showing how the code works :

Thanks for reading :)

  1. marvic03-19-2013

    sir can you explain to us what did you choose the value 0,979,0,470 and what is that value for?

    • Wai Hung03-19-2013

      Hi. From the ADC reading I realised that I’m getting the value of 979 at 4.7 volts.
      The max reading I’m getting from the ADC is 979. So lets say I’m getting 500, it’s 500/979 x 4.7v.
      But I can skip that calculation by just using the map function.

      • Erickson03-20-2013

        sir, you said thet you’re getting a maximum value of 0-979 at 4.7v from ADC then you scaled it down to 0-470. Now, in maximum value of 0-500, its operating at 2.4v, am I right sir? You’re formula you posted is (500/979) x 4.7v = 2.4v and I tried this formula also –> (500/1023) x 5v = 2.4v.

        • Wai Hung03-21-2013

          Yeah actually we have to divide by 1023 because thats the correct way, but what happened was that I’m sharing the 5V source with the Arduino and its been pulled down to 4.7V.

          For accuracy I divide it by 979 because thats the maximum of what I’m getting from the ADC. If I divide it by 1023 it will be a bit off.

          Only divide by 1023 if your input source is a maximum of 5V. Because 1023 corresponds to 5V.
          Example. (500/1023) x 5V = xx.

  2. yomo03-18-2013

    sir can you explain why you assign 0,970,0,470 ? what is that for?

    • Wai Hung03-18-2013

      Hi. From the ADC reading I realised that I’m getting the value of 979 at 4.7 volts.
      The max reading I’m getting from the ADC is 979. So lets say I’m getting 500, it’s 500/979 x 4.7v.
      But I can skip that calculation by just using the map function.

  3. wiicaak12-27-2012

    Hei nice project, i had same project like this.. But i want to charge the battery using a solar panel and i can read the volt of battery? Would you like to give me the schematic?

    • Wai Hung12-28-2012

      Hi. I don’t have any experience on charging batteries, can’t help you in that area sadly…

  4. Ed04-04-2012

    Nice project. What is the highest voltage this can measure? I am looking at making a project similar to this but it has to measure a 48 volt battery bank. Also, could you post a schematic of your project?

    Thanks. :)

    • Wai Hung04-04-2012

      Thanks :)
      Actually the highest voltage you can dump into the Analog pins are only 5 Volts.
      But if you want to measure higher than that, you can. Just have to use potential divider.
      Get a large enough resistor to bring down the voltage to lower than 5 Volts and fine tune the code to measure it.

      I’ll draw up the schematic send it to your email together with the code later? I’m at work now.

      Thanks again.

Leave a Reply