Calibrating Accelerometer and Magnetometer

Hi,

I have an Arduino Mega 2560 with a Breadboard, along with a 10DOF sensor.

I am using the ADXL345 and HMC5883L.

I am not new to programming, but am new to Arduinos, and sensor based programming. Within the current sketch, I have the the 10DOF sensor mounted horizontally/parallel to the breadboard on the desk I am working on. I have sensor data being read into the sketch, but I am unsure on how to calibrate my sensors, specifically the Magnetometer.

Accelerometer is fairly simple, assuming gravity isn't too eccentric where you are. Magnetometer is trickier, and depends where you are. One method is to rotate the device slowly in all three axes, and work out the vector of the strongest response. Code is available on the Web, but if you get stuck, PM me, and I may be able to help.

Edit: Or, have a look at the LSM303/LSM303DLH libraries