Can pH be measured with the sensor in the soil?

No, pH is a measurement in solution. Soil consists of solution, air and particles.