A swallowable capsule configured to obtain fluid samples from the gastrointestinal tract of a subject comprising: an outer shell enclosing an interior space; the outer shell having a shell opening serving as an inlet port that allows a fluid sample to enter into the swallowable capsule; a sampling chamber which may hold one or more samples obtained from the gastrointestinal tract; a piston which is moveably arranged in the interior space; a pressure generating device that can build up pressure on one side of the piston to propel the piston in the interior space at least from a second position allowing fluid from outside the swallowable capsule to enter into the capsule to a third position, in which fluid exterior to the swallowable capsule is prevented from entering into the capsule; wherein the piston comprises: a main body and an extension extending away from the main body in the forward direction of the piston a first seal portion that closes the shell opening in a first position of the piston thereby preventing fluid exterior to the swallowable capsule from entering into the capsule; a piston opening that is aligned with the shell opening in a second position of the piston thereby allowing fluid from outside the swallowable capsule to enter into the capsule; a second seal portion that closes the shell opening in a third position of the piston thereby preventing fluid exterior to the swallowable capsule from entering into the capsule; a control unit configured to control the pressure generating device so as to move the piston in a forward direction from the first position to the second position and then from the second position to the third position. an outer shell enclosing an interior space; the outer shell having a shell opening serving as an inlet port that allows a fluid sample to enter into the swallowable capsule; a sampling chamber which may hold one or more samples obtained from the gastrointestinal tract; a piston which is moveably arranged in the interior space; a pressure generating device that can build up pressure on one side of the piston to propel the piston in the interior space at least from a second position allowing fluid from outside the swallowable capsule to enter into the capsule to a third position, in which fluid exterior to the swallowable capsule is prevented from entering into the capsule; wherein the piston comprises: a main body and an extension extending away from the main body in the forward direction of the piston a first seal portion that closes the shell opening in a first position of the piston thereby preventing fluid exterior to the swallowable capsule from entering into the capsule; a piston opening that is aligned with the shell opening in a second position of the piston thereby allowing fluid from outside the swallowable capsule to enter into the capsule; a second seal portion that closes the shell opening in a third position of the piston thereby preventing fluid exterior to the swallowable capsule from entering into the capsule; a control unit configured to control the pressure generating device so as to move the piston in a forward direction from the first position to the second position and then from the second position to the third position. a main body and an extension extending away from the main body in the forward direction of the piston a first seal portion that closes the shell opening in a first position of the piston thereby preventing fluid exterior to the swallowable capsule from entering into the capsule; a piston opening that is aligned with the shell opening in a second position of the piston thereby allowing fluid from outside the swallowable capsule to enter into the capsule; a second seal portion that closes the shell opening in a third position of the piston thereby preventing fluid exterior to the swallowable capsule from entering into the capsule; a control unit configured to control the pressure generating device so as to move the piston in a forward direction from the first position to the second position and then from the second position to the third position.