# DIY Voltmeter With Arduino and a Nokia 5110 Display

16,541

161

9

In this Instructable I am going to show you how to build a Voltmeter with a big Nokia 5110 LCD display using Arduino.

Building a Voltmeter is a great learning experience. When you finish building this project you will have a better understanding of how Voltmeters work, you will refresh your knowledge of Ohms law, and you are going to see in action how powerful the Arduino platform can be. With this project as a base and the experience gained, you will be able to easily build more complex projects in the future.

You can use this project to measure DC voltage from varius electronic circuits or monitor the battery state of your Arduino projects easily. Also, with the knowledge gained you can easily build your own voltage sensor to create your custom Voltmeter that fit your needs.

Without any further delay, let's get started!

## Step 1: Get All the Parts

The parts needed in order to build this project are these:

1. An Arduino Uno
2. A Voltage Sensor
3. A Nokia 5110 LCD display
5. Some wires

The cost of the project is very low. It is about 10\$.

## Step 2: The Voltage Sensor Module

Let’s see how this sensor module works. This voltage sensor is very simple and it can measure DC voltage from 0-25V.It consists of only two resistors! You can build your own easily if you wish, or you can buy this module sensor with less than a dollar if you want something already built. This is how it works. This sensor is actually a voltage divider. A voltage divider circuit is a very common circuit that takes a higher voltage and converts it to lower one by using a pair of resistors. The formula for calculating the output voltage is based on Ohms law. Please check the attached image.

In this module, the R1 is 30.000 Ohms, the R2 is 7500 Ohms. If we put 25V on the input, if we make the calculations, we get 5V at the output! I And that’s the maximum voltage an analog pin of Arduino can handle. So, if we exceed 25V at the input, we will burn the Analog pin of Arduino. If we put 0 volts in the input we get 0V at the output. So, if we put any voltage from 0-25V at the input we will get a voltage from 0-5V at the output.

The Arduino Uno has a 10bit ADC so the resolution that we can achieve using this sensor is 25mV. If we use an Arduino Due, we can achieve even better resolution since it has 12bit ADCs. But, of course, we need to build our own voltage sensor, because the Arduino Due board uses 3.3V logic levels, and any voltage beyond that will destroy its analog pin.

## Step 3: Nokia 5110 LCD

The Nokia 5110 is my favorite display for my Arduino Projects.

The Nokia 5110 is a basic graphic LCD screen which was originally intended for as a cell phone screen.
It uses the PCD8544 controller which is a low power CMOS LCD controller/driver. Because of this this display has an impressive power consumption. It uses only 0.4mA when it is on but the backlight is disable. It uses less than 0.06mA when in sleep mode! That's one of the reasons that make this display my favorite.

The PCD8544 interfaces to microcontrollers through a serial bus interface. That makes the display very easy to use with Arduino. You only need to connect 8 wires and use the following library:

http://www.rinkydinkelectronics.com/library.php?id=47

This impressive library is developed by Henning Karlsen who has put a huge amount of effort to help the Arduino community move forward with his libraries.

I have prepared a detailed tutorial on how to use the Nokia 5110 LCD display with Arduino. I have attached that video in this Instructable, it will provide may useful information about the display, so I encourage you to watch it carefully.

Now, let's move on!

## Step 4: Building the Voltmeter

Let's now connect all the parts together.

At first we connect the voltage sensor. It only has 3 pins. Of those, we only have to connect 2.

Connecting the Voltage Sensor

- Pin goes to Arduino's GND

+ Pin stays unconnected

S Pin goes to Analog Pin 0

The next step is to connect the Nokia 5110 LCD display.

Connecting the Nokia 5110 LCD Display

RST goes to Digital Pin 12 of the Arduino

CE goes to Digital Pin 11 of the Arduino

DC goes to Digital Pin 10 of the Arduino

DIN goes to Digital Pin 9 of the Arduino

CLK goes to Digital Pin 8 of the Arduino

VCC goes to Arduino 3.3V

LIGHT goes to Arduino GND (backlight on)

GND goes to Arduino GND

Now that we have connected all the parts together, all we have to do is to load the code. A Splash screen is displayed for a couple of seconds and then we can start measuring the voltage.

## Step 5: The Code of the Project

The code of the project consists of 2 files.

1. ui.c
2. VoltMeter.ino

ui.c Code - Graphichs for our Project

In the first file ui.c, there are the binary values of 2 icons that are displayed on the Nokia 5110 LCD display. There is the Splash icon, and the User Interface for Voltmeter that appears afterwards. Please watch the attached video I have prepared in order to see how to load your custom graphics to your Arduino Project.

VoltMeter.ino Code - Main Program

The main code of the project is very simple. We need to include the Nokia 5110 library. Next we declare some variables. We initialize the display and we display the splash screen for 3 seconds. After that, we print the ui icon once, and we read the analog value from the sensor every second.

All the magic happens in the following function:

```float readVoltage(){  sensorValue = analogRead(sensorPin);
vout = (sensorValue * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
return vin;}```

This above method, reads the value from the sensor and converts it to a voltage fron 0 to 25V. If you use your custom made voltage sensor, you have to change the R1 and R2 variables in order to reflect the resistor values of your sensor.

After reading the value from the sensor, the code converts the value to a String and displays it to the screen.

I have attached the code to this Instructable. In order to download the latest version of the code you can visit the project's webpage : educ8s.tv/arduino-voltmeter-project/

## Step 6: Testing the Project

Now that the code is loaded we can test the Voltmeter with some batteries. I test it with a rechargable AA battery, a 18650 battery and a big 12V alarm battery.

As you can see in the attached photos, the Voltmeter works fine. For comparison I have also used my multimeter. Our "handmade" Voltmeter's reading are very close to the professional Multimeter's. Great isn't it?

As you can see, this project is a great demonstration of what open source hardware and software is capable of. Within a few minutes one can build such an impressive project! This project is ideal for beginners and as I said in the beginning, this project is a great learning experience.

I would love to hear your opinion on this project. Do you find it useful? Are there any improvements that can be implemented to this project? Please post your comments or ideas in the comments section below!

## Recommendations

• ### 3D Printing With Circuits Class

6,313 Enrolled

## 9 Discussions

Hello Hightech_arduino

I am unable to get this sketch compiled. It may be posible because I could not get the ui.c file loaded onto my computers Arduino files.

I would like this project to my "Arduino Test Bench" which I am bould idn for my workshop.

Regards

Jeff Stuart

how would you go about adding in I as well as V? would you just add the current sensor in series and use another dac pin on the arduino?

hi !
it is a very cool project, I can't wait to realise it !

I actually work on the Nokia 5110 with a arduino pro mini.
do you think your library could work on an arduino pro mini ?
and do you know some good website which could help me to understand all ? (I understand all the data sheet but some fonction of C are very hard for me to understand :P )

thank you for your help, and sorry for my poor english (I'm french)

2 replies

Hi!

as the pro mini has the same chip (328p) than the uno (just the form factor changes from dip to smd), you should be just fine?

I'm French also, but answered in English so the answer can be understood from everybody, but do not hesitate to ask if there is something you do not understand.

Happy Diying !