Project tutorial

DIY Voltmeter with Arduino and a Nokia 5110 Display © GPL3+

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

  • 3,074 views
  • 0 comments
  • 5 respects

Components and supplies

Apps and online services

About this project

In this tutorial 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 various 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 a custom voltmeter that fits 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:

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 and if we make the calculations, we get 5V at the output! 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 forth 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 tutorial, 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.

  • ui.c
  • 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 the 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 tutorial. 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!

Code

Voltmeter.inoC/C++
   //////////////////////////////////////////////
  //        Arduino Voltmeter Project         //
 //            with NOKIA 5110 LCD           //
//           http://www.educ8s.tv           //
/////////////////////////////////////////////


#include <LCD5110_Graph.h> // THE LIBRARY I AM USING IS THIS:  http://www.rinkydinkelectronics.com/library.php?id=47


LCD5110 lcd(8,9,10,12,11);

extern unsigned char BigNumbers[];
extern uint8_t ui[];
extern uint8_t startScreen[];

float voltage = 0.0;
int sensorPin = A0;  
float sensorValue = 0.0f;  
String voltageString ="0.0";
int stringLength = 0;

float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; 
float R2 = 7500.0; 
 
void setup() {
  Serial.begin(9600);
  lcd.InitLCD();
  lcd.drawBitmap(0, 0, startScreen, 84, 48);
  lcd.update();
  delay(3000);
  lcd.setFont(BigNumbers);
  delay(1000);
}

void loop() {
  lcd.clrScr();
  lcd.drawBitmap(0, 0, ui, 84, 48);

  voltage = readVoltage();
    
  Serial.println(voltage);

  voltageString = String(voltage,1);
 
  stringLength = voltageString.length();
  displayVoltage(stringLength);
  lcd.update();
  delay(1000);
}


