فروشگاه آموزش پرینت 3D انجمن
  1. محمد نوروزی
  2. سنسور، ماژول و شیلد
  3. دوشنبه, 02 مهر 1397
  4.  اشتراک از طریق ایمیل
با سلام
در زمان استفاده از ماژول gy87 توسط i2c scanner این خطا را دریافت میکنم
HMC5883L connection failed

از لایبری hmc5883l هم استفاده کردم خطای عدم اتصال از طریق i2c رو میگیرم
HMC5883L connection failed
mag: 0 0 0 heading: 0.00
mag: 0 0 0 heading: 0.00
mag: 0 0 0 heading: 0.00
به این یحث رای دهید:
نظر
هیچ نظری هنوز ایجاد نشده است.
رضا پاسخ پذیرفته شده
محمد عزیز. به اینجا یک نگاهی بندازید:
https://forum.arduino.cc/index.php?topic=223345.0
نظر
هیچ نظری هنوز ایجاد نشده است.
محمد نوروزی پاسخ پذیرفته شده
متشکرم
ولی بی فایده است،
همه شناسایی میشن به جز قطب نما
شما تست کردین؟نتیجه گرفتید؟
نظر
هیچ نظری هنوز ایجاد نشده است.
محمد نوروزی پاسخ پذیرفته شده
کامل ترین کد برای ماژول به صورت زیر است و در لینک ارائه شده لایبری های آن نیز موجود هست،ولی باز قطب نما کار نکرد،چون ویدیو کار با این ماژول موجود است و با همین کد جواب میدهد قطعا سنسو 5883 مورد دارد.
/*
GY87_Readerv0.ino
This sketch is based on various sketches and libraries by Jeff Rowberg
<jeff@rowberg.net> and discussion thread by pistolero992000 on the Arduino forum
https://forum.arduino.cc/index.php?topic=223345.0. The BMP180 pressure
Senor library is from Love Electronics Ltd (loveelectronics.com)
http://embedded-lab.com/blog/bmp180/bmp180_11/

It gets all sensors on a GY87 IMU board reporting (something) to the
Serial. The challenge is the Digital Compass which is nromally blocked by
the Accelerometer. This is remedied by using an I2C bypass command. Thanks to
pistolero992000 for this solution.

Sensors on board the GY87 are:
MPU6050 Accelerometer. Address is 0x68
HMC5883L Digital Compass. Address is 0x1E
BMP180 Barometer and Temperature Sensor. Address is 0x77

Connections are through the i2c bus.

SCL to Arduino Pin A5
SDA to Arduino Pin A4
GND, 5V and 3.3V connections also present.

All sensors report sensible values. The tab seperated data covers a lot of screen space
so you will need to stretch your Serial monitor window to accommodate it.

*/

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
#include <BMP180.h> //Library for the BMP180 barometer.

//MPU6050 Accelerometer
MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

//HMC5883L Digital Compass
const int hmc5883Address = 0x1E; //0011110b, I2C 7bit address for compass
const byte hmc5883ModeRegister = 0x02;
const byte hmcContinuousMode = 0x00;
const byte hmcDataOutputXMSBAddress = 0x03;

//The BMP180 Digital Barometer
BMP180 barometer;
// Store the current sea level pressure at your location in Pascals.
float seaLevelPressure = 101325;

int LEDPin = 13;
bool blinkState = false;

int x,y,z; //triple axis data from HMC5883L.

void setup() {
Wire.begin();
Serial.begin(9600);

// initialize device
Serial.println("Initializing I2C devices...";);
accelgyro.initialize();

// verify connection
Serial.println("Testing device connections...";);
Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed";);
accelgyro.setI2CBypassEnabled(true); //This sets the bypass so the HMC5883L gets a look in.


//Initialise the Digital Compass
Wire.beginTransmission(hmc5883Address); //Begin communication with compass
Wire.write(hmc5883ModeRegister); //select the mode register
Wire.write(hmcContinuousMode); //continuous measurement mode
Wire.endTransmission();

//Initialise the BMP180 Barometer (and Temperature Sensor)
barometer = BMP180();
// We check to see if we can connect to the BMP180 sensor.
if(barometer.EnsureConnected())
{
Serial.println("Connected to BMP180.";);
// When we have connected, we reset the device to ensure a clean start.
barometer.SoftReset();
// Now we initialize the sensor and pull the calibration data.
barometer.Initialize();
}
else
{
Serial.println("No BMP180 sensor found.";);
}

// configure Arduino LED for
pinMode(LEDPin, OUTPUT);
delay(10000);
}

