Automation systems are widely applied in many fields such as manufacturing, warehousing, machinery, power management, and smart living spaces. In this study, a bidirectional security system was designed and applied to intravenous (IV) infusion for wards in hospitals. The system comprised a high-resolution gravity sensor, a 2.4 GHz XBee wireless sensor network communication module, and a drip-quantity-detecting control box with a HOTEC Corp. MCU HT66F70A core microprocessor to achieve automated management in the medical field. Toward achieving sustainability in our medical environment and computer science technology, we adopted data transformation, an Internet of Things (IoT) wireless communication and sensor network, and an app to construct the bidirectional security system for IV infusion. The main aims of the proposed method in this study were as follows: (1) to invent a reliable method to detect the remaining quantity of a patient's drip infusion using a gravity sensor so as to prevent the dangerous condition of blood flowing backward or air intruding into the vein as well as to decrease the burden on nursing staff in wards, and (2) to avoid medical disputes due to the incorrect infusion from drips, the autorecognition of patients using scanning QR code technology was applied in the medical management system. The outcome of the study was proved successful and has won many important national invention contests.