1. Home
  2. Docs
  3. MANUALS AND DATASHEETS
  4. Polaris Manual
  5. Main Connector
  6. Detecting Supply Voltage

Detecting Supply Voltage

The power supply voltage on the Main connector is detected with a circuit similar to one of the analog inputs with high range settings, after the reverse polarity protection diode:

Here is an example Arduino sketch that reads the main supply voltage. The diode voltage drop is estimated to be 0.25 Volts, which is fine for low current in the idle state, but may vary with higher current consumption:

void setup() {
  // Open and wait serial terminal
  Serial.begin(115200);
  while (!Serial);
  // Set ADC resolution
  analogReadResolution(12);
}

void loop() {
  // Read analog channel and convert to external voltage
  float vin = analogRead(AIN_S_INLEVEL) * ANALOG_SCALE * ANALOG_VREF / 4095.0f + 0.25f;
  Serial.print("VEXT (V): ");
  Serial.println(vin);
  delay(1000);
}

The same example with Zerynth:

from fortebit.polaris import polaris

polaris.init()

while True:
    print("VEXT (V):", polaris.readMainVoltage())
    sleep(1000)

How can we help?