Sensing mechanism illustrating the proton hopping between the heptazine units of 3D cubic mesostructured carbon nitride.