void loop() {

// read raw accel/gyro measurements from device
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

// these methods (and a few others) are also available
//accelgyro.getAcceleration(&ax, &ay, &az);
//accelgyro.getRotation(&gx, &gy, &gz);

// display tab-separated accel/gyro x/y/z values
Serial.print("a/g:\t";);
Serial.print(ax); Serial.print("\t";);
Serial.print(ay); Serial.print("\t";);
Serial.print(az); Serial.print("\t";);
Serial.print(gx); Serial.print("\t";);
Serial.print(gy); Serial.print("\t";);
Serial.print(gz); Serial.print("\t";);

// blink LED to indicate activity
blinkState = !blinkState;
digitalWrite(LEDPin, blinkState);

//Accessing the HMC5883L Digital Compass
//Tell the HMC5883L where to begin reading the data
Wire.beginTransmission(hmc5883Address);
Wire.write(hmcDataOutputXMSBAddress); //Select register 3, X MSB register
Wire.endTransmission();

//Read data from each axis of the Digital Compass
Wire.requestFrom(hmc5883Address,6);
if(6<=Wire.available())
{
x = Wire.read()<<8; //X msb
x |= Wire.read(); //X lsb
z = Wire.read()<<8; //Z msb
z |= Wire.read(); //Z lsb
y = Wire.read()<<8; //Y msb
y |= Wire.read(); //Y lsb
}

int angle = atan2(-y,x)/M_PI*180;
if (angle < 0)
{
angle = angle + 360;
}

//Reporting the Compass data to the Serial port
//Serial.print("Compass XYZ:\t";);
//Serial.print(x,y,z);Serial.print("\t";);
Serial.print("Dir(deg):\t";);
Serial.print(angle); Serial.print("\t";);

if(barometer.IsConnected)
{
long currentPressure = barometer.GetPressure();

// Print out the Pressure.
Serial.print("BMP180 P:\t";);
Serial.print(currentPressure);Serial.print("Pa";);Serial.print("\t";);

// Retrieve the current altitude (in meters). Current Sea Level Pressure is required for this.
float altitude = barometer.GetAltitude(seaLevelPressure);

// Print out the Altitude.
Serial.print("Alt:\t";);
Serial.print(altitude);Serial.print(" m";);Serial.print("\t";);

// Retrieve the current temperature in degrees celcius.
float currentTemperature = barometer.GetTemperature();

// Print out the Temperature
Serial.print("Temp:\t";);
Serial.print(currentTemperature);Serial.println("C";);
}
}
نظر
هیچ نظری هنوز ایجاد نشده است.
محمد نوروزی پاسخ پذیرفته شده
خروجی ماژول من

