Sensor based inhalers