{"id":18824652,"url":"https://github.com/lennarthennigs/espbattery","last_synced_at":"2025-07-24T06:05:03.724Z","repository":{"id":90173691,"uuid":"110727751","full_name":"LennartHennigs/ESPBattery","owner":"LennartHennigs","description":"Arduino Library to calculate the ESP8266 (Feather Huzzah) LiPo battery level.","archived":false,"fork":false,"pushed_at":"2020-03-28T17:40:25.000Z","size":13,"stargazers_count":26,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T01:36:50.001Z","etag":null,"topics":["arduino","arduino-library","c-plus-plus","embedded","esp8266","feather-huzzah","hardware","mbed"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LennartHennigs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-14T18:19:57.000Z","updated_at":"2025-02-02T08:21:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"43419fe9-c3ad-4f67-ab46-405d5bb06871","html_url":"https://github.com/LennartHennigs/ESPBattery","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/LennartHennigs/ESPBattery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LennartHennigs%2FESPBattery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LennartHennigs%2FESPBattery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LennartHennigs%2FESPBattery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LennartHennigs%2FESPBattery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LennartHennigs","download_url":"https://codeload.github.com/LennartHennigs/ESPBattery/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LennartHennigs%2FESPBattery/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266801406,"owners_count":23986371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-library","c-plus-plus","embedded","esp8266","feather-huzzah","hardware","mbed"],"created_at":"2024-11-08T00:57:04.803Z","updated_at":"2025-07-24T06:05:03.715Z","avatar_url":"https://github.com/LennartHennigs.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"ESPBattery\n==========\n\n* Author: Lennart Hennigs (https://www.lennarthennigs.de)\n* Copyright (C) 2017 Lennart Hennigs.\n* Released under the MIT license.\n\nArduino Library to calculate the ESP8266 (Feather Huzzah) LiPo battery level.\n\nDescription\n-----------\n\nIt uses the Huzzah's ADC pin and a voltage divider.\nThe circuit is documented here: \nhttps://github.com/lobeck/adafruit-feather-huzzah-8266-battery-monitor\n\nHow to Use\n----------\n\nThese are the constructor and the member functions the library provides:\n\n```\n    ESPBattery(\n\t\tbyte analog_pin = A0, \n\t\tint polling_interval_ms = 500, \n\t\tint min_lvl = ESPBATTERY_CRITICAL, \n\t\tint max_lvl = ESPBATTERY_FULL\n\t\t);\n\n\tfloat getVoltage();\n    int getPercentage();\n    int getLevel();\n    int getState();\n    int getPreviousState();\n    String stateToString(int state);\n    \n    void setLevelChangedHandler(CallbackFunction f);\n    void setLevelLowHandler(CallbackFunction f);\n    void setLevelCriticalHandler(CallbackFunction f);    \n    void setLevelChargingHandler(CallbackFunction f);    \n\n    void loop();\n```\n\nThe library provides several callback handlers to be notified when the battery levels changes.\n\n**Note:** For the class to work, you need to call the `loop()` member function in your sketch's `loop()` function. See the example for more details.\n\n\nInstallation\n------------\nOpen the Arduino IDE choose \"Sketch \u003e Include Library\" and search for \"ESP Battery\". \nOr download the ZIP archive (https://github.com/lennarthennigs/ESPBattery/zipball/master), and choose \"Sketch \u003e Include Library \u003e Add .ZIP Library...\" and select the downloaded file.\n\n\nLicense\n-------\n\nMIT License\n\nCopyright (c) 2017 Lennart Hennigs\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flennarthennigs%2Fespbattery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flennarthennigs%2Fespbattery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flennarthennigs%2Fespbattery/lists"}