a/g: -776 25936 15204 -189 -18 102 Dir(deg): 0 BMP180 P: 100745Pa Alt: 48.23 m Temp: 24.90C
a/g: -840 25992 15096 -222 -4 107 Dir(deg): 0 BMP180 P: 100738Pa Alt: 48.40 m Temp: 24.90C
a/g: -776 25960 15236 -176 -28 90 Dir(deg): 0 BMP180 P: 100741Pa Alt: 48.49 m Temp: 24.90C
a/g: -760 25960 15228 -188 -26 91 Dir(deg): 0 BMP180 P: 100742Pa Alt: 48.15 m Temp: 24.90C
a/g: -852 26060 15032 -199 8 109 Dir(deg): 0 BMP180 P: 100741Pa Alt: 48.23 m Temp: 24.90C
a/g: -888 26064 15204 -184 -40 82 Dir(deg): 0 BMP180 P: 100742Pa Alt: 48.74 m Temp: 24.90C
a/g: -732 26008 15124 -207 -26 91 Dir(deg): 0 BMP180 P: 100750Pa Alt: 47.48 m Temp: 24.90C
a/g: -784 26124 15136 -205 -18 118 Dir(deg): 0 BMP180 P: 100741Pa Alt: 47.98 m Temp: 24.90C
نظر
هیچ نظری هنوز ایجاد نشده است.
رضا پاسخ پذیرفته شده
محمد جان، این یک مشکل رایج در استفاده ازاین ماژوله و در اون بحثی که لینکش رو فرستادم هم میبینید. اصولاً اولین قدم در استفاده ازهر ماژولی خوندن دقیق دیتاشیت اونه( که پیشنهاد میشه ). کدی که شما فرستادین ظاهراً مشکلی نداره و گام بعدی اتصالاته که باید بررسی بشه و مشکلات مربوط به خود ماژول در مرحله آخر قرار داره( معمولاً اتفاق نمیفته و
با توجه به رایج بودن این مشکل در اینجا بعیده ). توصیه میکنم دیتاشیت و لینک فروم آردوینو رودقیق مطالعه بفرمایید و اگرهنوز مشکل پابرجا بود ماژول دیگه‌ای رو تست کنید. موفق و پیروز باشید
نظر
هیچ نظری هنوز ایجاد نشده است.
محمد نوروزی پاسخ پذیرفته شده
توضیح کار با این ماژول مشخص است که در زیر آمده،(mpu.setI2CBypassEnabled(true); // set bypass mode // now we can reach hmc5883l)
از لحاظ ارتباط هم که بصورت I2c هست و gnd , vcc چیز خاص دیگری نیست،ولی متاسفانه قطب نما جواب نمیده برای من.

On the GY-87 board teh hmc5883l is located behind the MPU6050. So you have to activate a bypass mode in the MPU6050:

#include <Wire.h>
#include <MPU6050.h>
#include <hmc5883l.h>

MPU6050 mpu; // the mpu6050

hmc5883l compass; // Store our compass as a variable.


void setup()
{
Wire.begin();
mpu.begin(); // initalise MPU6050
mpu.setI2CBypassEnabled(true); // set bypass mode
// now we can reach hmc5883l
compass = hmc5883l(); // Construct a new HMC5883 compass.
...
نظر
هیچ نظری هنوز ایجاد نشده است.
  • صفحه :
  • 1


هنوز به این بحث پاسخی داده نشده است
مهمان
پاسخ شما
فایل ها یا عکس های لازم برای این بحث را از اینجا بارگزاری کنید، فرمت های قابل پشتیبانی: gif,jpg,png,zip,rar
• حذف آپلود فایل ها (بیشترین حجم فایل : 2 MB)
شما می توانید در پست خود رای گیری قرار دهید. رای گیری در پست شما نمایش داده خواهد شد.
تنظیمات رای دادن
به اشتراک گذاری مکان فعلی شما

اگر تمایل دارید که موقعیت جغرافیایی شما به اشتراک گذاشته شود از این بخش استفاده نمایید..

عرض جغرافیایی:
طول جغرافیایی:
کد امنیتی
این بخش برای امنیت سایت و تشخیص انسان از ربات ایجاد شده است.

تماس با ما
  • تلفن و صندوق صوتی: ۰۲۱۲۸۴۲۱۴۹۰

  • تلفن: ۰۲۱۹۱۰۳۵۳۸۱

  • فقط برای پیام تلگرام، بله و ایتا: 09120870443 

  • آدرس انبار: تهران، بزرگراه فتح (متوسلیان) شرق، بزرگراه باغستان، جاده گلگون، خیابان باغ، شهرک صنعتی گلگون، خیابان ششم جنوبی، پلاک 2

    کد پستی: 3359751646

  • ساعت کاری از 9 تا 17 شنبه تا چهارشنبه و پنجشنبه از 9 تا 13.

  • info [@] sanatbazar.com
  •  فعالیت فروشگاه بصورت اینترنتی می باشد لذا از مراجعه حضوری خودداری فرمایید.

©کپی رایت 2020-2016 | تمام حقوق برای صنعت بازار محفوظ است

گفتگو