It might help to show us a wiring diagram of your setup. Without it we have no chance to know what that sketch should do.
And explain why the sketch includes code for 5 3-axis magnetometers. The sketches you post should be the minimal sketch to reproduce the error. So are the 5 magnetometers necessary?