Device for preparing a drink from a cartridge, with activation after reading an optical code on the cartridge