Bad altitude control after installing CX-OF optical flow sensor

Hello,
I built a 3" quadcopter with Matek F405 CTR, magnetometer, no GPS. After some tuning it flies very well in Stabilise and in Altitude Hold modes.

Then I added the CX-OF optical flow sensor. I connected and set it up as described in the documentation.
The problem is now that, it’s altitude control in Altitude Hold and in Flowhold has become very poor. The optic flow sensor works well. In Flowhold it clearly attempts to hold its position.
Apparently, the presence of the optical flow sensor disturbs the altitude control, even when it is not actively used.
On Mission Planner I see the message “EK2 IMU0 has stopped aiding”.
I also saw a post here where EK3 was mentioned in relationship to a similar problem.
I already changed the serial port : from Rx4 and Serial2 to Rx5 and Serial4. I also read in the specifications of the sensor (on Aliexpress) that the data baud rate is 19200. I changed the serial4 baud rate to this value. Nothing helps. When I disconnect the optical flow sensor, all is fine again.
Any idea what I can do?

I add a few graphs:

  1. flight with the CX-OF disconnected

  2. CX-OF connected, flight in Altitude Hold - so NOT Flowhold

Hi, I am glad that I was able to solve the problem.
In other posts I read about enabling and activating EKF3.
So I set
AHRS_EKF_TYPE=3
EK2_ENABLE=0
EK3_ENABLE=1
… and it works fine now!