An inbuilt ADC in an MCU is usually crappy, for instance: -
- Intergral non-linearity error might be +/- 2 LSBs
- Differential non-linearity error might be +/- 1 LSBs
- Zero offset error might be +/- 3 LSBs
- Gain error might be +/- 2 LSBs
All these conspire to make the average ADC inside most MCUs really crappy for accurate measurements. Worst case scenario INL+DNL error is 3 LSB with an offset error of 3 LSB and a mid-range gain error of 1 LSB.
Total error is 7 LSB - that's an absolute accuracy of 7 in 1024 or ~0.7%. Given that you are wanting a range of measurements (before you change the reference resistor) of maybe 10:1, the input signal might be only 10% of full-scale hence an error of ~7%.
Then you have ADC input bias currents. These might be as high as 0.5uA. This flows into the resistors are produces an error in (say) 100kohm of 50mV!
Plus there is the issue that Microchip tend to say on most MCUs that the source impedance feeding the ADC input should NOT be greater than 10k if you want "best accuracy". If you want to measure 1 Mohm with a reference of 1 Mohm the equivalent input resistance is 500 kohm i.e. 50 times above the limit imposed.
In short don't use MCU ADC inputs if you are wanting an accurate result. Read the data sheet.
Solution - use a precision current source to create a voltage across the unknown resistor - buffer this with a high impedance circuit (maybe based around an op-amp) and use an external ADC possibly 16 bits to get an accuracy that barely needs to be thought about.