Post Top Ad

Friday, April 14, 2023

on video How to easily use HMC5883L Compass Sensor


 Wiring and Test

This 3-axis magnetometer breakout is thankfully very easy to use. It only requires 2 power pins and 2 data pins.

We'll be demoing it with an Arduino but any other microcontroller can be used if you are willing to port the I2C code. We suggest using an Arduino to start since its guaranteed to work


Connect VIN to 5V pin on the Arduino. If you have a 3V logic Arduino, connect VIN to 3V instead

Connect GND to the ground pin on the Arduino

Connect the SDA pin on the breakout to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2

Connect the SCL pin on the breakout to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3

The HMC5883L has a fixed I2C address, you can only connect one sensor per microcontroller!

Download & Install Libraries

Lucky for you we have written a very nice sensor library for the HMC5883L, which is based off of our Adafruit_Sensor framework library.


 Wiring and Test

This 3-axis magnetometer breakout is thankfully very easy to use. It only requires 2 power pins and 2 data pins.

We'll be demoing it with an Arduino but any other microcontroller can be used if you are willing to port the I2C code. We suggest using an Arduino to start since its guaranteed to work


Connect VIN to 5V pin on the Arduino. If you have a 3V logic Arduino, connect VIN to 3V instead

Connect GND to the ground pin on the Arduino

Connect the SDA pin on the breakout to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2

Connect the SCL pin on the breakout to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3

The HMC5883L has a fixed I2C address, you can only connect one sensor per microcontroller!

Download & Install Libraries

Lucky for you we have written a very nice sensor library for the HMC5883L, which is based off of our Adafruit_Sensor framework library.

No comments:

Post a Comment

Post Top Ad

Pages