에듀이노-코딩교육 전문 쇼핑몰 에듀이노-코딩교육 전문 쇼핑몰

학교, 공공기관이라면 후불결제하세요!

 
현재 위치
  1. 게시판
  2. 묻고답하기

묻고답하기

기술문의 게시판입니다.

게시판 상세
제목 GY-801 기술문의
작성자 최중혁 (ip:)
  • 작성일 2019-12-05
  • 추천 추천하기
  • 조회수 85

GY-801 에 포함되어있는 HMC5883L 센서가 인식을 못하고 있습니다.

현재까지 4개의 제품으로 테스트를 해보았고 모두 동일하게 인식이 되지 않았습니다.

좀 더 확인해본결과 HMC5883L.h의 경우 address를 0x1E 로 설정되어있음과 달리 실제로 i2c 확인한 결과 0x30 으로 인식을 합니다. 그래서 단순히 헤더파일을 수정하면 원하던 값이 나오지 않습니다.


코트는
#include "Wire.h"

// I2Cdev and ADXL345 must be installed as libraries, or else the .cpp/.h files
// for both classes must be in the include path of your project
#include "I2Cdev.h"
#include "ADXL345.h"
#include "L3G4200D.h"
#include "BMP085.h"
#include "HMC5883L.h"

// accel
ADXL345 accel;
int16_t ax, ay, az;

// gyro
L3G4200D gyro;
int16_t avx, avy, avz;

// baro
BMP085 baro;
float temperature;
float pressure;
float altitude;
int32_t lastMicros;

// magneto
HMC5883L mag;
int16_t mx, my, mz;

#define LED_PIN 0 // (Arduino is 13, Teensy is 6)
bool blinkState = false;

void setup() {
    // join I2C bus (I2Cdev library doesn't do this automatically)
    Wire.begin();

    // initialize serial communication
    Serial.begin(9600);

    // initialize device
    Serial.println("Initializing I2C devices...");
    accel.initialize();
    gyro.initialize();
    baro.initialize();
    mag.initialize();

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(accel.testConnection() ? "ADXL345 connection successful" : "ADXL345 connection failed");
    Serial.println(gyro.testConnection() ? "L3G4200D connection successful" : "L3G4200D connection failed");
    Serial.println(baro.testConnection() ? "BMP085 connection successful" : "BMP085 connection failed");
    Serial.println(mag.testConnection() ? "HMC5883L connection successful" : "HMC5883L connection failed");

    // configure LED for output
    pinMode(LED_PIN, OUTPUT);

    gyro.setFullScale(2000);
}

void loop() {

    accelerometer();
    gyroscope();
    barometer();
    // blink LED to indicate activity
    blinkState = !blinkState;
    digitalWrite(LED_PIN, blinkState);

    // delay 100 msec to allow visually parsing blink and any serial output
    delay(1000);
}

void accelerometer(){
    // read raw accel measurements from device
    accel.getAcceleration(&ax, &ay, &az);

    // display tab-separated accel x/y/z values
    Serial.print("accel:\t");
    Serial.print(ax); Serial.print("\t");
    Serial.print(ay); Serial.print("\t");
    Serial.println(az);
}

void gyroscope(){
    gyro.getAngularVelocity(&avx, &avy, &avz);

    Serial.print("angular velocity:\t");
    Serial.print(avx); Serial.print("\t");
    Serial.print(avy); Serial.print("\t");
    Serial.println(avz);  
}

void barometer(){
    // request temperature
    baro.setControl(BMP085_MODE_TEMPERATURE);

    // wait appropriate time for conversion (4.5ms delay)
    lastMicros = micros();
    while (micros() - lastMicros < baro.getMeasureDelayMicroseconds());

    // read calibrated temperature value in degrees Celsius
    temperature = baro.getTemperatureC();

    // request pressure (3x oversampling mode, high detail, 23.5ms delay)
    baro.setControl(BMP085_MODE_PRESSURE_3);
    while (micros() - lastMicros < baro.getMeasureDelayMicroseconds());

    // read calibrated pressure value in Pascals (Pa)
    pressure = baro.getPressure();

    // calculate absolute altitude in meters based on known pressure
    // (may pass a second "sea level pressure" parameter here,
    // otherwise uses the standard value of 101325 Pa)
    altitude = baro.getAltitude(pressure);

    // display measured values if appropriate
    Serial.print("T/P/A\t");
    Serial.print(temperature); Serial.print("\t");
    Serial.print(pressure); Serial.print("\t");
    Serial.print(altitude);
    Serial.println("");
}

void magneto(){
   // read raw heading measurements from device
    mag.getHeading(&mx, &my, &mz);

    // display tab-separated gyro x/y/z values
    Serial.print("mag:\t");
    Serial.print(mx); Serial.print("\t");
    Serial.print(my); Serial.print("\t");
    Serial.print(mz); Serial.print("\t");

    // To calculate heading in degrees. 0 degree indicates North
    float heading = atan2(my, mx);
    if(heading < 0)
      heading += 2 * M_PI;
    Serial.print("heading:\t");
    Serial.println(heading * 180/M_PI);
}

입니다.

게시글 신고하기

신고사유

신고해주신 내용은 쇼핑몰 운영자의 검토 후 내부 운영 정책에 의해 처리가 진행됩니다.

평점 0점
첨부파일 Snap1005.jpg
비밀번호 수정 및 삭제하려면 비밀번호를 입력하세요.
댓글 수정

비밀번호 :

수정 취소

/ byte

비밀번호 : 확인 취소

댓글 입력

댓글달기이름 :비밀번호 : 관리자답변보기

확인

/ byte

왼쪽의 문자를 공백없이 입력하세요.(대소문자구분)

에게만 댓글 작성 권한이 있습니다.

댓글 입력

댓글달기이름 :비밀번호 :

확인

/ byte

왼쪽의 문자를 공백없이 입력하세요.(대소문자구분)

에게만 댓글 작성 권한이 있습니다.

«
»