Cloud-based IoT System for Automatic Pet Feeding
16.04.2022

This project was developed for the IoT course to solve the problem of feeding a pet automatically or manually from remote locations. The solution is a cloud-based IoT system that gathers data from sensors and interacts with the environment using actuators. The system ensures that the pet is fed on time, whether the user is nearby or far away.
The IoT device is built using RIOT-OS and an STM NUCLEO-f401re board. The system is designed around AWS cloud-based services, integrating both sensors and actuators to control the pet feeding process.
The core components of the system include two sensors and two actuators:
- Ultrasonic sensor (HC SR04): Measures the fill level of the food dispenser.
- PIR motion sensor (HC SR501): Detects when the pet is walking near the dispenser.
- Stepper motor (28BYJ 48 + ULN 2003 driver): Dispenses food when triggered.
- LED: Lights up when the food container is empty.
The board communicates with the cloud via MQTT-SN, which ensures low-latency and lightweight communication, ideal for IoT applications. The system's communication is optimized to handle small message sizes. Latency measurements show an average delay of less than 2 seconds for reading the fill level and 1 second for dispensing food. The overall round-trip time from a dispense request to the updated dashboard is less than 7 seconds, which is within acceptable limits for real-time interactivity. Messages are transmitted at small sizes (8 bytes for dispense requests, 3 bytes for sensor readings), minimizing network overhead. MQTT-SN was selected for its small message footprint, making it ideal for IoT environments.
The 'Sense-Think-Act' paradigm is followed in the system’s design:
- Sense: The PIR motion sensor detects when the pet walks by.
- Think: When motion is detected, the system triggers the stepper motor to dispense food.
- Act: The ultrasonic sensor measures the fill level after dispensing food, updating the cloud with the new data.
After dispensing food, the system checks if the container needs refilling by measuring the distance using the ultrasonic sensor. If the container is empty, the LED turns on as a visual alert.
The system integrates with AWS IoTCore for cloud communication. The following services were utilized to ensure smooth operation:
- DynamoDB: Stores pet feeder data, including fill levels and user interactions.
- API Gateway: Facilitates communication between the web dashboard and the IoT device.
- Amplify: Hosts the front-end web dashboard, enabling users to control the pet feeder remotely.
- Lambda Functions: Handle actions like publishing dispense requests to IoTCore and retrieving the current fill level.
AWS IoTCore ensures seamless communication with the device, while Lambda functions enable efficient, real-time processing.
You can find the complete code for both the RIOT-OS board logic and the cloud infrastructure on GitHub: Pet Feeder Repository. It contains detailed instructions on how to replicate the project, both for the hardware setup (including the sensors, actuators, and board) and for deploying the cloud-based services on AWS.