Add pH check and relay control