float readVoltage()
{

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

void displayVoltage(int length)
{
  switch(length)
  {
    case 3:  lcd.print(voltageString,14,19); break;
    case 4:  lcd.print(voltageString,2,19); break;
    default:  lcd.print(voltageString,2,19); break;
  }
}
ui.cC/C++
User Interface data
#include <avr/pgmspace.h>

const unsigned char ui []PROGMEM = {
0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x11, 0x31, 0xF1, 0xD1, 0x01, 0x01,
0x81, 0xF1, 0x11, 0x11, 0xC1, 0xE1, 0x11, 0x11, 0x11, 0x31, 0xE1, 0xC1, 0x01, 0x01, 0x11, 0xF1,
0xF1, 0x11, 0x01, 0x01, 0x01, 0x31, 0x11, 0x11, 0xF1, 0xF1, 0x11, 0x11, 0x31, 0x01, 0x01, 0x01,
0x01, 0x81, 0x61, 0x31, 0xF1, 0xC1, 0x01, 0x01, 0x01, 0xC1, 0xE1, 0x21, 0x11, 0x11, 0x11, 0x31,
0x31, 0x01, 0x11, 0xF1, 0xF1, 0x91, 0x91, 0x91, 0x31, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 0xC3, 0xCF, 0xCC, 0xC3, 0xC0, 0xC0, 0xC0, 0xC3, 0xC7, 0xCC, 0xC8, 0xC8, 0xC8, 0xC7, 0xC3,
0xC0, 0xC0, 0xC8, 0xCF, 0xCF, 0xC8, 0xC8, 0xC8, 0xCC, 0xC0, 0xC0, 0xC8, 0xCF, 0xCF, 0xC8, 0xC0,
0xC0, 0xC0, 0xC0, 0xC8, 0xCC, 0xCB, 0xC1, 0xC1, 0xC1, 0xCF, 0xCE, 0xC8, 0xC0, 0xC3, 0xC7, 0xCC,
0xC8, 0xC8, 0xC9, 0xCF, 0xC7, 0xC1, 0xC8, 0xCF, 0xCF, 0xC8, 0xC8, 0xC8, 0xCC, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x20, 0x60, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x60, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x20, 0x60, 0xE0, 0xE0, 0xE0, 0x60, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x7F, 0xFF, 0xFF, 0xF8, 0xE0,
0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x0F, 0x3F, 0xFF, 0xFF, 0xFC, 0xF0, 0xFE, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x83, 0x83, 0x81, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,  
};

const unsigned char startScreen []PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFC, 0xFC, 0xFC, 0xFC,
0xFC, 0x7C, 0x1C, 0x04, 0x00, 0x20, 0xE0, 0xE0, 0x20, 0x00, 0x00, 0x20, 0xE0, 0x20, 0x80, 0xC0,
0x60, 0x20, 0x20, 0x20, 0x60, 0xC0, 0x80, 0x20, 0xE0, 0xE0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0xE0, 0x60, 0x20, 0xE0, 0xE0, 0x20, 0x60, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0xE0, 0x00, 0x00,
0x00, 0x80, 0xC0, 0x60, 0x20, 0x20, 0x20, 0x60, 0xE0, 0x00, 0x20, 0xE0, 0xE0, 0x20, 0x20, 0x20,
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF, 0xFF,
0xFF, 0x3F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3F, 0x38, 0x38, 0x07,
0x00, 0x00, 0x0F, 0x1F, 0x30, 0x20, 0x20, 0x20, 0x30, 0x1F, 0x0F, 0x20, 0x3F, 0x3F, 0x20, 0x20,
0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3F, 0x3F, 0x20, 0x00, 0x00, 0x20, 0x38, 0x27, 0x04,
0x04, 0x27, 0x3F, 0x3C, 0x20, 0x0F, 0x1F, 0x30, 0x20, 0x20, 0x24, 0x3C, 0x3C, 0x04, 0x20, 0x3F,
0x3F, 0x22, 0x22, 0x22, 0x20, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFE, 0xFF,
0xFF, 0x3F, 0x0F, 0x83, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0x38,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xF8, 0x18, 0xF8, 0xE0, 0x00, 0xE0, 0x18, 0xF8, 0xF8, 0x08,
0x08, 0xF8, 0xF8, 0x88, 0x88, 0x88, 0x18, 0x00, 0x00, 0x38, 0x18, 0x08, 0xF8, 0xF8, 0x08, 0x18,
0x38, 0x08, 0xF8, 0xF8, 0x88, 0x88, 0x88, 0x18, 0x00, 0x00, 0x08, 0xF8, 0xF8, 0x88, 0x88, 0x88,
0xF8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x7C, 0x3F,
0x3F, 0x3F, 0x1F, 0x1F, 0x1E, 0x0F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0xC3, 0xFF, 0xFF, 0xFF, 0x7F,
0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0F, 0x08, 0x00, 0x07, 0x07, 0x00,
0x08, 0x0F, 0x0F, 0x08, 0x08, 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00, 0x00, 0x00, 0x08,
0x0F, 0x0F, 0x08, 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x0E, 0x00, 0x08, 0x0F,
0x0F, 0x08, 0x01, 0x03, 0x06, 0x0C, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0x80, 0xE0, 0xFE, 0x7F,
0x9F, 0x87, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x7F,
0x7F, 0x3F, 0x1F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
};

Comments

Similar projects you might like

Quadrature Encoder Demo

Project tutorial by Shawn hymel

  • 64 views
  • 0 comments
  • 3 respects

Arduino Amiga Floppy Disk Reader

Project in progress by Team RobSmithDev

  • 3,238 views
  • 6 comments
  • 5 respects

Arduino Controlled USB Trackpad

Project tutorial by Dante Roumega

  • 2,817 views
  • 2 comments
  • 4 respects

Arduino - Web-Based Keypad

Project tutorial by khanhhs

  • 3,942 views
  • 0 comments
  • 33 respects

Fidget Spinner RPM Counter

by Andriy Baranov

  • 7,969 views
  • 0 comments
  • 36 respects
Add projectSign up / Login