Skip to content

ESP32 (and remaining hardware) part of the DualCatFeeder project.

Notifications You must be signed in to change notification settings

ultrara1n/dualcatfeeder-esp32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dualcatfeeder-esp32

This is the microcontroller implementation part of the DualCatFeeder project. The code is developed using VS Code with the PlatformIO extension, so my urgent advice is to use this constellation if you are planning to build and use the software by yourself.

GIF of web app

Here you will only find software and wiring related information, the more important stuff (like 3D models) you can find in the main repository

Prepare your IDE

Clone the repository to a place of your choice and open the project in VS Code. You will need the Platformio extension to do all further steps. I'm using Arduino OTA to flash updates of code and website to the ESP32, but for your initial flash you will have to connect the device via USB and do a "old fashioned" flash process.

Flash your ESP32

It is necessary to do two separate flash processes to get all the data to your microcontroller. On the one hand you will have to flash the general C++ code and on the other hand some webserver related stuff to the flash memory of your ESP32. But don't worry, at the end there are only two different buttons to press.

Code

Upload code

Webserver data

Upload flash

Wiring

Wiring is quite simple, as the components used are pretty easy to hook up. Take a look at the Fritzing diagram and the notes afterwards Fritzing wiring diagram

The DC motor driver is a L298N powered by a 12 V 3A power supply. The L298N is providing a 5 V output that we are using on the ESP32. Be sure to use a jumper (if not already in place) on the L298N to connect ENA and ENB with the 5V pin over them.

On the ESP32 there are 4 GPIO pins used which are connected as following:

GPIO13 -> IN1

GPIO14 -> IN2

GPIO15 -> IN3

GPIO4 -> IN4

Feel free to change this wiring but don't forget to adjust the lines in the code.

WebSocket API

The ESP32 is providing a WebSocket API which is called with JSON input to control and receive data from the device.

Set Timer

{
    "data": {
        "type": "timer",
        "id": "1",
        "attributes": {
            "active": true,
            "timestamp": 18900,
            "seconds": 30
        }
    }
}

On connect to websocket

{
    "data": {
        "type": "initial",
        "attributes": {
            "boottime": 1611267046,
            "rebootreasoncpu0": "SW_CPU_RESET",
            "rebootreasoncpu1": "SW_CPU_RESET",
            "rssi": -55,
            "freeheap": 164124,
            "rightlastfeedtime": 1611325170,
            "rightlastfeedduration": 15000,
            "leftlastfeedtime": 1611292500,
            "leftlastfeedduration": 30000,
            "timer1": {
                "active": true,
                "timestamp": 18900,
                "seconds": 30
            }
        }
    }
}

Start motor

motor can be left, right or both

{
    "data": {
        "type": "startMotor",
        "attributes": {
            "motor": "right",
            "seconds": 20,
        }
    }
}

Stop all motors

{
    "data": {
        "type": "stopMotor"
    }
}

System operations

{
    "data": {
        "type": "reboot"
    }
}

Feedback when performing operations

{
    "data": {
        "type": "response",
        "attributes": {
            "message": "right"
        }
    }
}

Updating

Third-party resources

About

ESP32 (and remaining hardware) part of the DualCatFeeder project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published