ESP32 Projects
Start a build
Markdown

Petkit Local for ESP32-C3

An ESP32 display project for ESP32-C3.

ESP32-C3ESPHomeUnrated
Parts and source

Before you start

Confirm board compatibility and supported firmware targets in the upstream documentation.

Upstream README

🐱 PetKit ESPHome β€” Fresh Element Solo + Eversweet 3 Pro

Free your PetKit devices from the cloud! Custom ESPHome firmware for the PetKit Fresh Element Solo pet feeder that also acts as a BLE bridge to the PetKit Eversweet 3 Pro water fountain β€” both devices fully local in Home Assistant, no PetKit servers, no app, no cloud. 🚫☁️

The feeder's own ESP32 is reflashed with ESPHome, and it talks to the fountain over Bluetooth Low Energy using the reverse-engineered PetKit W5 protocol.

eatery


🎯 Choose Your Build Path

This project offers two options depending on which devices you have:

Best for: Owners of both devices β€” one ESP32 controls everything

Aspect Details
Difficulty ⭐⭐ Moderate (opening the feeder + soldering-free serial flash)
Hardware None to buy β€” uses the feeder's built-in ESP32-D0WD
Config File petkit-fresh-element-solo.yaml
Result Feeder + fountain as one ESPHome device in HA and one web UI

The fountain itself is not modified at all β€” the feeder connects to it over BLE in the background and relays everything.

πŸ”΅ Option 2: Fountain Only (standalone ESP32-C3)

Best for: Fountain-only owners, or if the feeder is out of BLE range of the fountain

Aspect Details
Difficulty ⭐ Easy (flash a dev board, nothing is opened)
Hardware Any ESP32-C3 dev board (~€3-5), e.g. ESP32-C3-DevKitM-1 / SuperMini
Config File petkit-eversweet-3-pro.yaml
Result Fountain monitoring + control via a small BLE-to-WiFi bridge

πŸ’‘ Recommendation: If you own both devices, go with Option 1 β€” zero extra hardware and everything lives in a single device. Just make sure the feeder stands within BLE range of the fountain.


✨ Features

Feeder (Fresh Element Solo)
  • 🍽️ Manual dispensing β€” button in HA / web UI, physical button still works
  • πŸ“… Flexible feeding schedule in one text field: 07:00=2, 12:30=1, 18:00=2 (any minute, not just full hours) with an Apply/validate button and live "next feeding" status
  • πŸ“‰ Low food detection β€” compares pellets-per-scoop against a threshold, warns via sound + HA event
  • πŸ§‚ Desiccant tracking β€” 30-day replacement counter, warning sensor, HA event, one-tap reset
  • πŸ• Robust timekeeping β€” NTP (Google + pool fallbacks) and Home Assistant as a secondary time source, runtime-selectable timezone, manual sync button, live clock display
  • 🍴 Last feeding sensor β€” shows the most recent feeding as 2 serving(s) at 19:00; its state is unique per feeding, making it a reliable Home Assistant trigger (no ESPHome event permission needed)
  • πŸ”Š RTTTL melodies (mutable), status LED, dispensed-food statistics
Fountain (Eversweet 3 Pro, via BLE)
  • ⚑ Power on / pause and Normal / Smart mode
  • 🚨 Warnings: water missing, filter due, breakdown
  • 🧽 Filter reset button β€” sends the native BLE reset command (cmd 222), filter counter resets inside the fountain itself
  • πŸ“Š Filter usage %, pump runtime, voltage, serial, firmware version
  • πŸ”„ Auto-reconnect + periodic polling (default 120 s)
Web UI

ESPHome web server v3 with sorting groups β€” entities organized into Feeding / Fountain / Settings / Diagnostics sections.


πŸ“¦ Repository Contents

