   // Detect end-of-conversion
   while (bit_is_set(ADCSRA,ADSC));
 
-  // Reading register "ADCW" takes care of how to read ADCL and ADCH.
+  // read ADCL and ADCH.
   return (ADCL | (ADCH << 8)); // combine bytes
 }
 

  digitalWrite(PIN_SENSOR_VCC, HIGH);

  tx_payload.setMsgId(++msg_id);

  uint16_t vcc = readVcc();
  tx_payload.setVcc(vcc);
  tx_payload.setCpuTemperature(readCpuTemperature());

  // Read the temperature.
  tx_payload.setTemperature(readTemperature());

  tx_payload.setChargeMa(readSolarCurrent());

  int avg = 0;
  double t;


  // The internal temperature has to be used
  // with the internal reference of 1.1V.
  // Set the internal reference and mux.
  ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
  ADCSRA |= _BV(ADEN);  // enable the ADC
  _delay_ms(10); // Wait for Vref to settle

  // Average a bit shiftable amount of readings.
  for (uint8_t i; i < 8; i++) {
    sum += readCpuTemperatureRaw();
  }
  
  avg = sum / 8;

  // subtract 273 for celsius
  // subtract the extra offest.
  // the 1.22 is a fixed coefficient k (http://www.atmel.com/Images/Atmel-8108-Calibration-of-the-AVR's-Internal-Temperature-Reference_ApplicationNote_AVR122.pdf)
  //@link https://playground.arduino.cc/Main/InternalTemperatureSensor
  t = (avg - 324.5) / 1.22;

  // The returned temperature is in degrees Celsius.
  return round(t);
