This research paper deals with the option of automating wastewater treatment in an oil refinery. We have studied the stages of processing where wastewater is polluted and from this, we have identified the characteristics of its composition as well as the characteristic pollutants. In the course of the work, methods of wastewater treatment were investigated. Emphasis was placed on biological treatment in a variable reactor, the operation principles of this system and its superiority over standard biological treatment were examined. To sum up all the information studied, we have designed and presented in the paper an automated wastewater treatment scheme for an oil refinery using SBR technology. It includes a flotation tank, SBR reactor, sand filter and chlorination tank. Floating foam, sludge and excess active sludge are proposed to be thickened, pressed, and unloaded into containers for further sale. © 2022 American Institute of Physics Inc.. All rights reserved.