Use an ATtiny85 to Build Your Own Electronic Compass

Find your way out of the wilderness and back to camp with this DIY compass.

Cameron Coward
2 months ago3D Printing / Displays / Sensors

A microcontroller is a small integrated circuit (IC) chip that contains process, memory, and input/output (IO) pins. Almost every electronic device on the market contains at least one microcontroller, and as a result there are a lot of different models available from many manufacturers. The Microchip ATtiny85, which was originally made by Atmel, is special because it’s small, affordable, requires little power, and is very versatile. If you don’t need many IO pins or a lot of processing power, the ATtiny85 is for you. Raul7321 used it to build a small electronic compass, and has shared a tutorial explaining how you can make your own.

This electronic compass is roughly the size of a typical analog pocket compass. That analog compass is probably more practical, as it doesn’t require a battery and is less likely to break. But Raul7321’s project does a great job of demonstrating the appeal of the ATtiny85. In addition to the AVR chip (the through-hole version), this project calls for an HMC5883L magnetometer, a 0.96” SSD1306 128 x 64 I2C OLED screen, and a 3.7V 300mAh LiPo battery. You’ll also need a 3D printer to fabricate the enclosure.

To flash Raul7321’s code to your ATtiny85, you’ll need either a dedicate AVR programmer or something like an Arduino Uno to act as a programmer. After flashing that code, you can assemble the circuit. The MCU receives directional information from the magnetometer. That information is then displayed on the OLED display. As is, the code shows the approximate vectors to the cardinal directions as well as a readout with the actual degrees of the North vector. You can, however, modify the code to display that information in whatever way makes the most sense to you. We recommend an analog compass if you’re actually heading into the wilderness, but this is a fun project to learn how to work with the fabulous ATtiny85.

Related articles
Sponsored articles
Related articles