Selective Detection of Mg2+ for Sensing Applications in Drinking Water