Quick and easy Voltmeter with a Arduino and a TV.

A while back I stumbled on a small Arduino sketch that turns your Arduino into a Voltmeter. It uses a voltage divider on the ADC to lower the voltage/current and with some ones and zeros going around the AVR it spits out a voltage reading onto a parallel compatible LCD.

Since I was killing time the other day I thought I would try it out but I didn’t have a LCD on hand so I thought I would reverse engineer the code to use the Arduino TVout Library. Sure enough after about twenty or so minutes I got it to work correctly. Even had enough time to make it look fancy.

It’s very simple to setup. Pin A0 is the input with the voltage divider of 10K and 100K ohm. 10K is grounded and the 100K is the voltage input.

Digital Pins 9 and 7 are the sync and video lines for the composite video.

vm

If you have a older TV that doesn’t have composite and has antenna jacks you could use this.

stripboard

I’m not 100% sure but for PAL you just need to change the code from NTSC to PAL on the line TV.begin(NTSC,120,96); to TV.begin(PAL,120,96);. Also I think you would need to use Digital pin 12 instead of pins 7 and 9. When I was looking at the TVout library demos for NTSC and PAL side by side they look the same expect for the declaration of the TV.begin code.

Here is the code

/*
DC Voltmeter
An Arduino DVM based on voltage divider concept
T.K.Hareendran
TVout port code by TCPMeta
Use a 1K resistor on pin 7
Use a 470 ohm resistor on Pin 9
Just follow the typical pinout for the TVout Library found everwhere on the net.
*/
#include <TVout.h>
#include <fontALL.h>

TVout TV;
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // resistance of R1 (100K) -see text!
float R2 = 10000.0; // resistance of R2 (10K) – see text!
int value = 0;
void setup(){
pinMode(analogInput, INPUT);
TV.begin(NTSC,120,96);
TV.select_font(font6x8);
TV.println(“//////////////////”);
TV.println(“// DC VOLTMETER //”);
TV.println(“//////////////////”);
}
void loop(){
// read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0; // see text
vin = vout / (R2/(R1+R2));
if (vin<0.09) {
vin=0.0;//statement to quash undesired reading !
}
TV.select_font(font8x8);
TV.print(9,40,”Volts=”);
TV.println(vin);
TV.select_font(font4x6);
TV.println(9,85,”TVOut Port By TCPMeta”);
delay(500);
}

Now be sure to use the TVoutBeta1 from here. Also from tinkering out for better results is to messure the 10K and 100K resistors with a ohm meter and make it reflect on lines 16 and 17 to get a better zero out setting.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s