Simple Arduino Voltage Monitoring
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
- Arduino uno (or what ever you are using)
- Solder
- Hook up wire
- 1x 60k ohm Resistor
- 1x 1N4004 diode - or similar
- Hook up wire
- Small piece of prototype PCB (you could just make in on a bread board)
- 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
captainj56 8 years ago
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.
MrSirLRD 8 years ago
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
captainj56 8 years ago
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.
JesseW6 8 years ago
I understand the resistor is there to limit current, but what is the diode for?
MrSirLRD 8 years ago