Pet Feeder
Automatic food dispenser for animals
Author: JUVERDEANU Diana-Maria
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-JuverdeanuDianaMaria
Descriptionā
I grew up surrounded by pets at home, and one recurring challenge we faced as a family was planning vacations. We often had to limit our travel plans because it was difficult to find someone reliable to feed our pets while we were away. This inspired me to design a Smart Pet Feeder system built using a Raspberry Pi Pico 2W and Rust. The feeder dispenses food at scheduled times or remotely via wi-fi control. To make pet care more convenient and give pet owners more freedom and peace of mind when traveling.
Motivationā
I believe this could be a practical solution to real-life problems I've faced. Even if the project might seem a bit silly, Iām excited to have fun working with the hardware I've invested in.
Architectureā
Main Components:
Raspberry Pico 2W: Acts as the central processing unit for the Pet Feeder, controlling the sensors and motors.
Ultrasonic Distance Sensor HC-SR04+: Detects when a pet is near the feeder.
Servo Motor SG90: Drives the mechanism to dispense the pet food.
LCD 1602: Displays a message when the object is detected.
Power Supply: Provides the necessary power to all components at 5V.
Wi-Fi Module: Facilitates communication with external devices.
Connection Overview: The Raspberry Pi Pico 2W acts as the central controller of the Pet Feeder, directly interfacing with the ultrasonic distance sensor (HC-SR04+), the SG90 servomotor, and an LCD1602 display. When the pet approaches the feeder, the sensor detects proximity, and the Pico 2W automatically activates the servo to dispense food. Simultaneously, the LCD1602 displays relevant status messages such as "Object detected" and the current measured distance, providing real-time feedback. The Pico also runs a Wi-Fi access point and hosts a local web server, allowing the owner to manually trigger feeding from a browser interface. The SG90 servomotor is responsible for physically releasing food from a dedicated container and is powered by a stable 5V supply. The ultrasonic distance sensor ensures that food is only dispensed when the pet is actually nearby, preventing unnecessary activation. This architecture ensures seamless interaction between sensing, actuation, and user control, enabling both automatic and manual feeding through reliable, Wi-Fi-based communication, with the Pico 2W orchestrating all core functions and the LCD1602 providing local visual feedback.
Logā
Week 5 - 11 Mayā
Bought hardware parts. Mounted the Raspberry Pi Pico 2W on breadboard. Wrote the code for the ultrasonic sensor (HC-SR04+). Tested PWM for SG90 servo motor.
Week 12 - 18 Mayā
Wrote the code for the servomotor (SG90) and for the button. Tested the LCD.
Week 19 - 25 Mayā
Wrote the code for the LCD to display text messages when the button is pressed and the sensor detects an object. I made a server with functionality commands.
Hardwareā
Pico 2W - brain of the Pet Feeder
Servo Motor SG90 - delivers food
Ultrasonic Distance Sensor HC-SR04+ - detects pet
LCD 1602 - displays a message
Power Supply - battery 5V
Schematicsā
This is the kicad schematic.
Bill of Materialsā
Device | Usage | Price |
---|---|---|
Raspberry Pi Pico 2W | The microcontroller | 39 RON |
Servo Motor SG90 | The Servo Motor | 12 RON |
Raspberry Pi Pico Debug probe | Pico Debug Probe | 66 RON |
HC-SR04+ Distance sensor | Used to measure the distance from the pet to the device | 15 RON |
LCD 1602 | LCD module that communicates via I2C interface and displays 2 rows of 16 characters each | 17 RON |
Softwareā
Library | Description | Usage |
---|---|---|
embassy-executor | Asynchronous runtime for embedded Rust | Runs the main() function as an async task and enables multitasking |
embassy-rp | Hardware Abstraction Layer (HAL) for Raspberry Pi Pico 2W | Configures PWM (servo), GPIO (button), I²C (LCD), and other peripherals |
embassy-time | Async timing utilities (timers, delays) | Used for Timer::after_secs() and debounce delays |
hd44780-driver | Driver for HD44780 LCD over I²C via PCF8574 expander | Initializes and writes messages to the 1602 LCD |
heapless | Provides stack-allocated types like String<32> without heap allocation | Used to build display messages for the LCD without std |
fixed | Fixed-point arithmetic types | Used to precisely set PWM frequency divider via to_fixed() |
defmt | Efficient logging framework for embedded devices | Displays debug/info messages via info! during runtime |
defmt-rtt | Sends defmt logs over RTT (Real-Time Transfer) via USB | Streams logs to the host for debugging over USB |
panic-probe | Panic handler that outputs the panic reason through defmt | Captures and logs panics during runtime for debugging |
core::fmt::Write | Enables formatted string output to heapless String | Used with write!(...) macro to write to a String<32> |
embassy-net | Async TCP/IP networking for embedded systems using embassy | Sets up a TCP web server and serves HTTP responses |
embedded-io-async | Async traits for I/O operations (read, write, flush) | Used for writing HTTP responses with write_all() |
core::sync::atomic | Low-level atomic types for safe concurrency | Used for AtomicBool to signal a dispense request from the web handler |
static_cell | Provides a safe way to statically allocate memory for objects that live forever | Used for persistent socket buffers and stack resources (StaticCell) |
core::str | Core string operations (UTF-8 parsing) | Used for interpreting incoming TCP data as a string |
embassy_lab_utils | Custom utilities for Wi-Fi and network initialization | init_wifi!() and init_network_stack() for setting up the access point and network stack |
core::write | Required macro support to use write!() in no_std | Formats LCD text and HTTP headers |