Skip to main content

Creating an ESPHome Device

The ESPHome integration exposes the board's supply, battery, output, charging, and power-state controls to Home Assistant. The current integration is the powerfeather external component and uses PowerFeather-SDK V2.

This guide covers ESPHome PowerFeather 2.0.0-beta1.

Start a Device Config

Create a normal ESPHome config for an ESP32-S3 board, then add the PowerFeather external component:

substitutions:
name: powerfeather
friendly_name: PowerFeather

esphome:
name: ${name}
friendly_name: ${friendly_name}
platformio_options:
board_build.flash_mode: dio

esp32:
board: esp32-s3-devkitc-1
variant: esp32s3
framework:
type: esp-idf

logger:

api:
encryption:
key: !secret api_encryption_key

ota:
- platform: esphome
password: !secret ota_password

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "${name}"
password: !secret fallback_ap_password

captive_portal:

external_components:
- source: github://powerfeatherdev/esphome-powerfeather@2.0.0-beta1
components: [powerfeather]

The source repository is PowerFeather/esphome-powerfeather. external_components.source uses a Git ref, so it cannot express a version range such as V2.0.0+. Use the exact 2.0.0-beta1 tag for the beta release covered by this guide.

Start from an Example

The component repository includes example configs for each supported board and framework combination:

ExamplePurpose
powerfeather-v2-idf.yamlPowerFeather V2, ESP-IDF, 3.7 V lithium battery.
powerfeather-v2-arduino.yamlPowerFeather V2, Arduino framework, 3.7 V lithium battery.
powerfeather-v2-idf-lfp.yamlPowerFeather V2, ESP-IDF, LiFePO4 battery.
powerfeather-v2-arduino-lfp.yamlPowerFeather V2, Arduino framework, LiFePO4 battery.
powerfeather-v1-idf.yamlPowerFeather V1, ESP-IDF, 3.7 V lithium battery.
powerfeather-v1-arduino.yamlPowerFeather V1, Arduino framework, 3.7 V lithium battery.

The examples use these ESPHome secrets:

api_encryption_key: "..."
fallback_ap_password: "..."
ota_password: "..."
wifi_ssid: "..."
wifi_password: "..."

api_encryption_key must be a base64-encoded 32-byte key. Generate one with:

openssl rand -base64 32

The other secrets are normal passwords you choose.

Configure the Mainboard

Add one powerfeather.mainboard object. Each ESPHome config represents one physical PowerFeather board.

powerfeather:
mainboard:
id: powerfeather_mainboard
board_revision: v2
battery:
capacity: 1000
type: Generic_3V7
update_interval: 10s

Choose the settings that match your hardware:

OptionValuesNotes
board_revisionv1, v2Defaults to PowerFeather V1. Use the value v2 for PowerFeather V2 hardware.
battery.capacity0, or a board-specific mAh valueUse 0 when no battery is configured. V1 accepts 50 to 6000 mAh. V2 accepts 1 to 16383 mAh.
battery.typeGeneric_3V7, ICR18650_26H, UR18650ZY, Generic_LFPGeneric_LFP requires board_revision: v2.
update_interval500ms or longerDefaults to 10s. Applies to published measurements.

The component supports both esp-idf and arduino ESPHome frameworks.

Add Home Assistant Entities

Entities are configured under the same mainboard block. Add only the entities you want exposed.

powerfeather:
mainboard:
id: powerfeather_mainboard
board_revision: v2
battery:
capacity: 1000
type: Generic_3V7

sensors:
supply_voltage:
name: "${friendly_name} Supply Voltage"
supply_current:
name: "${friendly_name} Supply Current"
battery_voltage:
name: "${friendly_name} Battery Voltage"
battery_current:
name: "${friendly_name} Battery Current"
battery_charge:
name: "${friendly_name} Battery Charge"
battery_health:
name: "${friendly_name} Battery Health"
battery_cycles:
name: "${friendly_name} Battery Cycles"
battery_time_left:
name: "${friendly_name} Battery Time Left"
battery_temperature:
name: "${friendly_name} Battery Temperature"

binary_sensors:
supply_good:
name: "${friendly_name} Supply Good"

switches:
enable_EN:
name: "${friendly_name} Enable EN Pin"
enable_3V3:
name: "${friendly_name} Enable 3V3"
enable_VSQT:
name: "${friendly_name} Enable VSQT"
enable_battery_temp_sense:
name: "${friendly_name} Enable Battery Temperature Sense"
enable_battery_charging:
name: "${friendly_name} Enable Battery Charging"
enable_battery_fuel_gauge:
name: "${friendly_name} Enable Battery Fuel Gauge"
enable_stat:
name: "${friendly_name} Enable STAT LED"

