In our work, we propose a novel temperature sensor design based on a two-dimensional (2D) photonic crystal resonant cavity structure designed to detect and monitor temperature under very harsh environmental conditions from 0 °C to 500 ºC. The sensitivity of the proposed structure is 109.8 pm/ºC, an ultra-high quality factor, high transmission efficiency and ultra-compact size. The characteristics of the proposed sensor under different temperatures are simulated using the Plane Wave Expansion (PWE) method and Finite Difference Time Domain (FDTD) method to calculate, respectively, the Photonic Band Gap (PBG) and transmission efficiency. The results obtained show that the wavelength of the resonant cavity increases linearly with increasing temperature. Our sensor is suitable for applications based on nanotechnology.