Automatic irrigation system with a soil sensor