The BBC GPIO connection rings (labelled 0, 1 and 2) of a micro:bit can all be used as analog inputs.
You might think, that as long as you are careful to to exceed the 3V input voltage limit, then you can measure any low voltage whatever the source. Perhaps a photoresistor in a voltage divider arrangement with a fixed resistor.
While this is basically true, if the source of the voltage to be measured has a high output impedance, at some point the voltage measured by the micro:bit will diverge from reality as the impedance of the voltage source being measured increases.
In reality, you can't measure something without altering it. The best we can do is to make the measurement errors small, so that they can be ignored.
This blog post determines the extent of this measurement error with the micro:bit's analog inputs.
Here's a handy test program that reports the voltage at P0 when button A is pressed, that I used in this experiment.
Use a multimeter to measure the voltage between the 3V and GND ring connectors on the micro:bit and put this value in for Vanalog. I was powering the micro:bit from USB, so Vanalog was about 3.2V.
You will also need:
- A digital multimeter on DC volts range
- Resistors 100Ω, 1kΩ, 10kΩ, 100kΩ, 1MΩ, 10MΩ
- A low-impedance voltage source such as bench power supply (set to 2V) or just an AA battery
- An alligator lead