-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This project is an intelligent mouse trap system that utilizes Raspberry Pi, Arduino, and a mobile app to detect mice, notify the owner, and allow remote control of the trap. The system integrates various components to ensure smooth operation and real-time communication.
Location: src/broker.py
Description: The broker component manages the communication between different parts of the system. It listens for connections, handles incoming messages, and routes them to the appropriate services.
-
Key Functions:
-
server(service): Starts the server for a specified service. -
message_control(service, msg_flag, msg_content): Handles messages based on their flag. -
stop(service, client_socket): Ensures all endpoints are online. -
play(service, client_socket): Syncs all endpoints. -
send(service, client_socket, msg_flag, msg_content): Sends encoded messages. -
recv_all(service, client_socket, length): Receives messages from a socket. -
toggleOffline(service): Sets the service status to offline. -
toggleClose(service): Closes the communication socket.
-
-
Usage:
python broker.py
Location: src/field_brain.py
Description: The field brain is responsible for communicating with the Arduino and managing local operations such as sending commands and receiving sensor data.
-
Key Functions:
-
client(service): Manages the main client functionality. -
recv(service, msg_flag, msg_content): Handles received messages. -
arduino_client(service): Manages communication with the Arduino. -
message_control(service, serial_socket, msg_flag, msg_content): Controls behavior based on received messages. -
play(service): Syncs the client with the server. -
send(service, msg_flag, msg_content): Sends encoded messages. -
recv_all(service, length): Receives messages from a socket.
-
-
Usage:
python field_brain.py
Location: src/photos.py
Description: This module handles photo capture using the Raspberry Pi camera. It continuously captures photos at set intervals.
-
Key Functions:
-
photos_control(service): Main functionality for capturing photos. -
main(): Starts the photo capture thread.
-
-
Usage:
python photos.py
Location: src/main.py
Description: The mobile app provides a user interface for interacting with the mouse trap system. It allows the user to send commands and view the status of the trap.
-
Key Functions:
-
build(): Builds the GUI. -
connect(text): Connects to the specified IP address. -
start_clock(): Starts the clock for GUI updates. -
updateGUI(*args): Updates the GUI with current information. -
sendOpenR(): Sends an open request. -
sendCloseR(): Sends a close request. -
sendPhotoR(): Sends a photo request. -
disconnect(): Disconnects the app. -
client(service): Manages the main client functionality. -
recv(service, msg_flag, msg_content): Handles received messages. -
play(service): Syncs the client with the server. -
send(service, msg_flag, msg_content): Sends encoded messages. -
recv_all(service, length): Receives messages from a socket.
-
-
Usage:
python main.py
Location: src/mouse_trap_controller/field_muscle.ino
Description: The field_muscle.ino Arduino code controls the servo motor and sensor.
-
Key Functions:
-
setup(): Initializes the Arduino. -
loop(): Main loop function. -
actuateServo(command): Controls the servo motor. -
getCurrentDistance(): Gets the current distance from the sensor.
-
-
Usage: Upload the
field_muscle.inocode to the Arduino.
- Raspberry Pi with Python installed.
- Arduino with the necessary libraries.
- Network setup to allow communication between the devices.
-
Clone the repository.
-
Install the required Python libraries.
-
Upload the Arduino code (
field_muscle.ino) to the Arduino.
-
Start the broker:
python broker.py
-
Start the field brain:
python field_brain.py
-
Start the photo capture service:
python photos.py
-
Start the mobile application:
python main.py
- Connection Issues: Ensure all devices are on the same network and the IP addresses are correctly set.
- Arduino Communication: Check the serial connection and ensure the correct port is specified.