Skip to content

Improved Personal Compass

  • by

I found the personal compass project at Instructables.com quite interesting. Basically, a personal compass works like a regular compass, but instead of pointing to magnetic north, it points to a particular location of personal interest. Maybe it is pointing to the place where you were married, perhaps where your childhood home is.

All this compass magic is done using an Arduino with a compass (magnetometer) sensor, GPS module and a servo motor to point the way. However, there were a couple of things I didn’t like about the original project:

  • Extra gears were needed to increase the servo’s sweep to 360 degrees
  • Location was hard coded into the code

The extra gears complicated the build and it still had to “rewind” itself when it reached its 360 degree limit, so I decided to use a continuous servo with feedback. This allowed for full 360 degree rotation and beyond of the compass needle. The feedback wire is used to determine where the pointer is located so it can be positioned at the correct angle. The one drawback for the continuous rotation servo with feedback is that there are not that many available, and the only one I found required 5V to run, even with no load on the servo. So, I added a 3V to 5V booster module to get the servo to work with the 3V battery power.

To solve the hard coded position issue, I decided to go with an ESP32 based Feather processor from Adafruit, the HUZZAH 32. This processor includes WiFi and Bluetooth features. I didn’t really need the processor to connect to a WiFi network or Bluetooth, but its web server feature provided a way to save configuration settings like the location’s coordinates from a cell phone quite easily. While I was at it, I wanted to add a smart button feature.

My code for the improved personal compass and supporting applications can be found on GitHub.

The Smart Button

The ESP32, along with it’s ESP8266 sibling, has a deep sleep mode that can be used to programmatically power up and down the compass. This method does not fully power down the unit like a true power switch, but it shuts down most of the processor and the power drain is very low. So instead of incorporating an on/off switch I used a momentary switch for the project. This allows for greater flexibility and allows the switch to work in different ways depending on when and how long the button is pressed. I came up with these uses for the switch:

  • Short press – Use to turn the unit on or off. The unit actually enters deep sleep mode instead of being turned off. The Adafruit GPS module and Power Boost modules do not shut down by default when deep sleep mode is entered, so the enable pin on each module was used to send a signal to shut down just prior to entering deep sleep.
  • Long press during boot up – Use to define locations (using a web page from a smart phone)

We can also power down the unit automatically after a set period of time to conserve the battery.

The LED was programmed to blink while acquiring the GPS location, switching to steady on when the GPS location was found. It also blinks to indicate you have arrived at your destination (when you are within a specified zone radius of the destination), and when it is powering down.

 

The Build

Parts List

The Improved Personal Compass was built using the HUZZAH32 Feather (ESP32) and included the Feather Wing Tripler to incorporate 4 boards from the Adafruit Feather system.  This made the project modular and easy to test items individually.

Here is the parts list for this project:

 

Part Details URL
HUZZAH32 Feather (ESP32) Microprocessor https://www.adafruit.com/product/3405
Continuous Rotation w/Feedback Servo 5V motor https://www.adafruit.com/product/3614
Ultimate GPS FeatherWing GPS Module https://www.adafruit.com/product/3133
Magnetometer Board – LSM303 Magnetometer (compass sensor) https://www.adafruit.com/product/1120
PowerBoost 500 Basic 5V supply for servo motor https://www.adafruit.com/product/1903
Lithium Ion Polymer Battery – 3.7v 1200mAh Rechargable Battery https://www.adafruit.com/product/258
Feather Wing Tripler Main Prototyping Board https://www.adafruit.com/product/3417
FeatherWing Proto Board (quantity 2) Prototyping Boards for Magnetometer, PowerBoost, Servo pins, LED, Switch https://www.adafruit.com/product/2884
Compass Pointer Custom 3D Printed Pointer
16 mm Momentary Switch with LED (green) Smart switch with LED indicator https://www.adafruit.com/product/1440
Panel Mount Extension USB Cable USB Extension cable For Inside Box https://www.adafruit.com/product/3258
Micro USB Cable Micro USB Cable https://www.adafruit.com/product/592
Battery on/off switch (optional) To power down the device by removing battery power https://www.adafruit.com/product/3064
Wooden Box
1 220 Ohm Resistor For LED
2 10K Ohm Resistors For pull ups

 

Building It

You will find the code on Github at https://github.com/ZContent/Personal_Compass