File Description
petkit-fresh-element-solo.yaml Option 1: feeder + fountain bridge (feeder's ESP32)
petkit-eversweet-3-pro.yaml Option 2: fountain-only standalone reader (ESP32-C3)
secrets.yaml.example Template for your WiFi / API / OTA secrets
backup/esp32_stock_backup_SANITIZED.bin Stock PetKit firmware dump (personal data removed) β€” last-resort restore
ha/automations.yaml Ready-made HA notification automations (copy & adapt)
img/ Photos / screenshots

πŸ”§ Option 1: Flashing the Feeder

What's inside

flashing_process

The Fresh Element Solo is built around an ESP32-D0WD (dual core, 4 MB flash) β€” perfect for ESPHome. Pinout and hardware photos are documented on the ESPHome devices page: πŸ‘‰ https://devices.esphome.io/devices/petkit-fresh-element-solo-pet-feeder/

GPIO Function
GPIO5 Status LED
GPIO16 Buzzer (RTTTL)
GPIO34 Manual feed button
GPIO27 Motor rotation sensor
GPIO14 Food (pellet) sensor
GPIO33 Sensor enable
GPIO18/17/19 Motor forward / reverse / enable
Step 0 β€” ⚠️ BACK UP THE STOCK FIRMWARE FIRST

Before flashing anything, dump the original 4 MB flash so you can always go back:

esptool --chip esp32 --port COM6 --baud 460800 read-flash 0 0x400000 esp32_backup.bin

esptool backup in progress

Connect a USB-serial adapter (3.3 V logic!) to the feeder board's serial pads: GND, TX, RX β€” and hold GPIO0 low on power-up to enter the bootloader.

⚑ Power tip: do not power the ESP32 from the USB-serial adapter's 3V3 pin β€” it cannot supply the WiFi+BLE current spikes and the board will brownout-loop. Power the board from the feeder's own PSU and connect only GND/TX/RX to the adapter. In my case, powering the ESP32 from the adapter's 3V3 pin was sufficient only for flashing the firmware. To test or run the firmware afterward, I powered the board from its regular power supply.

⚑ **Important: Do not power the board from both the feeder's power supply and the USB-to-serial adapter's 3V3 output at the same time. Powering the board from two different sources simultaneously can damage the ESP32 or the USB-to-serial adapter.

Step 1 β€” Prepare secrets

Copy secrets.yaml.example to secrets.yaml in your ESPHome config folder and fill in your values.

Step 2 β€” Set your fountain's MAC

In petkit-fresh-element-solo.yaml, set fountain_mac (substitutions at the top) to your fountain's BLE MAC. Find it with any BLE scanner app (nRF Connect) β€” the fountain advertises as a PetKit device.

Step 3 β€” Flash
esphome run petkit-fresh-element-solo.yaml

First flash goes over serial; every update after that is OTA. πŸŽ‰

Step 4 β€” Verify
  • Feeder time shows the current time within seconds (NTP sync)
  • Fountain Online turns on after ~10-15 s (BLE handshake: cmd 213 β†’ 73 β†’ 86)
  • Press Dispense food β€” scoops turn, statistics update

πŸ”§ Option 2: Standalone Fountain Reader

  1. Get any ESP32-C3 dev board
  2. Set fountain_mac in petkit-eversweet-3-pro.yaml
  3. esphome run petkit-eversweet-3-pro.yaml
  4. Place the board within BLE range of the fountain

πŸ“‘ PetKit BLE Protocol (short version)

Frame format used by W5-series fountains:

FA FC FD | cmd | type | seq | len | 00 | data... | FB
Cmd Purpose
213 Get device details (device ID, serial)
73 Init device (register secret)
86 Sync
200 Firmware version
210 Device state (power, mode, warnings, filter %, runtime)
66 Battery / voltage
220 Set power + mode
222 Reset filter counter

⚠️ Important quirks:

  • The init command (73) re-registers the BLE secret β†’ the PetKit phone app loses control of the fountain until you power-cycle the fountain.
  • Only one BLE central can be connected to the fountain at a time.

πŸ’Ύ Stock Firmware Backup & Restore

backup/esp32_stock_backup_SANITIZED.bin is a full 4 MB dump of the original PetKit feeder firmware (hardware revision with ESP32-D0WD, serial prefix 2024). Personal data has been erased from it: the NVS, WiFi credentials, device serial, device ID/secrets, account binding, schedule and server-info partitions are blanked (0xFF).

To restore a feeder to stock:

esptool --chip esp32 --port COM6 --baud 460800 write-flash 0 esp32_stock_backup_SANITIZED.bin

After restoring, set the feeder up again through the PetKit app (it will re-provision WiFi and re-register the device).

⚠️ Disclaimer: this image is provided as a last resort for the community. Always make your own backup before flashing β€” your dump contains your device's factory identity partitions, which this sanitized image does not. Restoring this image to a different hardware revision may not work. Use at your own risk.

πŸ”’ If you publish your own dump: sanitize it first. A raw dump contains your WiFi password in plaintext, your device serial, and your PetKit account binding.


🏠 Home Assistant

The device appears automatically via the ESPHome integration. Useful events for automations:

Event Fired when
esphome.feeder_food_dispensed Food was dispensed (with scoop count)
esphome.feeder_food_low Hopper is running low
esphome.feeder_desiccant_due Desiccant is 30+ days old
πŸ“¬ Ready-made notification automations

The repo ships with ha/automations.yaml β€” five Home Assitant automations. Copy the blocks into your automations.yaml (or paste into the UI editor in YAML mode), then adjust the entity IDs (HA may prefix them with your area name β€” check Developer Tools β†’ States) and the notify targets.

  1. πŸ’§ Water low β€” fountain out of water (debounced, only when the BLE link is alive)
  2. 🚰 Filter due β€” early warning at 95% used + the fountain's own alarm, with the live percentage in the message
  3. πŸ§‚ Desiccant due β€” 30-day reminder with reset instructions
  4. 🍽️ Food low β€” hopper running low, includes the actual pellet count
  5. 😻 Food dispensed β€” confirmation of every feeding, with humor scaled to portion size (triggered by the Last feeding sensor, whose timestamped state changes on every dispense)

πŸ™ Credits

This project stands on the shoulders of great community work:


πŸ“„ License

Released into the public domain under The Unlicense β€” no ownership, no restrictions. Do whatever makes your cats happy. 🐾

This project builds on the community work listed in the Credits section above; those projects keep their own respective licenses.

⚠️ Disclaimer

Flashing custom firmware voids your warranty and carries a small risk of bricking the device. Feeding hardware keeps animals alive β€” always verify scheduled feedings work after every firmware change, and keep the physical manual-feed path tested. This project is not affiliated with PetKit.