Scientists say they have designed a jelly-like pill that inflates to the size of a ping-pong ball when it reaches the stomach, and could be used to monitor tumours or ulcers.
The soft, squishy device was inspired by the puffer fish, which inflates quickly like a balloon when threatened.
The Massachusetts Institute of Technology team behind the pill says it can last for a month.
The pill has been tested in pigs but not yet in humans.
The pill is made from two types of hydrogels - an inner layer of absorbent particles and an outer protective membrane.
This gives it the consistency of jelly, helping it to expand quickly in the stomach and therefore stopping it from passing out the other end.
Soft and strong
The inflated pill could be removed at any time by drinking a solution of calcium that makes it quickly shrink to its original size, the scientists claim.
It can then pass safely out of the body.
In the lab, researchers put the pill in solutions of water resembling gastric stomach juices and found it inflated to 100 times its original size in 15 minutes.
But they also found it was strong enough to survive regular contractions in the stomach.
The researchers say the pill is softer and lasts longer than current alternatives, which are often made of hard plastic or metal.
When temperature sensors inside pills were fed to pigs - which have very similar stomachs and intestines to humans - the team was able to track the animals' daily activities for up to 30 days.
"The dream is to have a smart pill, that once swallowed stays in the stomach and monitors the patient's health for a long time, such as a month," says Xuanhe Zhao, associate professor of mechanical engineering at MIT.
The researchers, whose work is reported in the journal Nature Communications, envisage putting various different sensors inside the puffer pills and delivering them to the stomach.
These sensors could monitor signs of bacteria and viruses.
In the long term, with tiny cameras inside them, the pills might also be used to check the progress of tumours or ulcers over several weeks, the research team said.
And Prof Zhao said the pill could potentially be used as an alternative to the gastric balloon, which is inserted into the stomach to encourage weight loss.