This shows you the differences between two versions of the page.
iothings:proiecte:2022sric:rfid_cat_feeder [2023/06/02 03:12] maria_irina.gherman [Hardware Description] |
iothings:proiecte:2022sric:rfid_cat_feeder [2023/06/02 07:59] (current) maria_irina.gherman [Project Description] |
||
---|---|---|---|
Line 5: | Line 5: | ||
RFID Cat Feeder is a "smart" feeder that opens up only when a certain cat wants to eat. | 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 its collar, or ideally its microchip. The purpose | + | 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. | of such a feeder is to stop a gluttonous cat from eating all the food. | ||
- | ===== Hardware Description ===== | + | ===== Hardware ===== |
- | Parts list: | + | ==== Description ==== |
+ | |||
+ | 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. | ||
+ | |||
+ | ==== Diagram ==== | ||
+ | {{:iothings:proiecte:2022sric:rfid_cat_feeder_diagram.png?600|}} | ||
+ | |||
+ | ==== Parts list ==== | ||
* ESP32 | * ESP32 | ||
* RC522 RFID reader + RFID tag | * RC522 RFID reader + RFID tag | ||
Line 18: | Line 30: | ||
* TowerPro SG90 servo motor | * TowerPro SG90 servo motor | ||
- | The hardware is relatively simple. ESP32 gets info about the RFID tag from an RFID reader. | + | ===== Software Description ===== |
- | 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. | + | ==== Libraries ==== |
+ | |||
+ | ''**#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 | ||
+ | |||
+ | ==== Pseudocode ==== | ||
+ | |||
+ | The core functionality of the feeder can be simplified in this pseudocode: | ||
+ | |||
+ | <code> | ||
+ | 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 | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | The full code can be viewed on my [[https://github.com/zabbidou/RFID-Cat-Feeder|github]] | ||
+ | |||
+ | ===== Testing ===== | ||
+ | |||
+ | <html><iframe width="456" height="811" src="https://www.youtube.com/embed/VE8ORTkLVlI" title="RFID Cat Feeder Demo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></html> | ||
+ | |||
+ | ===== References ===== | ||
+ | [[https://www.electronicwings.com/esp32/rfid-rc522-interfacing-with-esp32|RC522 example]] | ||
+ | |||
+ | [[https://dronebotworkshop.com/esp32-servo/|Servo example]] | ||
+ | |||
+ | [[https://forum.arduino.cc/t/hc-sr04-always-returns-zero/206641/17|Ultrasonic sensor example]] | ||
- | 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. |