###### Abstract  
Contamination of the inner surface of milk hoses of milking systems with milk residues, water residues and pathogenic microflora has a negative impact on milk quality and can affect the accuracy of light-scattering sensors measuring milk quality parameters. A three-stage study of the influence of milking system operating conditions on the accuracy of a light-scattering sensor is presented. The growth of pathogenic microflora on the inner surface of milk hoses was studied, the flow of milk and milk hoses rinsing was simulated and the accuracy of the light-scattering sensor was tested under conditions of low-quality rinsing of the milking system. A significant difference in the total microbial count was detected between the milk residues of healthy animals and the milk residues of animals with subclinical mastitis (1.2 \(\times\) 10\({}^{4}\) CFU/mL and 9.2 \(\times\) 10\({}^{4}\) CFU/mL). The presence of _Staphylococcus_ (_aureus_ and _epidemidis_) was detected in quantities much lower than those that could interfere with the analysis of milk quality parameters. Simulation modeling allowed us to prove that even when rinsing with hot water (80 \({}^{\circ}\)C) without chemical solutions, pathogenic microflora in milk hoses of the milking system will be suppressed. Modeling of the milk flow in the measuring chamber of the device showed the stable replacement of milk in the measuring chamber and provided actual measurements of milk quality parameters. It has been determined that low-quality rinsing and water residues in milk hoses lead to a significant increase in measurement error up to 15-20% during the first 30-40 s after the milking system starts operating. The study results confirm that the light-scattering sensors are resistant to such factors of the milking system operation as contamination by pathogenic microflora (_S. aureus_ and _S. epidermidis_) and low-quality rinsing of milk hoses. miking systems; food quality control; milk; non-destructive food analysis; optical sensors 2023 13 11836 1136 1136 1136 1136 1136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 136 1 and non-destructive diagnostics with high sensitivity and speed [1; 2; 3; 4; 5]. Thus, a device for analyzing the milk quality must contain an optical unit for diagnosing the medium being tested, which is milk. During milking system operation, milk should not be contaminated with any objects affecting its optical properties. For example, water entering the milk hoses disrupts the milk flow proportions. Keeping the internal surfaces of the milking system clean is necessary to ensure this condition. Milking systems provide a favorable environment for the growth of pathogenic microflora (including _S. aureus_ and _S. epidermidis_), which can cause significant damage to animal health and milk quality. Effective udder hygiene before milking is essential for the production of high-quality milk [6]. [PERSON] et al. conducted an extensive study on the prevalence and antimicrobial resistance of _S. aureus_[7]. Milk contaminated with _S. aureus_ causes poisoning and acute gastroenteritis, affecting food safety and human health. Reliable antimicrobial cleaning of milking equipment requires knowledge of the minimum number of organisms that can cause udder infections such as mastitis. It is necessary to know which animals are sources of infection in herds and transmit infection to lactating and non-lactating cows [8]. Bovine mastitisitis is dangerous because of its effect on the quantity and quality of milk yield [9]. For example, _Staphylococcus aureus_ strains, which are insensitive to many antibiotics, are currently considered the most dangerous causative agents of bovine mastitisitis [10]. About 60-70% of all antimicrobials used on dairy farms are used for the prevention and treatment of mastitisitis [11]. The common feature of all pathogenic cocci is their ability to cause purulent processes, so they are called pus-producing (pyogenic).