Developing an in-pipe water pollution detection system ensures that the contaminated water will not enter the system in the event of water pollution, hence reducing the possibility of a water crisis. In this research, the design of the system was completed using SOLIDWORKS. ANSYS software was used for the deformation simulation analysis of the pH sensor and the ball valve installed in the system due to water pressure. The maximum deformation of the ball valve occurred at the edges of the ball valve for a fully-closed valve and the middle tip of the ball valve when the valve was opened 45°. The deformation is similar in these conditions due to the small area at the edges; thus, the pressure at the location is higher. For the pH sensor, the deformation of the body is approximately 5.7138 × 10-4 mm. The maximum stress is below the limit, proving that the sensor is suitable for operating in that position. Overall, the experimental results proved that the system is able to detect if the water is polluted by sensing the pH level changes in the water and managing the flow of the water pipe. In the future, by complementing this system with the Internet of Things (IoT), it can assist and alert workers in water treatment plants to detect water pollution in their treatment facility at the earliest stage. Thus, reducing operational costs and the closure of water treatment plants can be prevented in the future.