The following pins on the HUZZAH32 were used for this project:

Pin A1 – Analog pin for feedback from the continuous rotation server
Pin 14 – Servo pin
Pin 33 – LED pin
Pin 15 – Button pin
Pin 27 – Enable pin for the GPS
Pin 12 – Enable pin for the PowerBoost chip

The Adafruit Feather system provided a modular way to build the project. I used a Adafruit Feather Wing Tripler to connect 4 board together. So, you are asking how did I connect 4 board with 3 connections? Well, I stacked two of them together, with the Ultimate GPS FeatherWing stacked on top of the HUZZAH32. Two FeatherWing proto boards were used to house the other electronics. One FeatherWing proto board contained the LSM303 magnetometer with leads for the smart switch and the LED. The other proto board contained the PowerBoost board and leads for the servo and the feedback wire.

Modules from top: Feather Wing tripler proto board, HUZZAH 32, Ultimate GPS feather wing with enable pin wire (blue wire), proto board with magnetometer and wiring for LED light and switch, proto board with Powerboost board and wiring for servo.

All modules assembled in box.

Final assembly with shielding.

One should keep in mind the servo contains magnets, so it is not a good idea to place the servo adjacent to the magnetometer board. I found this particularly true when using a small box. I added a sheet metal wall between the servo and the magnetometer for shielding, but I still found some interference. A bigger box will provide a greater distance between the servo and the magnetometer.

3D design of compass pointer

The compass pointer was designed in Fusion 360 and printed at Shapeways.

You can enter the personal compass settings from a smart phone, no hard coded location required.

Challenges

