explaingit

carlborg/tuya-pet-feeder-reverse-engineering

18Audience · developerComplexity · 4/5Setup · hard

TLDR

How one person removed cloud dependency from a Tuya pet feeder by replacing its WiFi module with an ESP8266 and documenting the serial wire protocol for local Home Assistant control.

Mindmap

mindmap
  root((tuya-pet-feeder))
    What it does
      Remove cloud dependency
      Local Home Assistant control
      Protocol documentation
    Hardware
      ESP8266 module
      Motor chip
      Serial connection
    Protocol details
      8-byte frames
      Command codes
      Checksum format
    Lessons learned
      Button handling
      Power wiring
      Wrong frame traps
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace the cloud WiFi module in a Tuya pet feeder with an ESP8266 to control it locally without internet.

USE CASE 2

Implement custom firmware that speaks the feeder serial protocol and routes commands through Home Assistant.

USE CASE 3

Use the documented wire protocol as a reference when reverse-engineering other Tuya devices with similar two-chip designs.

Tech stack

ESP8266Home AssistantUART Serial

Getting it running

Difficulty · hard Time to first run · 1day+

Requires soldering and hardware modification to replace the WiFi module inside the physical pet feeder.

In plain English

This repository documents one person's process of removing the cloud dependency from a Tuya-branded pet feeder and making it work entirely through Home Assistant, a local home automation platform. The project involved replacing the original WiFi module inside the feeder with an ESP8266 (a small programmable microcontroller), then writing custom firmware so the feeder could be controlled directly from a home network rather than through Tuya's servers. The feeder turns out to be a two-chip design. A dedicated chip on the main board controls the motor, sensors, and buttons. A separate WiFi module sits alongside it and communicates with the cloud. The key insight is that you do not need to touch the chip running the motor: you only need to swap the WiFi module for an ESP8266 that speaks the same communication language to the motor chip, but routes commands through Home Assistant instead of the internet. Most of the document is a protocol reference covering exactly what bytes get sent over the serial connection between the WiFi module slot and the motor chip. The protocol is not the standard Tuya format, which is a common trap that wastes troubleshooting time. Frames are eight bytes long, use a different header, and compute the checksum differently. The document maps out the command codes for actions like triggering a feeding, reading the battery level, and detecting whether the food magazine is empty. Several sections cover specific problems encountered during the reverse-engineering process, such as what happens if you reply to the wrong frame type (the motor feeds continuously), how the physical button on the feeder works (the WiFi module must respond to a button press message or the button stops working), and how to power the ESP8266 from the feeder's own board without damaging anything. The README does not include finished firmware code ready to flash, because the exact setup is hardware-specific. Instead it provides the wire protocol details and lessons learned that someone could use to build their own implementation for a similar device.

Copy-paste prompts

Prompt 1
I am replacing the WiFi module in a Tuya pet feeder with an ESP8266. The serial frames are 8 bytes with a non-standard header and checksum. Help me write Arduino ESP8266 code to send a feeding command using this byte structure: header, cmd, data, checksum.
Prompt 2
I am building ESP8266 firmware for a Tuya pet feeder. The motor chip sends button-press messages over serial that I must acknowledge or the physical button stops working. Show me a loop that reads serial frames and replies to button events.
Prompt 3
I want to create a Home Assistant ESPHome config for a Tuya pet feeder I have reverse-engineered. It needs to send a dispense food command over UART and report battery level. How should I structure the UART component?
Open on GitHub → Explain another repo

← carlborg on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.