This research targets rats, which are notorious pests causing food spoilage, disease transmission, and human bites in residential areas, by developing an IoT-based automatic trap. Using ESP32-CAM and IoT technology, the trap ensures effective and safe rat capture with real-time monitoring. The NodeMCU-ESP8266 microcontroller integrates with the Blynk app for seamless control. HCSR-04 Ultrasonic Sensors and 2 Servo Motors detect rats and automate door movement. Employing a research and development approach, the study meticulously assesses sensor, motor, and trap accuracy. Findings highlight the initial Ultrasonic Sensor's proficiency in detecting mice within 16cm, triggering door 1 closure and trapping the mouse. The second Ultrasonic Sensor triggers door 2 to open, releasing the mouse into the electric trap. A Blynk app notification informs users of successful captures. This innovative IoT-based rat trap offers an efficient solution for rodent infestations, potentially enhancing residential environments with scope for further improvements