Can Xiao measure its own battery voltage?

I’m trying to measure the voltage of power source (two AA batteries) and if low warn the use by turning on a LED. Searching the Arduino forum, I found a good software solution at ( which does not apply to XIAO. Here is the sample code from the Arduino forum:

long readVcc() {

long result;
// Read 1.1V reference against AVcc
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; // Back-calculate AVcc in mV
return result;

It returns the current battery level in mV (milliVolts). Appreciate the help.