This little device when constructed draws about 2.5 mA from the battery it is connected across so for boats ,cars, etc .It can be left on all the time.
It gives the battery voltage as a colour on an RGB LED .
Very Low voltage -Flashing Red Under 11.5V
Low Voltage -Red 11.5 to 11.9V
Useable range -Green 12V to 13.2V
High Volts -Blue 13.3 to 14.4 V
Very High Volts -Flashing Blue Over 14.4 Volts
These points can be adjusted wherever you like them.
The pictures are of my testing setup-Put a diode in one or both of the lines and adjust calibration ! I am using 5 V from the arduino to a voltage booster with readout and adjustable output voltage to check out the working model
ATTiny 85 and holder
150K resistor (Voltage divider to 12V(
47K resistor (Voltage divider to GND Junction to Pin 2)
12K resistor (to LED Anode) R pin 7 ,G pin6 ,B pin 5
RGB LED Common Anode Can use Common Cathode change code to HIGH
78L05 1 amp or less regulator (watch -pins are Output Gnd Input)
You must program the ATTiny85 perhaps using an arduino (Lots of info on that -google)
Calibrate the program using a multimeter on the source voltage and by using the arduino loaded with "read an analogue voltage" from the examples you can watch on a serial port the sensed voltage change, on pin A0 of the arduino connected to pin PB3 of the ATTiny85, to get the numbers you need. Its not that hard and lots of fun.
Watch the 78L05 as if it blows it passes the full 12Volts to the ATTiny85 and blows it too. If it is not earthed then it does the same thing. I found no need for the usual capacitors on the 78L05 but you may want them. Test the socket connections without the chip in it just in case you have something the wrong way around
There is lots of room for further power saving with interrupts and low power modes so if someone knows how to change the code please post the result and code.
Looking around on Instructables I found this work which uses power saving sleep mode
By placing the AtMega328P in SLEEP mode, one can further reduce the power. In SLEEP mode, most of the MCU interfaces are turned off. In this mode, the MCU can draw as little as 0.001mA. However, the MCU is no longer running, or in this case, measuring the voltage.
A watchdog time is used to wake the MCU from SLEEP. Setting up the watchdog timer to wake up the MCU every 8 seconds, will ensure that the power used is even less.
More information about the power saving modes can be found at http://www.gammon.com.au/forum/?id=11497.
Results of power saving
By using the above power saving techniques, I was able to reduce the current of the circuit down from 80mA to as low as 0.12mA when the device is in SLEEP mode. Overall, the circuit uses about 0.28mA.
Thus, before power saving the circuit will drain a 7Ah battery in about 2.8 days.
After power saving, it will take around 3.5 years for the circuit to drain the same battery.
I put my name on the code finally after 2000 views . Forgot to do that. Full Pin names of ATTiny 85 are there in code at the top