A spiropyran–amide–dipicolylamine linkage behaves as a colorimetric receptor for selective Co2+ sensing in aqueous media under UV irradiation. This is promoted by strong coordination of Co2+ with amide oxygens of the receptors and efficient photoisomerization of the spiropyran moieties.