element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sensors
  • Technologies
  • More
Sensors
Sensor Forum Urgent - Need 3.3V tolerant Compass
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Sensors to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 5 replies
  • Answers 2 answers
  • Subscribers 342 subscribers
  • Views 1414 views
  • Users 0 members are here
  • quadcop_project
Related

Urgent - Need 3.3V tolerant Compass

screamingtiger
screamingtiger over 10 years ago

Cliffs:  Anyone know of a magnetic compass that works with the raspberry Pi, I2C and is 3.3V tolerant on the SDA/SCL?  It may need to be tilt compensated.  Please have first hand experience using it, I need it to work I cannot afford any more trial and error.  Thanks!

 

Details:

I've had some serious issues with my quadcop_project in terms of getting heading.  I've tried a mems sensor from xtrinsic but its not compatible via I2C with the Raspberry Pi 2.  It works fine with RPi B+. I digress.

 

I have an HCM5883L breakout and realized its not 5V tolerant, I think I burned it up and the data doesn't make any sense to me.  It is suppose to return a value between 0 and 255 but the registers are 16 bit with MSB and LSB being read independently.

https://www.sparkfun.com/products/10530

 

The examples from the Arduino don't make any sense.  Its really simple to use:

https://www.sparkfun.com/tutorials/301

 

You can see the values they are getting there.  A couple of odd things, the datasheet says it returns the data in 2 compliment form, which to me says I need to flip the bits but the sample code does not such thing. 

 

Regardless, I am not sure how to use this because it has 3 axis!  There is very little information on this board and no idea why I would want a 3 axis reading and how I would use that to calculate north.

  • Sign in to reply
  • Cancel

Top Replies

  • screamingtiger
    screamingtiger over 10 years ago in reply to shabaz +2
    A couple things: I bought 2 of these off ebay, one is bad!!! That keeps happening to me! The other thing is that it does not work with the raspberry PI. The arduino I am using now is 5V and it works with…
  • screamingtiger
    screamingtiger over 10 years ago +1
    BTW, After tinkiering some more I got it working with the raspberry pi directly using the wiringPi library. I am so glad I ordered two of these because one of them is way off and sends random data. The…
Parents
  • shabaz
    0 shabaz over 10 years ago

    Hi Joey,

     

    Don't you need it to have 3.3V logic levels (the RPI does not have 5V logic levels). What do you mean by 5V tolerant, do you expect the pull-up resistors on the I2C bus to be switched between 3.3V and 5V on the fly?

    or did you mean you wanted it to work with 5Vlogic levels?

    For level shifting, this link may be useful.

    However, I'm not sure that's what you need, since I don't understand the reason why 5V is mentioned, since both the RPI and the sensor you mention operate at 3.3V logic levels. For a better answer, could you explain this requirement in a little more detail?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • screamingtiger
    0 screamingtiger over 10 years ago in reply to shabaz

    I forgot the pins are 3.3V.  I thought they were 5V so any device it is using would need to be 5V tolerant, you can drop that requirement.  I mixed it up with my arduino.


    With so what I need is a digital compass that points north, gives degrees in 0-360 and fractional degrees.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • shabaz
    0 shabaz over 10 years ago in reply to screamingtiger

    I don't know of any sensor IC that will provide you with this single output, usually they will provide raw magnetic flux density values that need to be post-processed into the output that you need.

    The example the URL that you mention provides three such values (three axes). These three values can be converted (your microcontroller or raspberry pi etc., would be used for that).

    There is a honeywell document with the relevant calculations (PDF document).

    There may already be RPI implementations since that sensor seems quite popular, but if there isn't, there is an Adafruit guide for the HCM5883 that (according to the screenshots)

    shows that their code translates to a heading. It is for Arduino but the code can be examined (and compared to the honeywell doc).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • shabaz
    0 shabaz over 10 years ago in reply to screamingtiger

    I don't know of any sensor IC that will provide you with this single output, usually they will provide raw magnetic flux density values that need to be post-processed into the output that you need.

    The example the URL that you mention provides three such values (three axes). These three values can be converted (your microcontroller or raspberry pi etc., would be used for that).

    There is a honeywell document with the relevant calculations (PDF document).

    There may already be RPI implementations since that sensor seems quite popular, but if there isn't, there is an Adafruit guide for the HCM5883 that (according to the screenshots)

    shows that their code translates to a heading. It is for Arduino but the code can be examined (and compared to the honeywell doc).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • screamingtiger
    0 screamingtiger over 10 years ago in reply to shabaz

    A couple things:

     

    I bought 2 of these off ebay, one is bad!!!  That keeps happening to me!

    The other thing is that it does not work with the raspberry PI.  The arduino I am using now is 5V and it works with that, so apparently the pins need to be 5V?

     

    I used the adafruit example and it is giving me heading information as expected.  Thanks!  I am going to buy a real one from sparkfun and stop buy8ing knockoffs from ebay.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube