Jump to content
I2Cdevlib Forums

Recommended Posts

 I'm writing code in Python onto a Raspberry Pi. I'm pulling gyro data well enough, it seems, but I'm attempting to write sensor fusion code for this device--which is rather new to me--so I'm trying to use the magnetometer also. I'm getting rather desperate to find out how to use this device because currently its output does respond to its position but is extremely erratic, even at rest, and the values are not very large (>250) and vary wildly. I cannot imagine how I could possibly use it to determine bearing with the way it is currently outputting data. I found a paper with formulas for sensor fusion but this is a major impasse at the moment.

Link to comment
Share on other sites

  • 4 weeks later...

It sucks doesn't it!  Much worse than a HMC5883

 

A simple low pass filter helps. If x,y hold the raw values and xf,yf  are global floats:

 

xf = xf - (xf / 24) + (float)x/180.0;

yf = yf - (yf / 24) + (float)y/180.0;

 

// not tilt compensated...

heading = atan2(xf / 24, yf / 24);

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...