Digital Arduino Voltmeter with Temperature

Digital Arduino Voltmeter

Step 1: The case

I dug out an appropriate case from the dumpster, milled out a rectangular hole for the lcd, and drilled holes to mount the LCD and the Arduino. I used brass standoffs and fiber washers to prevent shorts. Then I gave the whole case a quick spray of flat black to cover the scratched and scraped gray that originally covered the case.

Step 2: Voltage Divider

The first part of the code and electronics I built was the voltage divider. I like to build my projects a section at a time, and get each section working, before progressing to the next. I built the voltage divider and tested it with the serial monitor before going on to the next section.To measure voltage, you take two resistors and connect them in series. Apply your input voltage to the ends, and take a reading from the center connection of the two resistors. One end of the resistors will be connected to ground on the Arduino. We have an AC voltage we want to monitor, but will rectify it to DC first.To learn more about voltage dividers, see 

Digital Arduino Voltmeter

My first attempt at this was disappointing.  When measuring a DC battery, my readings were rock solid. When reading the dc output of a bridge rectifier, they swung from full voltage to zero, and back again on a regular cycle. This was fixed by applying a capacitor across the output of the bridge rectifier, as per the schematic. If you will be monitoring a DC voltage, you can eliminate the capacitor and the bridge rectifier.  The other part of the circuit is the 5.1v Zener diode from the Arduino input to Gnd. This is to prevent you from doing something foolish with the voltage divider, like presenting higher than 5v to the Arduino inputs.  If the input goes higher than 5v, the Zener will conduct the excess to ground.

I calculated I needed a 3k and a 1k resistor for the voltage divider, but some adjustment might be necessary, so I used two 10k pots to give me the ability to fine tune the output.

Before connecting the output of the voltage divider to the Arduino, I plugged my DMM into the output of the voltage divider, connected the AC source, and adjusted the two pots till I got exactly 5v. Again, the 5.1v Zener prevents you from doing something foolish with the pots.

I then connected my DMM to the AC source, took the AC reading, and put it into my map command in the code as the value for 1023 on the ADC. After all the wiring was finished and the code uploaded to the Arduino, I connected the input of my AC transformer to a variac so I could run the transformer primary from 0-125vac. With my DMM on the secondary of my 29vac transformer, the Arduino LCD display mirrored the DMM almost perfectly throughout the complete range.

Arduino code as follows:

int voltPin = 0;     // voltage divider (middle terminal) connected to analog pin 0
// outside leads to 0-29vac

void setup()
Serial.begin(9600);          //  setup serial}

void loop()
{val = analogRead(voltPin);    // read the input pin
Serial.println(val);             // debug value
volt = map(val, 0, 1023, 0, 29); // map 29v range
Serial.println(volt);             // voltage


Step 3: Temperature – TMP36

The first version of this unit used a TMP36 analog temperature sensor. With flat side facing you, pins pointing down, this three legged transistor looking device has connections for (starting from left) +5v (pin1), data out (pin2) and Gnd (pin3).int tempPin = 2;     // TMP36 data pinvoid setup()
{Serial.begin(9600);          //  setup serial} 

void loop()
{int reading = analogRead(tempPin);    // read the input pin
float voltage = reading * 5.0;
voltage /= 1024.0;

Digital Arduino Voltmeter with Temperature Schematic

Serial.println(” volts”);
float temperatureC = (voltage – 0.5) * 100;
Serial.println(” degrees C”);
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.println(” degrees F”);


Step 4: Using DS18B20 Sensors

To use the DS18B20, you need two library files (updated for Arduino 1.0), and you need to find the address of your sensor. Library files and sketches to find your address can be found at

Step 5: Reading Temperature – DS18B20

Looking for more accuracy and stability, I switched out the TMP36,for a DS18B20. This unit looks the same, but is digital instead of analog. It has an onboard address, and is a bit more complicated to use. The pin connections are reversed, as you can see from the picture. I used the waterproof version which came with 2 foot leads. This one has white for data, black for ground, and red for +5vdc. A 4.7k ohm resistor connects between white (data) and red (+5vdc).

About $2 each at

Originally I installed the resistor and connections on the voltage divider board. I was getting the dreaded 85C/185F output from the sensor, so I figured my connections were bad. I then moved the connections directly to the Arduino, and made two unused digital ports +5vdc and Gnd by writing a high and a low respectively. I did this to keep the leads together, instead of cutting the cable apart and separating them. That did not fix the problem, so I looked over my code with a fine tooth comb. I didn’t find any errors, so I created a second sketch (no cutting and pasting), and that one worked. I don’t see any differences compared to the old one, but there had to be something corrupted somewhere. I’ve used these sensors in dozens of projects, and never had this issue pop up before. It was not a bad sensor or connection.

Read more: Digital Arduino Voltmeter with Temperature

Leave a Comment

Your email address will not be published. Required fields are marked *