Skip to main content

Read battery voltage

When running your Inkplate 10 board on a Li-ion battery, it's helpful to know the battery's condition. Inkplate 10 lets you measure the battery voltage directly, which gives you an estimate of the remaining capacity and tells you when it's time to recharge.

⚠️
Connecting and using the battery correctly is important! Please refer to the battery usage page for guidance before use.

Reading voltage example

#include "Inkplate.h" // Include Inkplate library to the sketch
#include "battSymbol.h" // Include .h file that contains byte array for battery symbol.
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)

void setup()
{
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.setTextSize(2); // Scale text to be two times bigger then original (5x7 px)
display.setTextColor(BLACK, WHITE); // Set text color to black and background color to white
}

void loop()
{
float voltage = display.readBattery(); // Read battery voltage
display.clearDisplay(); // Clear everything in frame buffer of e-paper display
display.image.draw(battSymbol, 100, 100, 106, 45, BLACK); // Draw battery symbol at position X=100 Y=100
display.setCursor(210, 120);
display.print(voltage, 2); // Print battery voltage
display.print('V');
display.display(); // Send everything to display (refresh the screen)
delay(10000); // Wait 10 seconds before new measurement
}
ℹ️
This example uses a battery symbol bitmap (battSymbol.h) alongside the main .ino file. Get both files from the example folder on GitHub and keep them in the same sketch folder.

display.readBattery()

Reads the current battery voltage when running on battery power

Returns type: float

Returns value: Returns the measured battery voltage

Inkplate10_Read_Battery_Voltage

GitHub link with all files