ARDUINO VOLTMETER USING SH1106 OLED DISPLAY

A voltmeter is an important tool on the workbench of every electronics hobbyist, maker or hardware design engineer. As its name suggests, allows the user to measure the voltage difference between two points.  For today’s tutorial, we will look at how you can build an Arduino based DIY voltmeter, for use in situations where you don’t have the standard meters around.

ARDUINO VOLTMETER USING SH1106 OLED DISPLAY

Measuring a DC voltage, should probably be as easy as connecting the voltage to be measured to an analog pin on the Arduino, but this becomes complicated when voltages are higher than the Arduino’s operational voltage (5V). When applied to an analog pin, Arduino will not only give a false reading but it could also damage the board. To solve this, today’s project uses the principle of voltage divider such that only a fraction of the voltage to be measured is applied to the Arduino. This fraction of voltage that goes in is determined by the ratio of the resistors used, as such, there is usually a limit to the maximum voltage that can be applied. For this tutorial, we will use a combo of a 100k and 10kresistor, with the 10k resistor on the “output side”. Feel free to experiment with other resistor values as well.

To make the voltmeter fully functional, we will add a third part, which is an SH1106 controller-based, 1.3″ OLED display, to show the value of the voltage being measured by the voltmeter.

It is important to note that this voltmeter can only monitor DC voltages within the range of 0-30v due to the values of the voltage divider used. It will require a voltage conversion circuit to be able to measure AC voltages.

Let’s dive in.

REQUIRED COMPONENT

The following components are required to build this project;

  1. An Arduino UNO board
  2. 1.3″ (132×64) OLED Display
  3. 10k Resistor
  4. 100k Resistor
  5. A breadboard
  6. Jumper wires

These components can be bought from any electronics component store online.

SCHEMATICS

The schematics for this project is pretty straightforward. The output of the voltage divider is connected to an analog pin on the Arduino while the OLED display is connected to the I2C bus on the Arduino.

Connect the components as shown in the schematics below:

As usual, a pin to pin description of the connection between the Arduino and the OLED display is illustrated below.

OLED – Arduino

VCC - 5v
GND - GND
SDA - A4
SCL - A5

Go over the connections once again to ensure everything is as it should be.

CODE

With the schematics complete we can now write the code for the project. The idea behind the code is simple, read the analog value, process it, then determine the Vin using the voltage divider equation and display it on the OLED display.

To reduce the complexity of the code to interact with the OLED, we will use the U8glib library. The library contains functions which make displaying text and images on the display easy.

To do a quick explanation of the code; We start as usual by including the library that will be used for the project, which in this case is, just the U8glib library.

  1. #include “U8glib.h” // U8glib library for the OLED

Next, we specify the analog pin to which the output of our voltage divider is connected and also create variables to hold different parameters including the Vout, Vin and the values of the resistors, correctly initializing their values.

Read more: ARDUINO VOLTMETER USING SH1106 OLED DISPLAY


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top