So vielen dank, nun gehts.
habs wie folgt gelöst:
Vref intern genommen. 2,56V
Ue = Vref / 1023 * ADC5_wert * ( 1+ R1 / R2 )
Code:
#define R1 12 // 12k
#define R2 10 // 10k
#define Vref 2.56 // Internal 2.56V Voltage Reference
// Ue = Vref / 1023 * ADC5_wert * ( 1+ R1 / R2 )
float BatPower(){
// REFS0=1; REFS1=1; MUX0=1; MUX2=1
ADMUX |= 0b11000101;
ADCSRA |= (1 << ADSC); // Start conversion
while (!(ADCSRA & (1 << ADIF))); // wait for conversion complete
ADCSRA |= (1 << ADIF); // clear ADCIF
return( (float)Vref / (float)1023.0 * (float)(ADCL + (ADCH << 8)) * ( 1+ (float)R1 / (float)R2 ) );
}
Lesezeichen