HMC5883L magnetometer problem

It seems that I have created an electromagnet with all the wires I have connected to the arduino and a breadboard. I moved the magnetometer farther away and the problem isnt as bad but It still makes the device fairly unusable. Can anyone explain to me how I can (easily) calibrate the mag so as to compensate for the electromagnetic field?