Arduino and MAX7219 - 50 Volt - Digital Volt Meter

Introduction: Arduino and MAX7219 - 50 Volt - Digital Volt Meter

Abstract

The Arduino inbuilt 10 bit ADC, can be used for constructing / measuring the 0Volt to 50Volt Digital Volt Meter. Popular MAX7219 display driver, connected with Arduino Uno will be used for displaying the measured voltage. This voltmeter can read only DC voltage.

Parts and components

  • Arduino Uno board
  • Max7219 4 Digit 7Segment Common cathode displays = 1 Nos
  • Or Max7219 assembled board
  • Resistor 27 K = 1 No
  • Resistor 1.2M = 1 No
  • IN5913B 3.3 Volt Zener diode = 1 No

Step 1: Schematic

  • The MAX7219 display driver chip provides a 3-wire serial (SPI) interface to drive 7-segment LED displays (common-cathode type) up to 8 digits.
  • The on-chip includes a BCD decoder, multiplex scan circuitry, segment and digit drivers, and an 8×8 static RAM to store the digit values.
  • The DIN, LOAD and CLOCK pins of MAX7219 is connected with 11,10 and 9 digital IO pins of Arduino.
  • A four digit, common cathode seven segment display is connected to the drive pins of MAX7219.
  • Otherwise, one can use the pre-assembled MAX7219 board with 4 digits, and connect the drive pins accordingly.
  • Voltage divider circuit is used to divide voltage into two parts (measurement and drop).
  • Internal Vref (1100 mV) of Arduino is selected for measurement.
  • The resistor R3 (1200K) and R2 (27K) forms the voltage divider, and connected to analog input pin of Arduino (A0).
  • IN5913B 3.3 Volt Zener diode, at A0 pin, will product the Arduino, from over voltage inputs.
  • Vmeasurment = (R2 / R3+R2 ) * Vin.
  • If Vin is 50V then Vmeasurment = (27/1227) * 50V = 1.1 V = 1100 mV.
  • ADC Resolution = Vref / (1024 -1).
  • ADC Resolution = 1.1 V / 1023 = 1100mV / 1023 = 1.075 mV.
  • DVM Resolution = 50 / 1023 = 48.875 mV.

Step 2: Software

  • The Arduino LedControl library is used for displaying digits on MAX7219.
  • The 1.1V internal reference is chosen for the ADC.
  • The voltage divider will, provide the input voltage between 0 to 1100mV.
  • Hence the software will measure and display the values between 00.00 Volt to 50.00 Volt.
  • 10 bit ADC reading is mapped to 1100 mV, which is the Vref mille volt.

/*
Measurement of 0V - 50V DC input Uses the MAX7219 and a 4x7 Segment display. The Arduino circuit connection for 7219: * MAX7219 DIN pin to digital pin 11 * MAX7219 LOAD pin to digital pin 10 * MAX7219 CLOCK pin to digital pin 9 Name:- M.Pugazhendi Date:- 12thJul2016 Version:- V0.1 e-mail:- muthuswamy.pugazhendi@gmail.com * /

// include the library code: #include <LedControl.h>

int analogPin1 = 0; // LM35 temperature sensor connected to analog pin 2 int val = 0; // variable to store the value read

// inputs: DIN pin, CLK pin, LOAD pin. number of chips LedControl mydisplay = LedControl(11, 9, 10, 1);

void setup() { analogReference(INTERNAL); mydisplay.shutdown(0, false); // turns on display mydisplay.setIntensity(0, 15); // 15 = brightest mydisplay.setDigit(0, 0, 9, false); mydisplay.setDigit(0, 1, 8, false); mydisplay.setDigit(0, 2, 7, false); mydisplay.setDigit(0, 3, 6, false); mydisplay.setDigit(0, 4, 5, true); mydisplay.setDigit(0, 5, 4, false); mydisplay.setDigit(0, 6, 3, false); mydisplay.setDigit(0, 7, 2, false); }

void loop() { // read the Analog input pin val = analogRead(analogPin1); int converted = map(val, 0, 1023, 0,5000); converted = HexToBCD(converted);

//Display the values mydisplay.setDigit(0, 0, ((converted>>12)&0x0F), false); mydisplay.setDigit(0, 1, ((converted>>8)&0x0F), true); mydisplay.setDigit(0, 2, ((converted>>4)&0x0F), false); mydisplay.setDigit(0, 3, (converted&0x0F), false); //One second delay between readings delay(1000); }

/**************************************************************************/ /*! * \brief Coverts hex into BCD * * This function will coverts hex into BCD * * \param[in] byte * \param[out] byte * \return Nill *
*/ /**************************************************************************/ unsigned int HexToBCD(unsigned int number) { unsigned char i=0; unsigned int k = 0;

while(number) { k = ( k ) | ((number%10) << i*4); number = number / 10; i++; }

return(k); }

