Nick Koumaris
Published © GPL3+

DIY Voltmeter with Arduino and a Nokia 5110 Display

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

BeginnerFull instructions provided1 hour13,698
DIY Voltmeter with Arduino and a Nokia 5110 Display

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Voltage sensor (generic)
×1
Nokia 5110 LCD display
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Voltmeter.ino

C/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.c

C/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, 
};

Credits

Nick Koumaris

Nick Koumaris

13 projects • 208 followers
My name is Nick Koumaris and I am a software engineer from Sparta, Greece. I love building projects and share them with the world!

Comments