A device includes a first flow channel and a liquid space for a liquid. The device also includes a second flow channel arranged in a flow connection with the liquid space, and a steam space arranged to receive steam forming in the liquid space. The first flow channel is arranged in a flow connection with the steam space. Gas flow to the device is conveyed via the second flow channel to the liquid space. Resistance is induced to the exhaled gas flow flowing through the second flow channel and pressure is increased in the liquid space. As a result of the pressure increase, steam produced in the liquid space is received in the steam space. The gas flow is conveyed from the steam space via the first flow channel to the outside of the device.