DIY Arduino Compass


406

4

4

I am a student studying engineering. Although I study mechanical engineering, I equally love elec...

We all know what a compass is and what is it used for. The compass tells us the directions i.e. E-W-N-S . Traditional compass worked with a magnetic needle in the middle. The needle's north pole always points towards earth's geographic north pole with is magnetic south.

The sensor I used MPU 9250 has a magnetometer which can measure the magnetic intensity along a given direction. I limited myself to X and Y axes only so simplify things a bit. Also as I mentioned in the video also, this project as an extension of the previous inclinometer project. Please have a look at the video and the article for the inclinometer. The links for provided are provided below.

LINK FOR YouTube

LINK FOR INSTRUCTABLES

Lets get started.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Watch the New Video

This video covers a bit of theory of magnets, magnetic fields and some vector algebra. As mentioned earlier, this is an extension of the previous project. Please watch the other video in the introduction.

Step 2: Components

The list of components is fairly straight forward. A simple arduino, (Nano in my Case), MPU 9250 IC, and an OLED display to output the data. As usual, having the monitor is not mandatory but thinking of a laptop eveytime you want to test a surface might be a bit absurd.

I got the MPU 9250 from Ali Express for about $3.5. This is not the cheapest IC but the noise levels were considerably lower. I highly recommend this IC. There's nothing special about the arduino or the wood. Arduino is a clone and works great.

The wood and leveling of IC is not as important as in the inclinoeter project.

You have some room for error. CHILLAX!!!!!!!!!

Step 3: The Structure.

For the main body, I took some simple square wood and cut it to a rough length of around 10cm. I then marked two holes in length of the IC. It is important that you fit the IC correctly. Also, if you do go wrond, please use some other side or even better, use another wood. Do not try to correct a missed hole. The screw may not hold good grip on such hole.

I then cut female headers on appropriate lengths and pasted them with two component adhesive. Once everything fit in place, I was pretty happy with the looks.

Step 4: Wire It All Up

With the I2C protocol, the wiring is always easy peezy.

I then started tinning the wires and the female headers. The wiring is very very simple.


SDA- A4

SCl- A5

Vcc- 5V

GND-GND

Make sure that the wiring connections are secure and proper. Make sure you used enough length of wire.

I made this mistake and trust me, it is very frustrating.

Step 5: Programming

There where the two twin project take on different paths.

The library is the same. Download the same library.

The GitHub link-

https://github.com/bolderflight/MPU9250

Having a look at the serial monitor, it was clear that the values were much more out of phase. I did some testing and finally could produce some decent sine function.

I have provided one of my excel sheets. Check it out if you are interested.

Sine wave is beautiful, isn't it?

Step 6: Enjoy the Project.

I you didn't get the repeating joke in my video, don't take this compass camping with you. Always use trusty instruments. for both reliability and ease of use.

Anyhow, I liked this project.

If you enjoyed, consider liking and subscribing to my instrutables and YouTube channels.

Thanks a lot.!

Build a Tool Contest

Participated in the
Build a Tool Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    4 Discussions

    0
    None
    HarshadB9Dave Mc

    Reply 6 months ago

    Hi friend,
    I checked the link you gave and seems like the IC is similar to TP4056 which I have a few.
    The problem is that the 4.2 V that you mentioned is the highest voltage a lipo battery can charge to. Those batteries will also drop their voltage as low as 2.5 V with which the Arduino, the OLED and the MPU would be uncomfortable. I have tested this and arduino would restart if voltage drops near to 4 V.
    So if you want to try, use a power bank circuit. That would work great

    0
    None
    audreyobscura

    6 months ago

    This is cool - could you recommend a battery you would add if you were to make it wireless?

    1 reply
    0
    None
    HarshadB9audreyobscura

    Reply 6 months ago

    Yeah! Thats actually a very good idea.
    The Arduino I used was a 5V one. So using a common lipo battery will require a boost converter.
    If you plan to add a battery, get yourself a 3.3V Arduino. But I doubt if the Oled display and the 9250 would work on 3.3V