Self Voltage Meter

Hello, I'm brand new to the world of microcontrollers and electronics so cut me a little slack on this one. I have an Arduino Mega2560 and I'm looking to measure it's own Vin voltage. I've drawn and attached an image of a breadboard layout of what I believe and am hoping will do what I want it to do. The battery is connected to the controller and along the connection line is a voltage divider (10Kohm and 8Kohm). I'm measuring across the 10Kohm resistor with the ground on one side and the 0A analog input pin on the other side. My hopes is that this cuts down the 9Vin to 5v which is the reference voltage of the board and I will be about to calculate the board's source voltage. Am I doing this correctly? And I mean even to the basics, are all the wires at the right spots including the battery terminals. I don't want to fry my board.

I also am aware that this current circuit design will put a constant drain on the battery through the voltage divider. I plan to insert a gait to prevent the constant drain unless I am measuring the voltage. As far as that is concerned, I would also like to know which part I should use for the gait. Would it be an NPN or PNP transistor? Or would that not work because I'd get amplification and an inaccurate reading? Or should I just use a SPST relay? Also, would I be okay just using one gait anywhere on the voltage divider or would I have to place a gait on both sides of the analog pin on the voltage divider?

Thanks a lot in advance,
Stauffski

You diagram shows the high side of the voltage divider and +9v power going to another Gnd pin instead of Vin, but otherwise it's correct. Fresh 9v batteries sometimes produce more than 9v, so I would make both resistors 10k, giving you 5v on the analog input pin for 10v Vin.

Regarding the current drain, why not just increase the resistors to reduce it? For example, 2 x 100k resistors will reduce it to 45uA, and 2 x 1M resistors will reduce it to 4.5uA. These currents are insignificant compared with the current drawn by the Arduino. If you do go as high as 1M, then I recommend connecting a 10nF or 100nF capacitor across the lower resistor.

Thanks. Haha, not sure how both of those leads found their way to ground. I agree, bump the resistance and forget about the drain, however, I still need a gait. Although the drain is insignificant during Arduino operation, when the project is off and stored away, it won't be so insignificant... Right?

Stauffski