Magnetometer and Compass
Introduction
Magnetometers measure magnetic field. The electronic devices available are very sensitive, and can measure fields down to the 100 u-Gauss level. Since the earth magnetic field is roughly 0.6 Gauss, we can measure the earth magnetic field with a resolution of 1 part in 6000. Therefore, magnetometers can be used as compasses.
Several magnetometers are on the market and we use
The chips, even though pin compatible and coming on the same PCB (GY-271), are very different. Both use I2C as communication interface, but the I2C address and the registers are different.
On the photo of the GY-271 board, the HMC5883L is mounted. The QMC5883 is marked HA 5883.
The HMC5883L also comes on the GY-87 board, which combines the magnetometer with an accelerometer and a gyroscope on the MPU6050 and a BMP180 barometric pressure and temperature sensor. In this case, the HMC5883L is connected to the MPU6050 I2C bus and can be accessed either through the MPU6050 I2C master or directly through a bypass of the MPU6050 I2C master.
Connections
Here are the connection tables for the two boards
GY-87 |
!WeMos Pin |
GPIO |
Vcc_In |
5V |
|
3.3V |
nc |
|
GND |
GND |
|
SCL |
D1 |
22 |
SDA |
D2 |
21 |
FSYNC |
nc |
|
INTA |
D0 |
16 |
DRDY |
D3 |
17 on the ESP32-WROOM 27 on the ESP32-WROVER-B T7 V1.5 |
The magnetometer driver class
The magnetometer driver class can be found at
--
Uli Raich - 2022-08-24
Comments