Giter VIP home page Giter VIP logo

seeed-xiao-nrf52840-battery's Introduction

Seeed-Xiao-NRF52840-Battery

Arduino library to sense Seeed Xiao NRF52840 Battery voltage or charging state on non-Mbed 1.0.0 firmware

Examples:

#include <Arduino.h>
#include <bluefruit.h>
#include <xiaobattery.h>

Xiao battery;
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
// Serial.println(battery.IsChargingBattery());
Serial.println(battery.GetBatteryVoltage());
}

seeed-xiao-nrf52840-battery's People

Contributors

honvl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

astrolemonade

seeed-xiao-nrf52840-battery's Issues

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

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; }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.