Measure Vcc using 1.1V bandgap For an battery driven application I want to measure the Vcc (using an Atmega 32u4). That is my code:

int readBandGap() {
  ADMUX = (B01 &lt;&lt; REFS0)    // VCC
        | (0 &lt;&lt; ADLAR)      // right-adjusted result
        | (B011110 &lt;&lt; MUX0) // 1.1V
        ;
  // switch off any ADC conversion
  ADCSRA &amp;= ~(1 &lt;&lt; ADEN);
  // enable ADC
  ADCSRA |= 1 &lt;&lt; ADEN;
  // start ADC
  ADCSRA |= 1 &lt;&lt; ADSC;
  // wait until finished
  while (bit_is_set(ADCSRA, ADSC));
  // first read low, then high!
  uint8_t low = ADCL;
  uint8_t high = ADCH;
  // switch off any ADC conversion
  ADCSRA &amp;= ~(1 &lt;&lt; ADEN);
  return (high &lt;&lt; 8) | low;
}

void setup() {
  Serial.begin(9600);
}

void loop() {
  int value = readBandGap();
  float vcc = 1.1 * 1023 / value;
  Serial.print(value);
  Serial.print("  ");
  Serial.println(vcc);

  delay(1000);
}


My Olimexino 32u4 board has the ability to switch the voltage between 5V and 3.3V. There are two strange things: 


the first measurement is always significantly different than the later measurements
with 5V I'm getting 450, followed by ~367; with 3.3V I'm getting 422, followed by ~395. I would have expected a higher Vcc resulting in a lower measured value (bandgap should be measured compared to Vcc).


Any ideas what is wrong with my approach?
The bandgap voltage reference needs some time to stabilize, after you enable it. See http://jeelabs.org/2012/05/12/improved-vcc-measurement/ 

Doing 3 dummy measurements, gives it enough time to do that.