Author: Gherman Maria Irina
RFID Cat Feeder is a “smart” feeder that opens up only when a certain cat wants to eat. It can do this by reading an RFID tag on a cat's collar, or ideally its microchip. The purpose of such a feeder is to stop a gluttonous cat from eating all the food.
The hardware is relatively simple. ESP32 gets info about the RFID tag from an RFID reader. The door motion is controlled by a servo motor. Registering a new tag is done through a button. Two LEDs help the user know what the feeder is currently doing.
To have a safety mechanism so that the door doesn't close on the cat, the feeder uses an ultrasonic sensor to sense if there is a cat in front of it.
#include <ESP32Servo.h> - Easy control of the servo motor, a fork of Arduino's Servo.h that is compatible with ESP32
#include <MFRC522.h> - Library for reading from the RFID reader
#include <SPI.h> - Another library used for the RFID reader
#include <NewPing.h> - A library to simplify the usage of the ultrasonic sensor
The core functionality of the feeder can be simplified in this pseudocode:
loop() {
if (register mode) {
turn on red led
} else {
turn off red led
}
if (button pressed) {
toggle register mode
}
if (reading a card) {
if (register mode) {
add card uid to vector
} else {
if (card uid is in vector) {
open door
wait 5 seconds
close door if no obstacle
} else {
do nothing
}
}
}
}
The full code can be viewed on my github