Ligth Library for Arduino Environment to Battery management.
This library need EMA.h library (https://github.com/RafaelReyesCarmona/EMA) and ADC.h library (https://github.com/RafaelReyesCarmona/EMA).
For a tutorial on how to install new libraries for use with the Arduino development environment please refer to the following website: http://www.arduino.cc/en/Reference/Libraries
--- or ---
- Download the ZIP file from the page releases to your machine.
- In the Arduino IDE, choose Sketch/Include Library/Add Zip Library.
- Navigate to the ZIP file, and click Open.
How to use the library in PlatformIO see documentation of Library Manager.
The only one simple step is to define dependencies in “platformio.ini” (Project Configuration File). For example,
[env:pro16MHzatmega328]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino
lib_deps = rafaelreyescarmona/TinyBattery
[env:LGT8F328]
board = LGT8F328P
board_build.f_cpu = 32000000
platform = lgt8f
framework = arduino
lib_deps = rafaelreyescarmona/TinyBattery@^0.1
For Manual installation in PlatformIO Core:
- Run a terminal and type for search the library:
pio lib search TinyBattery
- Type for install:
pio lib install ______
--- or ---
- Search "TinyBattery" in search box of Libraries of panel.
- Click Add to project button. Library will be included in the project and "platformio.ini" updated.
In Arduino IDE, Choose Sketch/Include Library/Scroll and select "TinyBattery".
There are a two examples files with the library. In the Arduino IDE, choose File/Examples/TinyBattery, and you can see "TinyBattery".
--- or ---
Example of use:
#include <Arduino.h>
#include <TinyBattery.h>
TinyBattery Battery(/* PIN */ A0,
/* VccREF */ 5.035,
/* RESISTOR_VDD */ 21000,
/* RESISTOR_GND */ 47000,
/* MIN_VOLT */ 16.00,
/* MAX_VOLT */ 25.90);
void setup() {
// put your setup code here, to run once:
Serial.begin(56700);
}
void loop() {
// put your main code here, to run repeatedly:
float Bat = Battery.GetVoltage();
byte Bat_Level = Battery.GetChargeLevel();
Serial.print("Battery: ");
Serial.print(Bat);
Serial.print(" V. Battery Level: ");
Serial.print(Bat_Level);
Serial.println(" %.");
delay(250);
}
This file is part of TinyBattery Library.
TinyBattery Library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
TinyBattery Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with TinyBattery Library. If not, see https://www.gnu.org/licenses/.
Copyright © 2021 Francisco Rafael Reyes Carmona. Contact me: rafael.reyes.carmona@gmail.com
Battery icon at the beginning is from Flaticon.es designed by FreePik and licensed by free license.