A drug delivery device comprising:a cartridge retainer configured to receive a cartridge of medicament;a controller; and an electronic cartridge detection system configured to determine if the cartridge of medicament has been correctly inserted into the cartridge retainer.