An inhalation device comprising a housing, a sensor, a microcontroller, and an actuating device controlled by the microcontroller the housing comprises a mouthpiece having an opening connected to a passage in said housing, wherein the other end of the passage provides an opening for a cartridge said sensor being in communication with the microprocessor and configured to detect a parameter based on an action to the mouthpiece, and wherein a parameter being reached, the microcontroller engages the actuating device which engages the cartridge to deliver medication through the passage and out of the mouthpiece.