With all this greatness in using the ESP32, it is not without its hiccups. Adafruit recommends this chip for experience developers only. The processor is new and may not be supported with some libraries. I found this true in a couple of instances. For example, I found a bug in the I2C support in the ESP32 libraries. Fortunately, there was a patch available but it had not made its way yet into the official release.  Also, the standard Arduino servo library does not support the ESP32 (at least not yet). The good news is that someone has written an ESP32 specific servo library that matches the API calls of the Arduino servo library (see https://github.com/jkb-git/ESP32Servo ).

Use of a continuous rotation servo with feedback was a must for this project in order to allow full rotation of the compass pointer without a complicated gear setup. Unfortunately, there are very few motors on the market that provide both continuous rotation and feedback. Adafruit sells the Parallax Feedback 360° High Speed Servo. This servo was a bit overkill for my needs but I could not find any other smaller motors. It also required 5 volts, so an Adafruit Powerboost module was added to convert the 3V battery supply to 5V that the servo could use.

Interestingly, the magnetometer provided some of the most difficult challenges of the project. First, it was noticed the compass needle moved if the device was tilted slightly up or down or rolled clockwise or counterclockwise. Research was done to find an algorithm that would take tilt and roll into consideration when calculating the magnetic north direction. The algorithm uses acceleration data in addition to the magnetometer data to calculate the adjusted magnetic setting. Fortunately, the LSM303 chip used to retrieve the magnetometer data also has an accelerometer where this data can be retrieved. I still found some compass variations with tilt and roll with the new algorithm but it was less than the original algorithm.

The other issue with the magnetometer was magnetic interference from the servo motor. There are several magnets in the servo used to rotate the motor shaft and determining the position of the shaft using a Hall effect sensor. These magnets affected the sensor’s reading of magnetic north, which I could see changing as the compass needle rotated. I added  copper tape and a sheet metal wall between the sensor and the servo to help minimize the interference but a better idea would be to use a bigger enclosure where the servo and magnetometer are further away.

Improving the “Improved Personal Compass”

These ideas are not in the code but could be added for an improved “Improved Personal Compass”. With additional code, the device could handle multiple locations to avoid having to re-enter GPS coordinates for a shortlist of locations.  A long press of the button could act as a switch between locations. One could also add configuration settings to use the device as a compass to magnetic or true north instead of a GPS location.

 

Awas Melewatkan Cuan! Rahasia Pola Black Scatter untuk Pecahkan Rekor Kemenangan Hari IniCara Gila! Tingkatkan Akurasi Taruhan Roulette Lewat Teknik Fibonacci Anti-RugiCuan Meledak! Ini Dia Pola Scatter Mahjong Ways 2 yang Paling Nge-Hits Saat IniCuci Mata dan Kantong! Aksi Pemain Sukses Raup Cuan di Black ScatterDari Patah Hati Jadi Heart Attack! Kisah Pemain Sukses di Baccarat dengan Trik SederhanaGak Nyangka! Rumus Sederhana Ini Bikin Peluang Menang Parlay Naik 80%Hati-Hati! Kesalahan Kecil di Baccarat Bisa Bikin Anda Kehilangan Jackpot Besar!Jangan Lewatkan! 3 Sinyal Kemenangan di Mahjong Wins yang Jarang Diketahui Pemain LamaMahjong Wins 2 Dari Pemula Jadi Sultan! Ini 4 Jurus Jitu yang Wajib DikuasaiMenang Terus! Strategi Taruhan Roulette yang Bikin Dealer Sampai Geleng-GelengMode Gila! Simak Trik Menguasai Freespin di Black Scatter Tanpa Modal BesarNgaku Pecinta Gates of Olympus? Wajib Baca 5 Kesalahan Fatal Ini Sebelum Spin!Parlay Panas! Kombinasi Tim Ini Dijamin Bikin Dompet Mbledos Terbukti!Perhatikan Jam Main! Ini Waktu Terbaik untuk Menang di Gates of OlympusPeringatan Keras! Jangan Mainkan Mahjong Ways 2 Sebelum Baca 7 Petunjuk Ini!Roulette Bukan Sekadar Tebak Angka! Strategi Jitu Ini Bikin Meja BergetarScroll Berhenti! Spill Pola Scatter Mahjong Wins dari Grup Telegram Paling DipercayaSensasi Maxwin! Bocoran Pola Scatter Mahjong Ways 2 yang Bikin Saldo Nambah Nol!Turun Gunung! Eks Member Kasino Bagikan Pola Andalan di Mahjong Ways 2Viral! Pemain Ini Raup Cuan Besar di Gates of Olympus Hanya Modal 20 Ribu, Caranya?Catat Tanggalnya! Peringatan Kemenangan Besar di Black Scatter Akan Segera TerjadiCurhat Pro Player Cara Saya Konsisten Cuan dari Parlay Tanpa RibetHati-Hati Scatter Palsu! Kenali Perbedaan Scatter Asli di Mahjong WaysIni Dia! Tanda-Tanda Mesin Mahjong Wins 2 Siap Memberikan JackpotModal Uang Kembalian? Coba Trik Ini di Baccarat, Bisa Jadi Cuan Besar!Sering Kena Scatter? Itu Tanda Anda Salah Main, Coba Simak Strategi Gates of Olympus Ini!Stop! Jangan Spin Sebelum Tau Pola Scatter Gates of Olympus yang TerupdateTakut Kalah? Pakai Saja Trik Anti-Panas di Mahjong Wins 2, Dijaman Aman!Tingkatkan Level! Cara Jago Main Roulette Ala Pro Player Dalam Waktu SingkatTips Sakti! Menaklukkan Meja Roulette Hanya dengan 3 Putaran AwalBaccarat Panduan Membaca Tren Meja Jalan KemenanganBlack Scatter Analisis Tingkat RTP Return to Player dan PengaruhnyaBlack Scatter Teknik Mengelola Emosi Saat Lagi Hoki dan HancurMahjong Wins 5 Kesalahan Fatal yang Sering Dilakukan PemulaPanduan Lengkap Menemukan Pola Scatter Mahjong Ways 2 dari Hasil SpinParlay Memilih Liga dan Tim yang Tepat untuk Taruhan AndaRoulette Eropa vs Amerika Mana yang Lebih Menguntungkan?Roulette Strategi Martingale dan Dampaknya pada Modal AndaStrategi Taruhan Progresif di Baccarat Apakah Efektif?Tips Bermain Gates of Olympus dengan Modal Kecil dan Risiko MinimBaccarat Mengenal Sistem Taruhan Paroli untuk PemulaBlack Scatter Pentingnya Mengatur Batas Waktu dan Target BermainGates of Olympus Membedakan Antara Pola Gacor dan Pola BiasaGates of Olympus Peran Penting Multiplier dalam Kemenangan BesarMahjong Ways 2 Cara Membaca Simbol-Simbol Penting di Dalam GameMahjong Wins Mengoptimalkan Fitur Beli Freespin untuk KeuntunganMemahami Volatilitas Mahjong Ways 2 agar Tidak Cepat Kehabisan SaldoParlay Tips Mengkombinasikan Taruhan Over/Under dan 1X2Roulette Trik Sederhana Memanfaatkan Hot Numbers di Meja LiveTips Memilih Bettingan yang Tepat di Mahjong Wins untuk PemulaBaccarat Memahami Peran Banker dan Player dalam PeluangBaccarat Trik Flat Betting untuk Konsistensi KemenanganBlack Scatter Analisis Pola Kemunculan Simbol Wild dan ScatterBlack Scatter Cara Membaca Pola Putaran Sebelum Memulai Taruhan BesarGates of Olympus Panduan Bermain di Versi Mobile vs DesktopMahjong Ways 2 Rekomendasi Jumlah Spin yang Ideal untuk 1 SesiMahjong Wins Tips Ampuh Memanfaatkan Bonus New MemberParlay Mengerti Risiko dan Manfaat Taruhan Kombinasi Multi-TimParlay Panduan Bermain Saat Musim Turnamen untuk Hasil MaksimalRoulette Perbedaan Taruhan Dalam dan Luar serta ManfaatnyaBaccarat Tips Memilih Meja Berdasarkan Jumlah PemainBlack Scatter Panduan Awal Bagi yang Ingin Beralih dari MahjongGates of Olympus Mengatur Kecepatan Spin untuk Pengalaman Bermain TerbaikMahjong Ways 2 Panduan Daftar dan Mulai Main untuk Pemula AbsolutMahjong Ways 2 Panduan Menerapkan Stop Loss dan Take ProfitMahjong Wins Cara Mudah Memahami Fitur Wild dan FungsinyaMahjong Wins Strategi Jitu Menggabungkan Pola dengan Manajemen ModalParlay Memahami Pengaruh Cedera Pemain Terhadap Peluang KemenanganRoulette Memanfaatkan Fitur Statistik untuk Membantu Menentukan AngkaRoulette Pola Dasar yang Perlu Diketahui Sebelum BertaruhNge-Hits Abis! Pola Scatter Mahjong Ways 2 Ini Bikin Auto Banjir Cuan!Gates of Olympus Sedang Panas! Langsung Gas Pola Ini, Dijamin Scatter Berondong!Cuma 5 Menit! Pemula Ini Raup Puluhan Juta di Mahjong Wins, Kok Bisa?Viral Di Mana-Mana! Ini Pola Black Scatter Paling Brutal yang Lagi Dicari!Siap-Siap Kaget! Baccarat Bisa Bikin Kaya Mendadak Pakai Trik Satu Ini!Roulette Bergetar! Strategi Gila Ini Bikin Meja Loss Berkali-Kali!Parlay Gacor! Kombinasi 3 Tim Ini Wajib Dipasang Pekan Ini Terbukti!Jangan Spin Dulu! Baca 3 Sinyal Kematian di Mahjong Ways 2 Sebelum Main!Cuan Mengalir Deras! Spill Pola Scatter Mahjong Wins dari Admin Grup Sultan!Gates of Olympus Auto Maxwin! Pemain Ini Cuma Modal Receh, Hasilnya Meledak!Bongkar Rahasia! Black Scatter Ternyata Punya Jam Emas Kemenangan!Peringatan Keras! 5 Kesalahan Fatal di Baccarat yang Bikin Bangkrut!Roulette Bukan Tebak-Tebakan! Simak Formula Jitu Ini Biar Cuan Terus!Auto Penasaran! Pola Scatter Mahjong Ways 2 yang Bikin Streaming Ramai!Mahjong Wins 2 Dari Pemula Pro! Ini Lho 4 Jurus Andalan Anak Muda!Parlay Maksimal! Trik Menentukan Tim Kuda Hitam untuk Taruhan Anda!Gila! Black Scatter Kasih Freespin Terus, Pemain Sampai Speechless!Gates of Olympus Hati-Hati! Simbol Zeus Ini Pertanda Akan Jackpot!Baccarat Meja Panas! Terapkan Teknik Cut Ini, Musuh Langsung Ciut!Roulette Berbisik! Pelajari Angka Favorit Dealer Biar Menang Terus!
toto togel
bandar togel