Norsk versjon: README.no.md.
This project replaces the control board in an automatic cat or dog feeder with an ESP32-C3 Super Mini running ESPHome. The feeder gets its own mobile web page on your home network, a daily quota in grams, up to eight feedings a day, and its clock from the internet. It needs no cloud, no app and no Home Assistant.
The conversion was done and tested on one iiglo feeder. It should fit other feeders that have the two parts everything relies on:
- a DC motor (5 V) that turns the dosing wheel, and
- a cam switch that toggles and returns once per revolution, which is once per portion.
Nothing else in the feeder is used, including the old control board. The exception is
the power board, which still supplies 5 V to both the motor and the new board. If your
feeder has a different motor voltage or counts portions in another way, you will have
to adapt the wiring and petfeed.yaml yourself.
Language note: the mobile page, the entity names and the code comments are in Norwegian. This README quotes the Norwegian labels and gives the English meaning next to them.
- Daily quota in grams. You enter how many grams the animal should have per day and how much one portion weighs. Feedings with a fixed amount are subtracted first, and the rest is split evenly across the day's automatic feedings.
- Up to eight feeding times, set from your phone. Each time is either automatic (shares the quota with the others) or has a fixed number of portions.
- «Gi mat nå» (Feed now) counts against the daily quota and gives nothing once the quota is used up. You can then give extra instead, outside the quota.
- Clock from the internet with Norwegian time and daylight saving. Times, quota and calibration are stored on the board and survive a power cut.
- Updates over wifi, so the case can be closed for good.
- Three guards against the motor staying on: the cam switch counts the portions, each portion has a time limit, and a separate timer outside the main program turns the motor off if everything else hangs.
| Part | Note |
|---|---|
| ESP32-C3 Super Mini | Other ESP32 boards are untested. You would at least have to change the pins and board in petfeed.yaml |
| TIP120 (NPN Darlington) | Motor driver. If you replace it, the substitute must handle the motor's start-up current and switch fully on with a 3.3 V control signal. Only the TIP120 is tested |
| Resistor, 1–2.2 kΩ | Between GPIO4 and the base of the TIP120. This build uses 2.18 kΩ |
| Resistor, 10 kΩ (recommended) | From GPIO4 to GND. Keeps the motor off while the board boots |
| Diode, e.g. 1N4007 or 1N5819 (recommended) | Across the motor, stripe towards +5 V. Absorbs the voltage spike when the motor switches off |
| Wire, soldering iron, heat shrink |
This build runs without the diode and without the 10 kΩ resistor, and has worked that way. Both are still normal good practice and cost next to nothing, so include them.
| From | To | Note |
|---|---|---|
| Power board GND | C3 "G" | Common ground for everything |
| Power board +5 V | C3 "5V" | Solder last. Never use the power board and USB at the same time |
| C3 "4" | Resistor 1–2.2 kΩ → TIP120 pin 1 (B) | |
| C3 "4" | 10 kΩ → GND | Recommended |
| TIP120 pin 3 (E) | GND | |
| TIP120 pin 2 (C) | Motor negative | |
| Motor positive | +5 V | A diode across the motor is recommended, stripe towards +5 V |
| C3 "5" | Cam switch → GND | Uses the board's internal pull-up, no resistor needed |
| C3 "6" | Button → GND | Optional. The firmware is ready for the button, but it is not fitted in this build, see below |
TIP120 seen from the front with the legs down: B, C, E from the left.
Do not use GPIO2, 8 or 9 for anything. They decide how the board boots.
The firmware already listens on GPIO6 with the board's internal pull-up. An ordinary
push button between "6" and GND is all it takes, and petfeed.yaml is left unchanged.
- When the feeder is idle, a press gives «Manuell dose» (the manual dose) and subtracts it from the daily quota, exactly like «Gi mat nå» on the mobile page. If the quota is used up, nothing comes out.
- When the feeder is busy, meaning while it is feeding or being updated over wifi, a press gives no food. If the motor is running, the press stops it.
- The button also works without wifi and without a clock. Without a clock the feeder does not start a new day, so the button only gives what is left of the daily quota.
- If the feeder is not calibrated, there is no quota. Each press while the feeder is idle then gives the manual dose, with no daily limit.
In this build the button is not connected. The original button sits on the old control board, and the pin is left open. The button is therefore untested on the device.
- Unplug the feeder, and keep it unplugged until the last step. You only work on the low-voltage side (5 V). If the feeder has a built-in mains supply (230 V going into the case itself), never plug it in while it is open.
- Find the motor's two wires, the cam switch's two wires, and the power board's +5 V and GND. Read the marking on the adapter or the power board to confirm that it really is 5 V. If you want to measure, only do so on feeders with an external adapter, and unplug it again afterwards.
- Disconnect the old control board.
- Measure the cam switch with a multimeter while the wheel is in its rest position,
which is where it stops by itself between two portions. Note whether the switch is
closed or open. You need the answer in
petfeed.yaml. - Flash the C3 board over USB before you solder it in (see below). Then you know the board works and gets onto wifi. Remove the USB cable afterwards.
- Solder in this order: cam switch, resistor and TIP120, ground, motor, and finally +5 V to the board.
- Plug the feeder in, open the mobile page, and follow "First setup" below.
You need Python 3. The tests also need g++ and Node.js 22.7 or newer (run here with
Node 24), but they are not required for building.
git clone https://github.com/mcmartnor/PetFeed.git
cd PetFeed
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
cp secrets.yaml.example secrets.yamlOpen secrets.yaml and fill in your wifi name, your wifi password, and a password of
your own choice for updates over wifi. The file must never go into git, and
.gitignore keeps it out.
scripts/esphome.sh compile petfeed.yaml # build
scripts/esphome.sh upload petfeed.yaml --device /dev/ttyACM0 # first time, over USB
scripts/esphome.sh upload petfeed.yaml --device FEEDER_IP # later, over wifi
scripts/esphome.sh logs petfeed.yaml --device /dev/ttyACM0 # log over USB
scripts/test.sh # the testsReplace FEEDER_IP with the address the feeder got on your network, here and in the
examples further down.
The toolchain is downloaded to .cache/ in the project folder the first time you
build. That takes a few minutes.
Everything is at the top of the file, under substitutions.
| Name | Default | What it is |
|---|---|---|
hvile_er_trykket |
"true" |
The cam switch's state when the wheel is in its rest position, as you measured it: closed is "true", open is "false". The wrong value makes the feeder stop halfway between two portions and miscount |
porsjonsfrist_s |
"5" |
The longest one portion may take before the motor is stopped. Here a portion takes about 2 seconds. Measure your own and set the limit to roughly twice that |
prell |
30ms |
Debounce filter for the cam switch |
wifi_effekt |
8.5dB |
Transmit power. It is set low because some C3 Super Mini boards are reported to get unstable wifi at full power. If the feeder is far from the router, you can try a higher value |
The time zone is under time: and is Europe/Oslo.
Open http://FEEDER_IP/ on your phone. You find the IP address in your router, or in
the log over USB. On many networks http://petfeed.local/ works too.
A new feeder has six feeding times (06, 09, 12, 15, 18 and 21), but no calibration and no daily quota. The scheduled feedings then give nothing. So do this before you let the feeder take over:
- Calibrate (see below), and save «Gram per porsjon» (grams per portion) under «Innstillinger» (Settings).
- Set «Dagskvote» (daily quota) in grams.
- Adjust the feeding times under «Fôringer» (Feedings).
- Check that the first scheduled feeding actually comes.
The feeder counts revolutions, not grams. You therefore have to tell it what a portion weighs:
- Empty the bowl and put it on a kitchen scale.
- Give at least six portions with the large button («Gi … nå»), and weigh it all together. Each press gives as many portions as «Manuell dose» is set to.
- Divide the weight by the number of portions, and enter the result as «Gram per porsjon».
Weigh many portions, not one. Here single portions varied from 6.5 to 18 grams, while six portions together gave 73 grams, which is 12.2 grams on average. The gram figures are therefore an estimate: the total over a day is much closer than any single feeding.
The daily quota is converted to whole portions and rounded down. With 75 grams per day and 12.2 grams per portion, that makes six portions. One feeding never gives more than four portions, so a large quota needs enough feeding times to fit.
When the daily quota is used up, the large button changes to «Kvoten er brukt» (quota used), and a separate button for giving outside the quota appears.
The mobile page uses ESPHome's ordinary web API, so the feeder can also be controlled from scripts. The entity names are Norwegian: «Gi mat nå» is the feed button and «Dagskvote» is the daily quota.
curl -X POST -d '' 'http://FEEDER_IP/button/Gi%20mat%20n%C3%A5/press'
curl -X POST -d '' 'http://FEEDER_IP/number/Dagskvote/set?value=75'
curl -N 'http://FEEDER_IP/events' # live stateRead these before you leave the feeder in charge on its own.
- No login. Anyone on the home network can give food and change the settings. Do not expose the feeder to the internet.
- Without a physical button, every feeding outside the schedule has to be ordered over the network, from the mobile page or with the commands above. That is how this build is. If wifi is down, the schedule keeps running as long as the clock is set, but you cannot give food outside it.
- No battery-backed clock. After a power cut the schedule does not run until the feeder is back on wifi and has fetched the time. Without internet, the feedings are missed.
- The cam switch confirms movement, not food. If the hopper is empty or the food has jammed, the feeder still believes it has fed.
- Automatic times catch up on what was missed. If feedings are missed early in the day, the next automatic time gives up to four portions at once. A feeding that is more than 15 minutes late counts as missed.
- If the processor itself hangs with the motor pin high, the motor runs until the power is cut. The timers in the firmware do not help against that. The 10 kΩ resistor covers boot, not this.
- Untested: a wifi update that hangs in the middle of a feeding, what the motor pin does in ESPHome's safe mode, and many short power cuts in a row.
- No alerts. The feeder does not tell you when something goes wrong. Check on the animal and the bowl, especially the first days.
| File | Contents |
|---|---|
petfeed.yaml |
The ESPHome configuration: pins, wifi, clock, buttons and the feeding scripts |
petfeed_logikk.h |
Quota, schedule and accounting. Plain C++ with no hardware, tested in tests/ |
petfeed_lager.h |
Storage of the settings in the board's flash |
motorvakt.h |
The timer that turns the motor off independently of the main program |
web/ |
The mobile page that the board serves itself |
tests/, web/petfeed.test.mjs |
Tests for the logic and the mobile page |
scripts/ |
Wrappers for ESPHome and for running the tests |
This is a hobby project, shared as is. You convert and use the feeder at your own risk, and you are responsible for the animal being fed. The conversion voids the feeder's warranty.
MIT, see LICENSE.