Water quality detection plays an increasingly important role in environmental protection. In this work, a novel colorimeter based on the Beer-Lambert law was designed for chemical element detection in water with high precision and miniaturized structure. As an example, the colorimeter can detect phosphorus, which was accomplished in this article to evaluate the performance. Simultaneously, a modified algorithm was applied to extend the linear measurable range. The colorimeter encompassed a near infrared laser source, a microflow cell based on microfluidic technology and a light-sensitive detector, then Micro-Electro-Mechanical System (MEMS) processing technology was used to form a stable integrated structure. Experiments were performed based on the ammonium molybdate spectrophotometric method, including the preparation of phosphorus standard solution, reducing agent, chromogenic agent and color reaction. The device can obtain a wide linear response range (0.05 mg/L up to 7.60 mg/L), a wide reliable measuring range up to 10.16 mg/L after using a novel algorithm, and a low limit of detection (0.02 mg/L). The size of flow cell in this design is 18 mm × 2.0 mm × 800 μm, obtaining a low reagent consumption of 0.004 mg ascorbic acid and 0.011 mg ammonium molybdate per determination. Achieving these advantages of miniaturized volume, high precision and low cost, the design can also be used in automated in situ detection.