Git Product home page Git Product logo

xiao_sense_nrf52840_battery_lib's Introduction

XIAO BLE Sense (nRF52840) Battery Management Library


GitHub Repo stars Hits

Overview

This library is designed to manage the battery charging functionality of the XIAO BLE and XIAO BLE Sense board. It supports the following features for a 3.7V LiPo battery:

  • Reading battery voltage.
  • Setting charging modes (fast or slow).
  • Enabling or disabling charging.
  • Calculating battery capacity in percentage.

The library is built on the Zephyr Real-Time Operating System (RTOS). For comprehensive details on Zephyr and how to get started, visit the Zephyr Getting Started Guide.

Programming and Debugging

Adafruit nRF52 Bootloader

The XIAO BLE Sense is equipped with the Adafruit nRF52 Bootloader 5, facilitating the UF2 flashing process.

UF2 Flashing Process

  1. Entering Bootloader Mode: Connect the XIAO BLE Sense to your computer via USB. Then, double-tap the reset button located to the left of the USB connector. This action will enable the bootloader mode, and the device will appear as a mass storage device named 'XIAO BLE' on your computer.

  2. Flashing the Firmware:

    • Navigate to the 'build/zephyr/' directory and locate the 'zephyr.uf2' file. If you can not find the build folder, build or rebuild the zephyr project.
    • Copy the zephyr.uf2 file to the root directory of the XIAO BLE mass storage device using either the command line or your file manager.
  3. Automatic Reset and Application Launch: After the UF2 file transfer is complete, the XIAO BLE Sense will automatically reset and launch the new application.

For additional information on the flashing process and the XIAO BLE Sense board, refer to the Zephyr Board Documentation for XIAO BLE.

xiao_sense_nrf52840_battery_lib's People

Contributors

tjoms99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

xiao_sense_nrf52840_battery_lib's Issues

Random Voltage readings - what am idoing wrong?

Hi @Tjoms99
Thanks for the lib.

I am very new on Zephyr and was struggling wit a lot of code samples - I was unable to get most of the examples running.
Not with you code :-) Cool.

But the output of the logging shows pretty random values.
Any hint?

Cheers
Felix

17:18:59.440 -> [00:08:39.338,806] �[0m main: Battery at 3756 mV (capacity 44%) �[0m
17:18:59.440 -> [00:08:41.338,958] �[0m main: Battery at 4149 mV (capacity 97%) �[0m
17:18:59.440 -> [00:08:43.339,111] �[0m main: Battery at 3753 mV (capacity 44%) �[0m
17:19:01.476 -> [00:08:45.339,263] �[0m main: Battery at 4140 mV (capacity 96%) �[0m
17:19:03.470 -> [00:08:47.339,416] �[0m main: Battery at 3759 mV (capacity 44%) �[0m
17:19:05.461 -> [00:08:49.339,569] �[0m main: Battery at 4113 mV (capacity 93%) �[0m
17:19:07.450 -> [00:08:51.339,721] �[0m main: Battery at 3999 mV (capacity 74%) �[0m
17:19:09.445 -> [00:08:53.339,874] �[0m main: Battery at 3762 mV (capacity 45%) �[0m
17:19:11.477 -> [00:08:55.340,026] �[0m main: Battery at 4146 mV (capacity 97%) �[0m
17:19:13.467 -> [00:08:57.340,179] �[0m main: Battery at 3756 mV (capacity 44%) �[0m
17:19:15.449 -> [00:08:59.340,332] �[0m main: Battery at 4146 mV (capacity 97%) �[0m
17:19:17.440 -> [00:09:01.340,484] �[0m main: Battery at 3756 mV (capacity 44%) �[0m
17:19:19.440 -> [00:09:03.340,637] �[0m main: Battery at 4152 mV (capacity 98%) �[0m
17:19:21.435 -> [00:09:05.340,759] �[0m main: Battery at 3762 mV (capacity 45%) �[0m
17:19:23.474 -> [00:09:07.340,881] �[0m main: Battery at 4149 mV (capacity 97%) �[0m
17:19:25.463 -> [00:09:09.341,003] �[0m main: Battery at 3798 mV (capacity 49%) �[0m
17:19:27.444 -> [00:09:11.341,125] �[0m main: Battery at 3951 mV (capacity 69%) �[0m
17:19:29.473 -> [00:09:13.341,247] �[0m main: Battery at 4146 mV (capacity 97%) �[0m
17:19:31.455 -> [00:09:15.341,369] �[0m main: Battery at 3759 mV (capacity 44%) �[0m
17:19:33.447 -> [00:09:17.341,491] �[0m main: Battery at 4149 mV (capacity 97%) �[0m
17:19:35.435 -> [00:09:19.341,613] �[0m main: Battery at 3756 mV (capacity 44%) �[0m
17:19:37.475 -> [00:09:21.341,735] �[0m main: Battery at 4143 mV (capacity 97%) �[0m
17:19:39.466 -> [00:09:23.341,857] �[0m main: Battery at 3759 mV (capacity 44%) �[0m
17:19:41.459 -> [00:09:25.341,979] �[0m main: Battery at 4149 mV (capacity 97%) �[0m
17:19:43.452 -> [00:09:27.342,102] �[0m main: Battery at 3759 mV (capacity 44%) �[0m
17:19:45.445 -> [00:09:29.342,224] �[0m main: Battery at 4068 mV (capacity 86%) �[0m

License request

Hi @Tjoms99, this looks like great work.

Can I request that you put a license with this repository, so I know how I can use your code you've published?

Killed my XIAO

Hello, I don't know if this is an issue with your Lib but I added it to my project and connected a 3.7 Lipo. It first worked fine but after connecting and disconnecting an usb c cable to charge, my chip is now dead... could not determine what happened.

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.