Skip to main content

Inkplate 5v2 MicroPython - Battery and temperature

Inkplate 5v2 has built-in functions for measuring battery voltage and board temperature. This example reads both values and shows them on screen.

⚠️
You need a Li-ion battery for this example to work. For more details, see the battery docs page.

Connect the battery like this:

Inkplate 5v2 running the example code
Battery connected to Inkplate 5v2.

Reading battery voltage and temperature

from inkplate5v2 import Inkplate

inkplate = Inkplate(Inkplate.INKPLATE_1BIT)
inkplate.begin()
inkplate.clear_display()
inkplate.display()

# Get battery voltage as a string
battery = str(inkplate.read_battery())
inkplate.set_text_size(2)
inkplate.print_text(350, 350, "Battery voltage: " + battery + "V")
inkplate.partial_update()

# Get temperature reading as a string
temperature = str(inkplate.read_temperature())
inkplate.print_text(350, 400, "Temperature: " + temperature + "C")
inkplate.partial_update()

inkplate.read_battery()

Measure the current battery voltage of the Inkplate board.

Returns type: float

Returns value: Battery voltage in volts.

inkplate.read_temperature()

Measure the temperature of the Inkplate board's internal sensor.

Returns type: float

Returns value: Temperature in degrees Celsius.

Inkplate 5v2 running the example code
Displaying battery and temperature data on Inkplate display.

Full example

battery_and_temperature.py

Read the battery voltage and temperature and display them on the screen.