anon7548
Newbie

Hi, i am using 3.7~4.2V lithium battery. I am using internal voltage reference to read constant battery voltage as we know that the battery voltage level depletes overtime. The problem is that my sensor (mini solar panel) reads max value under little light and does not go beyond that level no matter how much light falls onto it in the later stage. I need my logic to be <<< if read sensor voltage less than 3V detect night and do something whereas if voltage level is above 3V detect day and go to sleep. The entire project is ready i just need to figure out this.
Code:
void loop() {
printVolts();
//REFS1 AND REFS0 to 1 1 -> internal 1.1V refference
analogReference( INTERNAL);
//We read A1 (MUX0)
ADMUX = 0b00000000;
DIDR0 = 0;
// Start AD conversion
ADCSRA |= (1<<ADSC);
// Detect end-of-conversion
while (bit_is_set(ADCSRA,ADSC));
val = ADCL | (ADCH << 8);
val = val * 5.7; //Multiply by the inverse of the divider
Serial.println("val: ");
Serial.println(val);
}
Last edited by a moderator: