Read ATtiny85 VCC Without ADC Tutorial

Posted on


How to Read ATtiny85 VCC Voltage Without Connecting to ADC – Today I am trying to implement an ADC to read the VCC voltage of an ATtiny85.

This does not require a cable or wire connected between the ADC pin and the VCC pin, but rather reads using the internal registers on the chip.

The VCC voltage read by ATtiny85 will be sent to the computer via serial communication and displayed on the Arduino Serial monitor.

ATtiny85 by default has no Tx Rx pins. To be able to outsmart this we use the SoftwareSerial.h library.


In this experiment, I used 2 circuits. The first circuit is Arduino as an ISP which is connected to ATtiny85. It is used to program the ATtiny85. Read here.

The second circuit is, the ATtiny85 circuit is connected to the FT232. This is used to receive ATtiny data and will be forwarded to the computer. Read here.

Code Program

To program the VCC voltage reading using the internal ADC, please use the following program:

#include "SoftwareSerial.h"

int Rx = 3;
int Tx = 4;

SoftwareSerial mySerial(Rx, Tx);

void setup() {
  pinMode(Rx, INPUT);
  pinMode(Tx, OUTPUT);


void loop() {
  float supply = readVcc() / 1000.0;
  mySerial.print ("VCC: ");
  mySerial.println (supply);

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
  ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
  ADMUX = _BV(MUX3) | _BV(MUX2);
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA, ADSC));
  result = ADCL;
  result |= ADCH << 8;
  result = 1126400L / result; // Calculate Vcc (in mV); 1126400 = 1.1*1024*1000
  return result;

Once uploaded, open the serial monitor. Make sure:

  • You select port FT232 FTDI
  • Set the baud rate of the serial monitor at 9600.

You will see a response from ATTiny85 in the form of a voltage that is read in the Arduino IDE Monitor serial.

 ATtiny85 VCC

If you don’t receive the response, check the circuit again. Thank you for visiting the website Chip Piko.

I hope this article is useful.

1 comment

  1. I am a website designer. Recently, I am designing a website template about The boss’s requirements are very strange, which makes me very difficult. I have consulted many websites, and later I discovered your blog, which is the style I hope to need. thank you very much. Would you allow me to use your blog style as a reference? thank you!

Leave a Reply