What it is: The QMC5883L is a 3-axis magnetometer that senses the Earth's magnetic field, so you can compute a compass heading (0–360°). It's the chip on most "GY-271" breakouts sold today.
How it works: I2C device at address 0x0D. It reads magnetic field strength on X/Y/Z; the library turns X and Y into an azimuth (heading) in degrees. Shares SDA/SCL with the OLED.
Wiring (shared I2C bus with the OLED):
QMC5883L SDA -> GPIO4
QMC5883L SCL -> GPIO5
QMC5883L VCC -> 3V3
QMC5883L GND -> GND
OLED VCC=3V3, GND=GND, SDA=GPIO4, SCL=GPIO5
Libraries: "QMC5883LCompass" by MPrograms, plus "Adafruit SSD1306" and "Adafruit GFX Library".
On screen / Serial: heading in degrees (0 = North). Rotate the board flat and watch it track like a compass.
Gotchas: Older GY-271 boards use the HMC5883L chip (address 0x1E, different library) — check which you have. Keep it away from motors, speakers and metal, which distort the field. For accuracy, run the library's calibration by rotating the board through all orientations.