Smart measurement and regulation of flow of liquids