Two ways to solve that problem.
-
Change Aref from default to one of the internal reference voltages (1.1volt or 2.56volt).
And drop the "voltage to measure" with a voltage divider to that range.
This is the easiest way, and only needs one line of code in setup(). -
Measure VCC internally, and use that value in your code.
Google "Arduino secret voltmeter" for instructions.
Note that only voltages, or sensors with a voltage output need the above.
Many sensors are ratiometric (pot, thermistor, ACS712 etc.), and give worse results with a stable reference.
Leo..