In-Car circuit

Hi All,

please see attached circuit diagram. This is my first time drawing out a schematic so hopefully it makes sense.

The aim of this project is a microcontroller based board that will sit in my car and:

  • Monitor the voltage in the main electrical bus of the car (via voltage divider and input A5)
  • Monitor the voltage on a secondary battery, which powers the board (input A3)
  • Control a relay which allows the second battery to charge when active (via D11)
  • Control another relay which controls a 5v / USB socket (this has a wifi router connected to it, and some other things)

Am I making any elementary mistakes here?

OP diagram:


I don't use A4 or A5 for analog because I might need them for I2C.

Notice the bottom opto/mosfet package, each lead, on the right side, goes to 12 volts?

Will those 12 to 5 volt regulators be switching?
Why 2 regulators?

You might want to use the above link to 'test' out your voltage dividers.

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
}