numbers:
supply_maintain_voltage:
name: "${friendly_name} Supply Maintain Voltage"
battery_charging_max_current:
name: "${friendly_name} Battery Charging Max Current"

buttons:
update_battery_fuel_gauge_temp:
name: "${friendly_name} Update Fuel Gauge Temperature"

Keep ship_mode, shutdown, and powercycle buttons out of routine dashboards unless you want those actions available from Home Assistant:

powerfeather:
mainboard:
buttons:
ship_mode:
name: "${friendly_name} Ship Mode"
shutdown:
name: "${friendly_name} Shutdown"
powercycle:
name: "${friendly_name} Powercycle"

LiFePO4 Batteries

LiFePO4 support is available on ESP32-S3 PowerFeather V2 only:

powerfeather:
mainboard:
board_revision: v2
battery:
capacity: 1000
type: Generic_LFP

Migrating from the Old Syntax

ESPHome integration 2.0.0-beta1 changes the component name and moves all entities under powerfeather.mainboard.

Old syntaxNew syntax
components: [powerfeather_mainboard]components: [powerfeather]
powerfeather_mainboard:powerfeather: mainboard:
battery_capacity: 1000battery: capacity: 1000
battery_type: Generic_3V7battery: type: Generic_3V7
Separate sensor:, binary_sensor:, switch:, number:, and button: platform blocksNested sensors:, binary_sensors:, switches:, numbers:, and buttons: under mainboard
platform: powerfeather_mainboard and mainboard_idRemoved

For example, this old sensor block:

sensor:
- platform: "powerfeather_mainboard"
mainboard_id: "my_powerfeather"
battery_voltage:
name: "Battery Voltage"

becomes:

powerfeather:
mainboard:
sensors:
battery_voltage:
name: "Battery Voltage"

Entity Reference

Sensors

KeyUnitNotes
supply_voltageVInput supply voltage.
supply_currentmAInput supply current.
battery_voltageVBattery voltage.
battery_currentmABattery current.
battery_charge%Fuel gauge state of charge.
battery_health%Fuel gauge state of health.
battery_cyclescountFuel gauge cycle count.
battery_time_leftminFuel gauge time estimate.
battery_temperatureCBattery temperature; unknown when battery temperature sensing is disabled.

Binary Sensors

KeyNotes
supply_goodWhether the USB or VDC input supply is good.

Switches

KeyNotes
enable_ENControls the EN pin for connected Feather Wings.
enable_3V3Enables or disables the 3V3 output.
enable_VSQTEnables or disables the STEMMA QT VSQT output. Disabling this also cuts off access to the fuel gauge and charger IC.
enable_battery_temp_senseEnables or disables battery temperature sensing.
enable_battery_chargingEnables or disables battery charging.
enable_battery_fuel_gaugeEnables or disables the battery fuel gauge. Disabling this also disables fuel-gauge-backed sensors.
enable_statEnables or disables the charger STAT LED.

Numbers

KeyUnitRangeStepNotes
supply_maintain_voltageV4.6 to 16.80.012Charger input voltage regulation target.
battery_charging_max_currentmA40 to 20004Charger current limit.
battery_low_voltage_alarmV0 to 5.0 on V1, 0 to 5.1 on V20.01Battery low-voltage alarm threshold.
battery_high_voltage_alarmV0 to 5.0 on V1, 0 to 5.1 on V20.01Battery high-voltage alarm threshold.
battery_low_charge_alarm%0 to 1001Battery low-charge alarm threshold.

Battery alarm thresholds are write-only in the SDK. ESPHome will show them as unknown at boot until you set them from Home Assistant or a YAML automation.

Buttons

KeyNotes
update_battery_fuel_gauge_tempSends the current battery temperature to the fuel gauge.
ship_modeEnters ship mode, which exits by pulling QON low or plugging in a supply.
shutdownEnters shutdown mode, which exits by plugging in a supply.
powercycleRequests a board power cycle.

Development Helpers

The component repository's test/ directory contains the full internal fixture and Docker-based helper scripts:

For local board bring-up from the component repository:

cd test
export WIFI_SSID="..."
export WIFI_PASSWORD="..."
just v2-idf /dev/ttyACM0

Use just --list in test/ to see the V1, V2, ESP-IDF, Arduino, and LiFePO4 flash targets.