52 comments

[ 1.7 ms ] story [ 132 ms ] thread
It's a nice high-level writeup of getting a flakey piece of consumer electronics back in service, though he used an ESP8266, so I am not sure about the title.
To add more to the confusion, twice in the text of TFA he refers to an ESP8622, which AFAIK isn’t a thing. The ESP8266 is fine in this application of course since he’s using a single GPIO pin.
I think the author is not an embedded guy and assumed that ESP32 is the generic name given to these sort of devices.

Either way, I am sure this was a fun project and he achieved what he wanted to do. But if this happened to me I would probably try to reverse engineer the device to free it from PetNet cloud. It would be fun and cool and interesting and I would probably never finish it..

There are a few projects out there that were based around reverse-engineering, and running a local server with DNS hijacking to make the feeder use them as its CC server[1]. But I mostly just wanted something that could sit happily in HomeAssistant along with all the other automations, so ESPhome based device it is

And yeah, I'm not an embedded guy, but I've updated the article with an addendum

[1]: https://github.com/feedernet/petnet-feeder-service/wiki/Gett...

(comment deleted)
I haven't done as much with it, but I've also been very impressed with ESPhome. Seems like a really great piece of software, and super extensible.

The list of supported components is extensive: https://esphome.io/components/index.html

I use it extensively and it really is awesome. It’s not perfect, but the limits I run into aren’t what 80+% of users will ever hit. Even if hacky and ugly, you can work around most of the limitations
I love Home Assistant but I have yet to venture into the ESP32 board route of things. Can someone point to a good guide to getting started with these boards? How much soldering and/or microcontroller experience is needed?
They're pretty great and compatible with most things. ESPHome [1] is a great resource for getting ESP32's working nicely with HA and you can find lots of projects using it to learn from.

You'll likely need to do soldering if you want to connect sensors, batteries and the like.

Personally I really like what SEEED Studio [2] does with their ESP32 boards and they have nice docs.

1. https://esphome.io/ 2. https://www.seeedstudio.com/home-assistant

You could get a dev board and a breakout board on aliexpress for less than $6 - this way you can get away without any soldering for most use cases. And if you use esphome and homeassistant, pretty much all code is just configuration and setup in homeassistant.
You can easily get ESP8266/ESP32 boards with header pins already soldered on; combine this with some DuPont cables (as I’ve just learned they’re called) and you can start messing around with things without much soldering at all. You can also connect to e.g. LED strips and simple sensors in the same way.

See this kit for example: https://a.aliexpress.com/_EyZhdw5

https://www.athom.tech/ are selling a lot of pre-flashed gear in nice casings which is essentially "plug and play ready to go" - out of the box you can wirelessly flash them.

So depending on what you're doing, they're an excellent place to start.

M5Stack/M5Stick products and Grove accessories comes with batteries onboard and connects with cables
The sonoff line is typically pretty hackable and now has etl certification on some of their products. If recommend something like this if you want to switch mains voltage. I use tasmota, which is similar to esphome. The tasmota wiki has disassembly and flashing info. I've always used wires to flash mine but I think there's a software only flash method. The s31 can be flashed with some spring hook probes and the appropriate rs232 cable (3.3v on the data lines iirc). Some of the in wall line need a few pins soldered on (typically 4).

Tasmota has a setup package of you don't mind manually setting up each device. You can also configure them with code if you learn a little c and platformio. At this point, I batch my devices and flash them with wires for initial configuration (Wi-Fi, mqtt, etc), then run updates wirelessly using an http server on my network and mqtt to coordinate.

Side note, the esp8266 is older and less powerful than the esp32. In practice, the esp8266 can't handle https but the esp32 can. This has never been an issue for me and most of my devices are 8266.

> This thing is covered in sensors; it's got two scales, ostensibly for measuring the weight of the hopper and the weight of food dispensed, a pair of infrared sensors to detect when the hooper is empty, sensors that monitor the motor's turning, and others that I haven't figured out the purpose of.

Bad for business if your cat feeder fails to feed the customer's cat and they return from a trip to a very hungry cat.

How could you tell? Don't they usually act as if they're starving?
It'd be much skinnier and/or dead.
It’s pining for the fjords.
You shouldnt leave a cat alone for that long anyway for that to become a concern. Indoor cats become bored very quickly if they dont get enough playtime
Yeah, that sentence shows me that this guy isn't an engineer at all, he's just a hacker.

If he made his own automatic litter box (the rotating drum kind) for his cat, he'll also not see the point of all those sensors that "aren't really needed", and one day he'll come home to find his cat chopped in half.

This take is unnecessarily negative. OP could be very aware of the limitations of their chosen approach and use the feeder accordingly.
Perhaps, but I didn't see anything to that effect in his text. His comment about there being "too many" sensors that he didn't even know the function of, or seem to appreciate the presence of at all, seems to contraindicate your assumption.

Consumer electronics are generally made cheaply, so they don't put sensors in there for no reason at all. Usually there's a very good reason they're in there.

When the device was in service, the sensors didn't really work, and were likely never enabled in the software. The hopper feed level never accurately indicated in-app, and was mostly just based on calculating the approximate amount dispensed vs a "full" hopper, and the machine would often happily report that it dispensed food, and never actually did, so I doubt the scales actually were enabled either
> Complex in that they built so much more functionality into the device than was really needed. This thing is covered in sensors; it's got two scales, ostensibly for measuring the weight of the hopper and the weight of food dispensed, a pair of infrared sensors to detect when the hooper is empty, sensors that monitor the motor's turning, and others that I haven't figured out the purpose of.

