Water scarcity is a pressing global issue that needs to be faced. The United Nations highlights that only about 31 percent of the population is not characterized by water stress, meaning that the world's freshwater resources are unevenly distributed and unsustainably managed. This phenomenon is both natural and man-made, as the human footprint is linked to many disciplines, with the largest impact coming from the agricultural sector. Scientific literature highlights how 4.0 technologies are the key drivers to reduce this sector's impact on valuable resources, such as water and soil. Based on these premises, the proposed work aims at improving the irrigation management in agriculture by implementing a three-layer architecture system to optimize water consumption and prevent soil percolation, by avoiding situations where the soil moisture exceeds its capacity point. To achieve this, experimental activities allow the evaluation of the soil capacity point and thus the definition of a confidence interval to guide watering decisions. The latter interval, soil and environmental data, and three-day weather forecasts are aggregate to create a consistent dataset for training and testing three different machine learning algorithms based on a classification problem to predict the state of the irrigation network. As a result, the implemented multi-layer perceptron neural network, support vector machine, and k-neighbors classifier achieved an accuracy of nearly 99%. Despite this, the neural network produced superior decision region boundaries, resulting in fewer false predictions. A Monte Carlo simulation was then applied to evaluate the water and energy savings, which were up to 27 % and 57 %, respectively. In summary, the predictive algorithm-based irrigation management system is a cost-effective solution for optimizing water management in agriculture that it is truly scalable to any crop by assessing the appropriate soil capacity level.