Ca, Mg, as the main components in water, are not only essential nutrients for life but are also an important index of water hardness. Rapid detection of the element content is of great significance for water quality evaluation and nutrient balance in planting and breeding water. Traditional laboratory analysis methods are time consuming and involve complex procedures. Ion cross sensitivity and response drift also limit the application of online sensors. These disadvantages are not in line with the precise control and rapid response required for practical applications. Here, we propose a rapid automatic Ca, Mg ion concentration detection method using Laser-induced breakdown spectroscopy. Based on a cation exchange membrane, an automatic control system integrating water sampling, hybrid reacting, attachment drying and spectra measuring was constructed. The testing time for one sample could be compressed to 5 min. Consequently, it met the requirements of accuracy and timeliness of water element regulation. The proposed system can provide new technical means for large-scale aquaculture, soilless cultivation of facilities and other scenarios aiming at accurate measurement and control of elements in water body.