@nilclass
@discuss.tchncs.deI can't recall a time when I wasn't lost in the inner solar system. Currently I'm stuck on the third dot - how do I proceed?
::: spoiler Alt
The picture shows today's XKCD comic.
Transcript:
[A grayed-out sentence in the Times New Roman font reads "Optimistic aliens measure space typographically". The "O" in "Optimistic" is dark black and indicated as representing the Sun (not to scale). The dots of the letters "i" in the sentence are similarly dark black. The dot in the first "i" in "Optimistic" is indicated as representing Mercury; the dot in the second "i" represents Venus; the dot in the third "i" represents Earth. The dot in the "i" in "aliens" is indicated as representing Mars. The dot in the "i" in "typographically" is indicated as representing Jupiter. A measurement bar indicates that the distance between the "O" and the third "i" in "Optimistic" is equivalent to 1 AU (astronomical unit).]
[Caption below the panel:]
Space tip: if you're ever lost in the inner Solar System, you can just type out the phrase "Optimistic aliens measure space typographically" in Times New Roman and use the dots as a map.
:::
I am powering a 5V microcontroller (arduino clone, atmega328p) using a 9V block and a buck converter. Now I want to let the microcontroller occasionally measure the battery voltage, so I can get an idea of how full it is.
My first idea was to use a simple voltage divider:
I've chosen the resistor values so that:
< 1.1V
, to be able to use the 1.1V internal reference of the atmega's ADCR1 || R2 < 10kΩ
, since the atmega datasheet says "The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less"This is great and all, but what bothers me is that this circuit will constantly draw ~100µA from the battery.
So, my next thought was to add a mosfet to the divider, to switch it on only while measuring:
This is obviously bad, because now when the mosfet is off, the ADC input sees the whole battery voltage.
To address that issue, I've added a second mosfet into the measure path:
This works, and it does not draw any current, except while measuring.
However, it's quite a few parts. So I'm curious if anyone has an idea how to do this with just a single mosfet. It seems to me like it should be possible, but I haven't figured out how.
Oh, and if I'm doing something stupid here, please tell me :)