Conclusion

  • The project is successfully simulated by using the Proteus.
  • The measured DC voltage is displayed 4 digit 7 segment display.

Be the First to Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Automation Contest

      Automation Contest
    • Make it Glow Contest

      Make it Glow Contest

    13 Comments

    0
    TheThinker
    TheThinker

    4 years ago

    Very cool! How accurate is the circuit?

    0
    PugazhM
    PugazhM

    Reply 4 years ago


    The DVM Resolution is approximately 50mV.

    DVM Resolution = 50 / 1023 = 48.875 mV.

    0
    cadrj2015
    cadrj2015

    6 months ago

    Hi Mr. Muthus,
    I am from Brazil. My name is Carlos and I am trying to assemble your project according to Instructables website, as per link below.
    I have used Proteus for simulation; I did It and everything works fine on Proteus.
    So I made the same assembly using my arduino board with common cathode multiplexed display and max7219 but does not work, no one indications on the display... I know how to transfer the sketch from Arduino IDE to arduino board, checked all connections several times but nothing happened..
    I appreciate if you could give me some help!
    Regards,
    If you want, you can zap me at +5521 98878 8084
    Thanks a lot!
    Carlos
    https://www.instructables.com/id/Arduino-and-M
    0
    PugazhM
    PugazhM

    Reply 6 months ago

    Dear Carlos,
    If you use the SPI based MAX7219, please try the following sketch, and confirm display is working fine.
    https://www.instructables.com/id/Arduino-Laser-Obstacle-Detection-Proximity-Sensing/ .
    And connect the D4,D2,D3, VCC, and Ground to the MAX7219 board.
    This experiment is based on real time hardware. And worked fine.
    If the display works fine, then rest will work as expected.
    Send me any JPG image of your work, analysing further.
    Kind regards
    Pugazh
    0
    skcamdam
    skcamdam

    Question 1 year ago on Introduction

    Setting up a voltage monitor to watch the output of a solar panel (vmp 36.81, voc 45.75) and your project looks like a good fit. But, I’m having a hard time finding the IN5913B 3.3v zener diode. Can you point me to a source or alternative diode I can buy?

    0
    paulkeenan07
    paulkeenan07

    Question 1 year ago on Step 2

    Used your code for measuring wind speed ,giving a digital readout.
    How is it possible to suppress leading zero's ?

    0
    AlexN39
    AlexN39

    3 years ago

    This circuit and code only shows positive 0 to 50 volt. But what if we want to measure negative voltage, i.e in the range of +50 to -50. Please sir modify the code and circuit as well

    0
    TahirK16
    TahirK16

    4 years ago

    Hi!

    i have successfully simulated by using proteus,Just was a little problem it needs ledcontrol library to be add in arduino compiler.Thanks

    0
    IndikaP2
    IndikaP2

    4 years ago

    I need to make 230v ac main voltage controller. If it over need to show "over voltage" and if it under voltage it need to show "Under voltage" .Those two situation there should be disconnected the appliance. If min voltage between 200 to 240 volts it is normal and connect the appliance. Please give me idea to do this project.

    0
    drj-research
    drj-research

    Reply 4 years ago

    hai

    following suggest a transformer circuit - battery is better - COMPLETLY ISOLATED

    For 230 v - which ""played with"" - and got a few belts from - the use of a MAX 138 / 139 / 140 - which built as well ( sadly the days of "samples" long gone , but one can at least reward by good reference )

    Its 3.5 digits of device - depends how accurate it required as the article has eight digits - and ain't gonna get no-where near microvolts

    As an article which authour enjoyed fair enough

    Old adage

    An engineer does for £1 what any damn fool can do for £5

    How many DVM with eight digits

    0
    pfeerick
    pfeerick

    Reply 4 years ago

    Monitoring mains AC voltage is nothing like measure DC voltage like in this project. However, you'll want to look at the measurement that the open energy monitor project has documented (i.e. using a 9V AC transformer to do the measurement at a safer voltage - https://openenergymonitor.org/emon/buildingblocks/measuring-voltage-with-an-acac-power-adapter). You'll then want to have the main power to your appliance connected to the mains via a relay, which you can turn on and off, in order to connect or disconnect your appliance to the mains. This is of course just one of many possible ways - you could wirelessly control one of those wireless switch thingys (X1??) or a foot switch type switch for accessing hard to get power points.

    0
    fnkngrv
    fnkngrv

    4 years ago

    So this could be a great project for an automobile?