Scientists developed a pill that could replace insulin injections for patients with type 2 diabetes.

The blueberry-sized capsule contains a small needle made of compressed insulin, which gets infused once the tablet reaches the stomach.

In tests on animals, an MIT-led research group showed they could deliver enough insulin to lower blood sugar to levels comparable to those produced by doses administered through skin.

The device, detailed in a paper published this week by the journal Science, could also be adapted to deliver other protein drugs.

“We are really hopeful that this new type of capsule could someday help diabetic patients and perhaps anyone who requires therapies that can now only be given by injection or infusion,” study co-author Robert Langer, of MIT’s Koch Institute for Integrative Cancer Research, said in a statement.

In 2014, Langer, visiting scientist Giovanni Traverso, and their colleagues developed a similar pill, coated with many tiny needles that could inject drugs into the lining of the stomach or small intestine.

They’ve since whittled that design down to just one needle, attached to a spring, held in place by a sugar disk. The idea is that, once swallowed, water in the stomach dissolves the sugar, releasing the spring, and injecting the needle into the stomach wall.

There are no pain receptors in the organ’s lining, so patients shouldn’t feel a thing.

Drawing inspiration from the leopard tortoise, which can right itself if it rolls onto its back, researchers designed their system so that no matter how the capsule lands, it can self-orient so the needle is in contact with the stomach wall.

“As soon as you take it, you want the system to self-right so that you can ensure contact with the tissue,” Traverso said.

“Also, if a person were to move around or the stomach were to growl, the device would not move from its preferred orientation,” Alex Abramson, MIT graduate student and study first author, added.

Once injected, the insulin dissolves at a predetermined rate, controlled by scientists preparing the capsule.

Most diagnosed cases of diabetes (75 to 85 percent) are classified as type 2, typically occurring later in life (hence its “adult-onset” title)—when the body stops producing enough insulin to meet the increased demands of weight gain.