Select your language

Our old cat felt a bit lonely after his friend passed away, so we decided to get him some refreshing new company. However, the younglings are eating a whole lot of cat food and this gives me the opportunity to realize a little hardware project with some circuits I had lying around for too long.


I have a 3D printer, an ESP8266 with WIFI connectivity, a stepper motor with driver and I am an engineer. What could possibly go wrong?

The cat feeder is based on a simple bucket wheel blue print. A reservoir which holds the fodder on top and a cylinder with a pocket to pick up a portion while it rotates. To enjoy the full excitement of being technologically advanced is it imperative that the ESP8266 runs a web socket server to start and stop the feeding from anywhere (especially my couch ūüėÄ).¬†



Building models for my FDM Prusa Mini comes with some limitations in terms of design if functionality is a focus. They cannot be larger than 180mm in all dimensions and to a) resist the hangry cat and b) be warp free, they have to be of appropriate thickness and size. A good guide for 3D printing model creation is e.g. available from the University of Louisville. 



While waiting for all the prints to finish, it is time to take care of the software and electronics


In order to minimize development time and avoid custom designing of PCBs the following four components will be the core of the built:

- ESP8266 NodeMCU board. Its a microcontroller board with integrated WiFi. It can be programmed with the Arduino framework and tools.

- 5V stepper motor

- ULN2003 stepper driver board

- 9V battery

Wiring can be taken from the following diagram. And yes, the 9V battery won't grill the ESP8266 since the datasheet says that you can apply up to 9V even if it says 5V.



As a prerequisite for this project should you start with installing the LittleFS on the ESP8266. This will enable you to properly structure your project into files as you would do it on an ordinary computer. For details please take a look at the documentation. To actually use it, start with downloading the files and then unpack them into a folder called Tools right in your Arduino directory.

After restarting Arduino you will have the uploader available under the Tools menu.

Last step is to create a folder called data right underneath the folder in which you are going to store your sketch. All files which you want to upload need to be stored into this folder.

In our case this folder is going to have just one file for starters. This file will be the homepage through which the user is going to interact with the pet feeder.

<!DOCTYPE html>
    <title>Websocket Table Update</title>
    <style type="text/css">
        table {
            border-collapse: collapse;
        td {
            border: 1px solid black;
            padding: 10px;
    <h1>Cat Feeder V1</h1>
                <div class="card" style="width: 18rem;">
                    <img class="card-img-top" src="/..." alt="Card image cap">
                    <div class="card-body">
                        <h5 class="card-title">Feeder Status</h5>
                        <p class="card-text" id="stat">Idling</p>
                        <a href="#" class="btn btn-primary" onclick="sendMyMessages()">Start</a>
    <script type="text/javascript">
        var gateway = `ws://${window.location.hostname}/ws`;
        var websocket;
        // Init web socket when the page loads
        window.addEventListener('load', onload);

        function onload(event) {

        function getReadings(){

        function initWebSocket() {
            console.log('Trying to open a WebSocket connection…');
            websocket = new WebSocket(gateway);
            websocket.onopen = onOpen;
            websocket.onclose = onClose;
            websocket.onmessage = onMessage;

        // When websocket is established, call the getReadings() function
        function onOpen(event) {
            console.log('Connection opened');

        function onClose(event) {
            console.log('Connection closed');
            setTimeout(initWebSocket, 2000);

        // Function that receives the message from the ESP8266 with the readings
        function onMessage(event) {
            var myObj = JSON.parse(;
            var keys = Object.keys(myObj);

            for (var i = 0; i < keys.length; i++){
                var key = keys[i];
               document.getElementById(key).innerHTML = myObj[key];

        function sendMyMessages() {