A milking robot system (1) for milking of a dairy animal (2) with teats (3) comprises milking cups (12), a robot arm (11) for attaching the milking cups (12) to the teats (3), a teat detector (13) configured to detect the position of the teats (3), and a compressed air system (15) for providing dry compressed air to at least part of the milking robot system (1). The teat detector (13) comprises a housing (20) containing an optical sensor (21). The compressed air system (15) is operatively connectable with the inside of the housing (20) via an air line (18) in order to at least partly replace air which is present in the housing (20) by an amount of dry air from the compressed air system (15). This replacement operation may be performed directly, under pressure, or by first extracting air by means of an additional system and then replenishing it with dry air from the compressed air system (15). In this way, any moist air which may have penetrated in the housing (20) can be forced out in an efficient manner.