Saturday, February 11, 2012

Arduino as voltmeter

I made a solardatalogger for few years ago (will publish code latter to this solardatalogger).

In my solardatalogger i used arduino with a ethershield to mesure battery bank voltage with analog input.

The analog input at the arduino board are not protected, and will burn if 20 volt is connected. So i made a overvoltage protecting circuit with a few 1% resistors and a 5 volt zener.

The codesnip below is used to integrate in you own arduino sketch, enjoy ;)
Arduino as Voltmeter


The routine showed in the codesnip collect data from analog pin 5, at 5 volts contains whole 1023, the divide by 2 and converted into 4 digits. The 4 digits plus a decimal point is stored in a string of char with excitement: 05.00 ready to send serial with usb or via ethernet.

A better way to scale the analog input is with the MAP command:

map(value, fromLow, fromHigh, toLow, toHigh)

This command is very flexible. value is converted from 0 to 1023 to 0 to 20000

Then we have a good solid scale, and need only to divide by 1000 to place the decimal point.

In my own solardatalogger project data is sent to a mysql database and it is easy to handle calculations in php instead of the Arduino.


In my EVduino-MS project the voltage value will be converted into  graphic bars on the LCD touch display

No comments:

Post a Comment