The Arduino measures its own USB Voltage / VCC

The Arduino can measure its own processor voltage VCC. With a long USB cable this voltage can drop to e.g. 4,5V. That is important if you want to make a simple measurement with the AD converters on board.


Circuit board:Arduino Nano with wire bridge from 3V3 to A1

The program:

// Let the Arduino measure its own VCC voltage.
// Hardware:
// - Arduino Uno, Nano or similar with 10 bit AD converter
// - wire bridge from 3,3V to A1 (D15)
// measure with a multimeter:
// - voltage 3.3 V Pin to GND and write result in variable ref
//
// Matthias Busse 9.12.2020 version 1.1

float ref=3.25; // measured value

void setup(void) {
  Serial.begin(38400); // serial terminal output
}

void loop(void) {
float vcc;
int i, counts=10;

  vcc=0;
  for(i=0; i<counts; i++) {
    vcc += ref * 1023.0 / analogRead(A1); // A1 input AD converter
  }
  Serial.println(vcc/counts,3);
  delay(1000);
}

by Matthias Busse @Youtube

 

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.