In order to improve the living standards of diabetes patients and reduce the negative health effects of this disease, the medical community has been actively searching for more effective treatments. In recent years, an artificial pancreas has emerged as an important approach to managing diabetes. Despite these recent advances, meeting the requirements for miniaturized size, accurate sensing and large-volume pumping capability remains a great challenge. Here, we present a novel miniaturized artificial pancreas based on a long microtube sensor integrated with an ultrasonic pump. Our device meets the requirements of achieving both accurate sensing and high pumping capacity. The artificial pancreas is constructed based on a long microtube that is low cost, painless and simple to operate, where the exterior of the microtube is fabricated as a glucose sensor for detecting diabetes and the interior of the microtube is used as a channel for delivering insulin through an ultrasonic pump. This work successfully achieved closed-loop control of blood glucose and treatment of diabetes in rats. It is expected that this work can open up new methodologies for the development of microsystems, and advance the management approach for diabetes patients.