An electrically heated smoking device (100) is disclosed. The device comprises at least one heating element (119) for heating an aerosol-forming substrate, and a power source (107) for providing power to the heating element, and electric circuitry (109) for controlling the supply of power to the heating element. The electric circuitry (109) is arranged to determine the temperature of the heating element and adjust the power to the heating element to maintain the temperature of the heating element within a desired temperature range. The desired temperature range is dynamically calculated based on a measured flow rate of gas through or past the device. By controlling the temperature of the heating element, aerosol with consistent and desirable properties can be produced. A method of controlling aerosol production is also disclosed.