Incorrect battery voltage measurements

In the sketch I provided, the reference voltage for the AD converter uses an internally generated reference voltage that is unaffected by VDD=3.3V.