Skip to content

risk of burning out the P0.31 pin ( 32 , PIN_VBAT ) #1

Description

@AdamM68

There is a comment on Xiao wiki :
Q3: What are the considerations when using XIAO nRF52840 (Sense) for battery charging?​
When P0.14 (D14) turns off the ADC function at a high level of 3.3V, P0.31 will be at the input voltage limit of 3.6V. There is a risk of burning out the P0.31 pin.
Currently for this issue, we recommend that users do not turn off the ADC function of P0.14 (D14) or set P0.14 (D14) to high during battery charging.

According to this suggestions we should add a procedure to allow battery measurement only when NOT charging.
During charging, the function GetBatteryVolatge should return 0 or error.

something like

float Xiao::GetBatteryVoltage() {

if ( !digitalRead(BAT_CHARGE_STATE) == LOW ) {
digitalWrite(VBAT_ENABLE, LOW);
uint32_t adcCount = analogRead(PIN_VBAT);
float adcVoltage = adcCount * VBAT_MV_PER_LBS;
float vBat = adcVoltage * (1510.0 / 510.0);
digitalWrite(VBAT_ENABLE, HIGH);
return vBat;
}
else { return 0;}
}

bool Xiao::IsChargingBattery() { return digitalRead(BAT_CHARGE_STATE) == LOW; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions