센서 > Triple Axis Magnetometer HMC5883L + Arduino

TODAY799 TOTAL2,229,357
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | 센서 | 자이로센서 | Triple Axis Magnetometer HMC5883L + Arduino

페이지 정보

작성자 키트 작성일2017-08-22 14:29 조회1,515회 댓글0건

본문

 

 

 

One of the first articles we did was on the hmc6352 digital compass. Well this is his older brother (or younger but smarter). I really don’t know what to say about the HMC5883L other than it is a three axis magnetometer, so it is capable of sensing in 3 directions.

 

That doesn’t mean that it is tilt compensated, because you really don’t know how it is orientated when the reading comes in. For that, you would need to combine this with an accelerometer to do that. But this can get you one step closer. If you are looking at using this as a digital compass, make sure to read the following section.

Magnetic Declination

 

Something I found interesting and obvious once I thought about it, is that all compasses point to magnetic north, and not true north. The difference between them is called Magnetic declination. And how much they vary depends on where you are, and… when it is, because as weird as it is, it changes over time (awesome animation of that). You can look up your Magnetic declination here.

 

Hooking it up

Hooking you HMC5883L up to your arduino is pretty simple. The HMC5883L is an I2C device, a type 2-wire serial connection, so we just need to connect the SDA (Data) and SCL (Clock) lines to your Arduino for communication. On your Arduino (everything but the mega) SDA is on analog pin 4, and SCL is on analog pin 5. On an arduino mega, SDA is digital 20, and SCL is digital 21. (The Arduino Leonardo will also be different). Other than these 2 lines, we just need to connect power(3.3v), ground and we are all set.

Code

The code for the HMC5883Lis a bit more complex than his single-axis brother, and the readings from it come in a few different forms, so we will be using a library to achieve this.

To make this code work, before you load the code, or even open the Arduino program, we need to place the “HMC5883L” folder into your Arduino Library. If you don’t know where that is by default, Look to the right.

If you click the download button to the right of “Arduino” you can download the whole thing as a zip, so you dont need to copy all the files.

 

http://bildr.org/2012/02/hmc5883l_arduino/

 

댓글 0

조회수 1,515

등록된 댓글이 없습니다.

센서HOME > 센서 > 자이로센서 목록

게시물 검색

2022년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2021년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2020년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2020
모바일버전으로보기