In general, the operation of produced water treatment systems is often based on manual sampling, visual observations, operator judgment and manual tuning by operation of valves. Work has been conducted to automate the operation of a Compact Flotation Unit (CFU). The objective was mainly to reduce the overall amount of discharged of Oil-in-Water (OiW). As discharge peaks often govern the overall OiW percentage in discharge, a real-time operated and optimized CFU system could immediately detect and reduce the effect of such peaks. Furthermore, the waste generated and utility consumption should both be reduced. The CFU operation would not require operating personnel which is an absolute requirement for an unmanned installation or subsea operation. The work was conducted in a produced water test rig. Manual sampling and visual observations were successfully replaced with online analyzing- and flow measuring technology. This replacement ensured better process overview and allowed implementation of Integrated Operations (IO) philosophy. Advanced control algorithms for real-time CFU operation and optimization were developed based on implementation of this technology. The work has resulted in a new automatically operated CFU system. Testing in the produced water test rig met the goals: increasing OiW content was detected and effective corrective actions were taken without the need for operating personnel. In addition to reducing the OiW content, the waste generation and utility consumption were simultaneously minimized.