Force-compensated hydrogel-based pH sensors