I was surfing the postings on AVRfreaks site and came across an interesting topic where someone asked how and if they could measure the battery voltage that was powering their AVR chip.
There were the normal suggestions of using a voltage divider across the battery and changing the A/D reference to the internal 1.1 band gap option. But also mentioned was a way I hadn't heard of or had known about before.
It seems with the proper analog mux channel selection made, one can directly measure the 1.1 bandgap voltage while using the normal default Avcc voltage reference. As the 1.1 bandgap is a constant voltage but Avcc will change as the battery voltage decreases, one will get a A/D count reading that will change with the battery's actual voltage.
So no need for external parts. That sounds useful. However the existing analogRead() allows for no selection of the mux channel 14 (for the 328 chip, channel 30 for the 1280 chip).
So is there a way to allow a sketch to read mux channel 14? Would a new whole function be required to bypass analogRead(), or could the core library for analogRead() be modified?
328 datasheet shows the following analog mux channels available:
Table 23-4. Input Channel Selections MUX3..0 Single Ended Input 0000 ADC0 0001 ADC1 0010 ADC2 0011 ADC3 0100 ADC4 0101 ADC5 0110 ADC6 0111 ADC7 1000 ADC8(1) 1001 (reserved) 1010 (reserved) 1011 (reserved) 1100 (reserved) 1101 (reserved) 1110 1.1V (VBG) 1111 0V (GND
I believe that channel 8 is the internal temp sensor recently posted about.