Protect Compass from interference

Hello, I have a question for you, I made a vtol vehicle before, but over time the compass of my pixhawk broke down, I bought a new one, but over time it also broke down, I solved this problem by turning off the data from the flight card and flying only with gps data, but I wonder How do you protect the Pixhawk from other equipment such as esc battery pdb and their cables that pass high current and create an electromagnetic field, is the compass not affected by them?

Read the blog post on how to methodically configure and tune ArduCopter