Introduction: DIY Arduino Compass
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.
Lets get started.
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.
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-
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.!
Participated in the
Build a Tool Contest