This example is not designed to run on the FunHouse. It is an example of a device you could connect to Adafruit IO and then display the connected feed on your FunHouse IoT hub.

This example uses a Feather RP2040 (although any Feather board with stemma works) and an LC709203 to track the charging of a LiPo battery with Adafruit IO.

For this project, you will need:

Angled shot of black rectangular microcontroller "Feather RP2040"
A new chip means a new Feather, and the Raspberry Pi RP2040 is no exception. When we saw this chip we thought "this chip is going to be awesome when we give it the Feather...
In Stock
Angled shot of Adafruit AirLift FeatherWing.
Give your Feather project a lift with the Adafruit AirLift FeatherWing - a FeatherWing that lets you use the powerful ESP32 as a WiFi co-processor. You probably have your...
In Stock
Angled shot of a Adafruit FeatherWing OLED - 128x32 OLED Add-on For Feather connected to a white breadboard and a lithium battery.
A Feather board without ambition is a Feather board without FeatherWings! This is the FeatherWing OLED: it adds a 128x32 monochrome OLED plus 3 user buttons to...
In Stock
Top view of Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor powered by a Lipoly battery and an OLED display.
Low cost Lithium Polymer batteries have revolutionized electronics - they're thin, they're light, they can be regulated down to 3.3V and they're easy to charge. On your...
In Stock
Angled shot of a Stacking Headers for Feather - 12-pin and 16-pin female headers.
These two Female Stacking Headers alone are, well, lonely. But pair them with any of our Feather boards and...
In Stock
Double prototyping feather wing PCB with socket headers installed
This is the FeatherWing Doubler - a prototyping add-on and more for all Feather boards. This is similar to our
In Stock
Angled of of JST SH 4-Pin Cable.
This 4-wire cable is 50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but...
In Stock
Lithium Ion Polymer Battery 3.7v 2000mAh with JST 2-PH connector
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This...
Out of Stock

If the cable or battery is out of stock, you can buy any other size, although for the STEMMA QT cable, shorter is better.

Feather Setup

First, click Download Project Bundle below. This zip file will contain everything you need for this example. However, the files are also in the zip file you downloaded for the FunHouse, so you can get them from either one, just make sure you take the files from the battery_peripheral directory.

# SPDX-FileCopyrightText: 2021 Eva Herrada for Adafruit Industries
# SPDX-License-Identifier: MIT

Adafruit IO connected LiPo charger.
    * Feather board (M4 or RP2040 reccomended)
Either the Feather or the Airlift Featherwing should have stacking headers for the display.

import time
import board
from adafruit_lc709203f import LC709203F
import busio
from digitalio import DigitalInOut
import adafruit_connection_manager
from adafruit_esp32spi import adafruit_esp32spi
from adafruit_esp32spi import adafruit_esp32spi_wifimanager
import neopixel
import adafruit_minimqtt.adafruit_minimqtt as MQTT
from adafruit_io.adafruit_io import IO_MQTT

import displayio
import terminalio
from adafruit_display_text import label
import adafruit_displayio_ssd1306


### WiFi ###

# Get wifi details and more from a file
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in, please add them there!")

# If you are using a board with pre-defined ESP32 Pins:
esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
"""Use below for Most Boards"""
status_light = neopixel.NeoPixel(
    board.NEOPIXEL, 1, brightness=0.2
)  # Uncomment for Most Boards
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)

# Define callback functions which will be called when certain events happen.
# pylint: disable=unused-argument
def connected(client):

def subscribe(client, userdata, topic, granted_qos):
    # This method is called when the client subscribes to a new feed.
    print("Subscribed to {0} with QOS level {1}".format(topic, granted_qos))

def message(client, feed_id, payload):
    print("Feed {0} received new value: {1}".format(feed_id, payload))

# Connect to WiFi
print("Connecting to WiFi...")

pool = adafruit_connection_manager.get_radio_socketpool(esp)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(esp)

# Initialize a new MQTT Client object
mqtt_client = MQTT.MQTT(

# Initialize an Adafruit IO MQTT Client
io = IO_MQTT(mqtt_client)

# Connect the callback methods defined above to Adafruit IO
io.on_connect = connected
io.on_subscribe = subscribe
io.on_message = message

# Connect to Adafruit IO
print("Connecting to Adafruit IO...")

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
display_bus = displayio.I2CDisplay(i2c, device_address=0x3C)

WIDTH = 128

display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=WIDTH, height=HEIGHT)

splash = displayio.Group()
display.root_group = splash

digital_label = label.Label(
    terminalio.FONT, text="Battery Percent: ", color=0xFFFFFF, x=4, y=4
alarm_label = label.Label(terminalio.FONT, text="Voltage: ", color=0xFFFFFF, x=4, y=14)

i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
sensor = LC709203F(i2c)

start = 0
while True:
    percent = sensor.cell_percent
    if time.time() - start > 60:
        io.publish("battery", int(percent))
        start = time.time()
    splash[0].text = f"Percent: {str(int(percent))}%"
    splash[1].text = f"Voltage: {str(sensor.cell_voltage)}"

The first thing you'll need to do is copy all the required libraries over. The libraries needed are:

  • adafruit_esp32spi/
  • adafruit_minimqtt/
  • adafruit_io/
  • adafruit_display_text/
  • adafruit_lc709203f.mpy
  • adafruit_requests.mpy
  • neopixel.mpy
  • adafruit_displayio_ssd1306.mpy

After you've copied over those libraries, copy over to the CIRCUITPY drive.

Finally, copy to the CIRCUITPY drive.

After you've done all that, this is what your CIRCUITPY drive should look like:


Solder the stacking headers to either the RP2040 or the AirLift Featherwing, solder the normal headers to whichever one you didn't solder the stacking headers to and the OLED. Then, solder the headers that came with the FeatherWing Doubler to it (it's a bit easier to do if you put 2 Feather boards in to hold them in place before you get 2 pins on each header soldered).

Then, put the Feather RP2040 and AirLift FeatherWing on the doubler and put the OLED on top of the Feather.

Hook up the LiPo charger to the STEMMA QT connector on the Feather using either of the STEMMA QT connectors on the charger. Then, use the JST 2-PH cable that came with it to connect the charger to the Feather. You can use either jack on the charger.

Now that you've set everything up, plug a battery in and press the RESET button and it should look something like this:

Having issues removing the battery cables? Try putting a pair of tweezers through the hole on the top of the jack and use them to push the connector part out.

This guide was first published on May 26, 2021. It was last updated on Jun 16, 2024.

This page (Battery Charger Example) was last updated on Jun 15, 2024.

Text editor powered by tinymce.