Hi,

I have got a LSM303DLHC sensor, it's giving out very accurate reading in term of heading, pitch and roll when sitting horizontally on the table. however, in the final product, the sensor needs to be mounted vertically onto a pole or somewhere else.

so here are my problems:

in terms of calculating the roll and pitch angle, what components should I be substituting into the formula in this scenario .

in term of calculating the heading angle, I have tried to used the formula of (atan2(megZ,megX)* 180/pi), it ended up giving out some wired reading .

Thanks