I'd love if Surefeed, a competitor, had gone the way of shipping more sensors. Instead, they just monitor the current going through the motor to detect if the lid is closed or opened (the current will spike when it reaches either end position)... and the motor is relatively powerful, powerful enough in fact to shred the plastic gears. It's laughable - this thing consists of a few pieces of plastic, an RFID antenna loop, a motor and a tiny PCB, but costs 160€.

A current sensor is much better than a position sensor, as you don't want to keep trying to close the lid if it catches on anything.
A rotation sensor would detect a blocked gear just as fine, maybe even faster than a current monitor - with the advantage of the rotation sensor being unimpeded by slack in the gear train.
Why is the current sensor impeded by slack? It's also much cheaper and more reliable.
By the time the current monitor senses the spike, a lot of tension can build up in the gear train from slack and torsion. A rotation sensor on the outermost axle can detect a blockage way earlier.
Current sensors can respond in microseconds if needed. Tension takes milliseconds to build up.

I would say the current sensor is probably the right engineering design for reliability, but clearly poor implementation choices were made in this case.

An even better design is a BLDC motor with saliency feedback. That avoids brushes (wear component), and gives both angle and torque feedback. Unfortunately I think someone must have patented it because nobody uses such a design for cheap stuff, despite it being far cheaper.

That's complete overkill. Single BLDC driver can drive 3 DC motors each, even in both directions independently if combined with a dual power supply. I think positional readouts from BLDC is still incremental, so either an origin sensor or a separate absolute encoder is going to be necessary on top of current monitor for sanity check. Whereas, that sanity check current sensing channel could detect jams somewhere in the machine which in itself should suffice for detecting lids pressed against stops.

If there were even a <350EUR cat feeder with that kind of controls and features - it'll be flying off the shelf into university labs and hobbyists sheds. There will be drones and 3D printers built on that. Perhaps even some guided missiles.

Tiny BLDC motor controllers can be had for under 1.5 cents, plus a microcontroller (which most devices have anyway). (six 1 amp mosfets, plus a few passives, and about 1 cm^2 of board area)).

Unfortunately they normally need a control loop that runs at at least 10kHz for saliency measurement, which means all the other code on the microcontroller needs to be well behaved and not have millisecond long critical sections. If you can't do that, you need to add another 5 cents for another microcontroller.

What if I have a dumb cat?
I bought a cat food dispenser for $5 at goodwill and plugged it into a $10 "inching" timer plug from AliExpress. 10 seconds every 4 hours. It's the dumbest smart feeder I could make for the dumbest best cat.
Now this is my kind of engineering!

KISS in action is beautiful, don't let anyone tell you otherwise.

Could you link to a cat food dispenser this works with? The one I have gives food whenever the electricity gets turned on as part of its startup process, but way too much.

Edit: Ah, if it's from goodwill that might be not as easy...

It's one of these

https://www.homehealthcareshoppe.com/buy-ergo-auto-pet-feede...

Big hopper with a plastic auger at the bottom, driven by a gear motor similar to the one that runs a dryer timer. Very simple, no sensors beyond motor overheat. Mine is slightly modified because the idiot cat ate the spout off the end of the auger mechanism. I cobbled together a replacement that's tougher than her.

Oh, so this is also a programmable feeder where you are now using the startup movement to dispense food? Did you try the programming and it did not work for you?

But thanks! Always good to have more options.

Mine had no smarts in it at all. The programmability from the factory was a plug in timer similar to a block heater timer, but that wasn't with the unit when I bought it. If you supply power, the auger turns until the power is disconnected. As in the motor is wired directly to the power cord, with only a thermal cutout in line. The timer I use allows you to set interval in minutes and duration in seconds. They're commonly sold as "inching" timers, which I suspect is a translation error but it's descriptive enough.
Alright, that clears it up. The description I found was misleading. Thanks again!
Something like this was actually my plan for a feeder if I couldn't get the one in the article to work. Except instead of a purpose built catfood dispenser, it was an old BBQ wood pellet feeder I found on the local craigslist-equivalent for $20.

Basically a big metal bin with a powerful auger and chute out the side of it

It's pretty much that, but in a more compact form.

If I hadn't found this one I'd planned on using the auger system from a chocolate fondue fountain, just placed on its side.

I built a smart treat dispenser for my cat using an ESP32.

The best feature is the little speaker inside that plays the Meowmix jingle when dispensing. My cat is now conditioned to come running when she hears that sound.

I connected it to my Apple Home network via Home Assistant, and it works great. I can tell Siri to give the cat a snack, and off she goes.

>The best feature is the little speaker inside that plays the Meowmix jingle when dispensing. My cat is now conditioned to come running when she hears that sound.

Are you sure you don't have that backwards? Maybe she conditioned you to spend your time building a gadget to play her favorite tune.

This is a clever hack. However, if the intent is serious use, I'd be concerned about resiliency. It sounds like the schedule is maintained in Home Assistant, and that it sends a command to the ESP8266 to dispense food. That means a ton of moving parts have to all be working, otherwise the cat doesn't eat: Home Assistant's server and power source, Wi-Fi, and the $1 microcontroller.

If this is intended for serious usage, i.e. the cat won't eat if it fails to dispense, a different design would be more resilient: maybe still define the schedule in Home Assistant or another control plane, but then have it "push" the whole schedule to the device. The device will also need time sync and a realtime clock. Then, the device manages its scheduled dispensation autonomously, even if the network or control plane are unavailable. And, the dispenser should have a little battery so it can run for a couple days with the power out.

Hi, post author here ESPhome timers are actually local to the ESP device. They just depend on a time signal for timekeeping. For now, the time is sent by HomeAssistant, but I could stick an RTC or GPS timesource on the ESP,and have it run 100% locally.

But since this is mostly supplemental food for dental concerns, and he still gets two bowls of wet every day, its not really an issue