Engorio.in
Home › Projects › Electronics › PoleStar — HMC5883L Digital Compass & Field Mapper

PoleStar — HMC5883L Digital Compass & Field Mapper

Electronics Intermediate ESP32 Arduino C++
PoleStar — HMC5883L Digital Compass & Field Mapper project banner

About this project

PoleStar turns an ESP32 and an HMC5883L 3-axis magnetometer into a precision digital compass — with zero sensor libraries. Every register is written manually over raw I2C: Config Register A is programmed for 8-sample averaging at 15 Hz, Config Register B selects the ±1.3 Gauss gain stage (1090 LSB/Gauss), and the Mode register switches the chip into continuous-measurement mode. On every read cycle the firmware performs a 6-byte burst read from address 0x03, reassembles three signed 16-bit integers (honouring the chip's unusual X–Z–Y byte order), and applies a hard-iron calibration offset computed by the built-in min/max method — the user rotates the board 360° for 60 seconds once to capture magnetic circle extremes, and the firmware stores the offsets in RAM for all future measurements. Calibrated X and Y field vectors feed atan2f to produce a heading angle, a user-configurable magnetic declination correction is added, and the result is mapped to eight compass points. A live animated SVG-style compass rose, six field-strength cards, and a one-click calibration button are served from the ESP32's Wi-Fi Access Point to any browser at 192.168.4.1. An SSD1306 OLED on the shared I2C bus shows heading, direction label, total field magnitude in µT, X/Y/Z in milli-Gauss, and live calibration countdown.

What you get

  • Complete, commented source code
  • Full components list with quantities
  • Pin-by-pin wiring guide and connection table
  • Step-by-step upload and testing guide
  • Project report (.docx, IEEE style)
  • Presentation slides (.pptx)

More Electronics projects

AquaRoot — Smart Soil Moisture Auto-Irrigation System

Beginner₹109

BatteryMind — 9V Internal Resistance Analyzer

Beginner₹109

CapMeter — RC Charge-Time Capacitance Meter

Beginner₹109

ChromaSnap — TCS3200 RGB Color Detection System

Beginner₹109

FreqBlade — Digital Frequency & Duty Cycle Analyzer

Beginner₹109

KnockCipher — Piezo Secret Knock Security System

Beginner₹109