HMEs work by trapping the heat and moisture from exhaled air and then releasing it into the inhaled air. They typically consist of a hygroscopic material that absorbs moisture and retains heat. When the patient exhales, the HME captures the heat and moisture, and during the next inhalation, this captured heat and moisture is transferred to the incoming air.