The opto/mosfet package is described as a solid state relay in the editor I'm using, which is the closest thing it had to what I'm actually using, an optoisolator and a heavy duty (40A 12v) relay. When closed, that relay connects the + of the secondary battery to the + of the cars electrical system, charging the secondary battery.
the 12v / 5v regulators are cheap dc-dc buck convertors.
I have 2 just to ensure I can pull enough current through the USB one without disturbing the one powering the Arduino. If there's no possibility of that happening, I can just use one.
deicist:
Am I making any elementary mistakes here?
Your voltage divider values suggest you are comparing battery voltage to the unspecified 5volt supply.
That could be noisy/dirty, so your measured results will be the same.
Better to use 33k:2k2 dividers, and enable the internal stable ~1V1 reference voltage of the Uno.
Test sketch attached.
Avoid using pin13 if you can. That one might flash during boot-up.
Maybe easier to just use a fat Schottky diode or battery isolator between engine and house bank, like everybody else does.
You can buy them in a marine shop, mounted/encapsulated on a heatsink.
Leo..
/*
0 - ~17volt voltmeter
works with 3.3volt and 5volt Arduinos
uses the stable internal ~1.1volt reference
10k resistor from A0 to ground, and 150k resistor from A0 to +supply
(1k8:27k or 2k2:33k are also valid 1:15 ratios)
100n capacitor from A0 to ground for stable readings
*/
float voltage;
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // use (INTERNAL1V1) for a Mega
}
void loop() {
voltage = analogRead(A0) * 0.01660 ; // calibrate by changing the last digit(s) of 0.0166
// print
Serial.print("The supply is ");
Serial.print(voltage);
Serial.println(" volt");
delay(1000); // remove when combine with other code
}