Simple Arduino Voltage Monitoring

4.8K215

Intro: Simple Arduino Voltage Monitoring

In this Instructable we utilize the analog pins on the Arduino to make a simple power monitoring system that will detect the voltage on the 5v rail and perform an action if it gets too low. This could be used to shut off non essential devices that are drawing a lot of current to conserve battery power.

STEP 1: What You Will Need

General
  1. Arduino uno (or what ever you are using)
  2. Solder
  3. Hook up wire
Voltage Reference
  1. 1x 60k ohm Resistor
  2. 1x 1N4004 diode - or similar
  3. Hook up wire
  4. Small piece of prototype PCB (you could just make in on a bread board)
Equipment
  1. Soldering Iron

STEP 2: Putting It Together

The diode and the resistor need to be simply connected together in series with a wire coming from the junction of the two going to the analog pin of the Arduino.

The resistor end needs to be connected to 5V and the diode to GND. Make sure you connect the diode the right way around.

Note: the Resistor value should be high so that not too much current is being drawn.

STEP 3: Code / How It Works

This system works by reading in the voltage across the diode (which should be fairly constant) and comparing it to Vref (which defaults to the 5v rail)

The analogRead Val=(Vin/Vref)*1023

If Vin is a constant we can find the real value of Vref

Vref=(Vin*1023)/Val

This is assuming Vref is > Vin but because Vin is so low (0.44V) we should be able to achieve this.

This code outputs the Vref value to the serial monitor and turns on the LED on pin 13 when the voltage drops below 4V

Thanks for reading!

5 Comments

Hi and thank
you for this project. Please answer to my questions.

I have a
project where I want to monitor both 5V and 3.3V at the same time, because I
use wall power supply and batteries (when there is no wall power) with voltage
regulators. What changes I must do?

Also in
your pictures I can see two capacitors 100F each. Why are you putting them?

Thank you.

I'm not too sure what you mean, this will only monitor the 5v supplying the Arduino. If you are supplying power from a wall supply then why do you need to monitor the voltage? If you want to monitor the voltage from the batteries then you just need to analog read the voltage of the batteries

Thank you
for your replay.

I want to
monitor the voltage because I suspect big voltage drop due to relays and some
other peripherals I have (TFT monitor, LCD display, some 5V sensors, 5V cooling
fan, 3.3V 5110 Hitachi display and others). I have errors during the operation of
these, so I want to know if voltage I have is enough.

Thank you.

I understand the resistor is there to limit current, but what is the diode for?

The voltage across the diode is the thing we are measuring, when you do an analogue read, the arduino compares the input voltage to the reference voltage which is the 5v power supply by default. As the power supply voltage decreases the voltage across the diode stays relatively the same, if we assume the voltage across the diode remains the same as the the power supply voltage drops we can calculate the approximate power supply voltage