I am working on a project with Raspberry Pi with display, ESP32 with a couple of sensors and an output relay. The basic circuit diagram is shown in the figure below.
Now coming straight to the problem. ESP reads the sensors and sends the data to the RPI. it displays the sensor reading in the display live. the sensors consist of a pulse meter based flow sensors and a couple of analog sensors.those part are working fine. Now the esp has some rule engine running inside it, by which it turns on and off a motor. the Motor is a half HP induction diaphram pump.it starts ok. but when the esp shuts it down the display of my raspberry pi turns off and come back on in 2 seconds. It is not turning off the Pi or the esp32, but just gets the display off and on. I tried out various work arounds I can just get to know, like adding a EMI filter as shown in the figure. I am driving the relay via a optocoupler to isolate it from the main circuit. Then I connected my DSO to the 5V SMPS power supply. and found that there is a noise getting injected to the 5V Rail when the motor is turned off. Suprisingly it doesnt happen when the motor is turned on. Figure below will be a pic of the noise i saw across my 5v supply.
I am guessing that noise is causing the problem.
How to prevent this noise from affecting my display? I am sure it might be affecting my raspberry pi too.
EDIT: The EMI filter I am using is shown below and data sheet of the filter is here


