Abstract Er3+-M2+ (M2+ = Zn2+, Mg2+) co-doped double-perovskite CaBa2WO6 phosphors were synthesized. The site occupancy of Mg2+and Zn2+ is studied by first-principles calculations of binding energy, the band structure and partial density of states. The temperature dependent emission spectra of resulting samples are studied. The fluoresce intensity ratio of thermally coupled levels of 2H11/2 and 4S3/2 is dependent on the temperature. The optical temperature sensitivity of perovskite CaBa2WO6:Er3+ is doubled by co-doping with 3 mol% Mg2+. These results indicate that CaBa2WO6:Er3+, Mg2+ will be applied in optical temperature sensor.