ist/enlighterjs.min Arduino Vcc Measuring without analog pin
Type Here to Get Search Results !

Arduino Vcc Measuring without analog pin

General Voltage Measurement


Once Vin is determined, the VCC can be calculated by the formula:

Vcc = Vin x (R1 + R2)/R2


Internal Analog Input Circuitry of the ADC


measure the VCC/Battery voltage without using any I/O pins or external components.

The core idea is to let the internal reference voltage Vbg act as ADC input, 

and the target VCC act as ADC reference.

This solution helps the users setting up applications with low power consumption, 

low MCU pin count, and/or few BOM parts.

For better resolution, this solution should be optimized due to its non-linearity. 

In general voltage/battery monitoring, the solution is quite attractive.


Features

• VCC or battery voltage measurement

• No I/O pin occupying

• No external components

• Low power consumption


Example Code :


void setup() {

  Serial.begin(9600);

}


void loop() {

  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);

  delay(2);

  ADCSRA |= _BV(ADSC);                         // Start conversion

  while (bit_is_set(ADCSRA,ADSC));        // measuring

  

  uint8_t ADC_RES_L = ADCL;        

  uint8_t ADC_RES_H = ADCH;

  float Vcc_value = ( 0x400 * 1.1 ) / (ADC_RES_L + ADC_RES_H * 0x100);


  Serial.print(Vcc_value);

  Serial.println("V");

  delay(1000);

}




Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.