Trouble connecting to GY-88A module

Hi,
I am trying to read 3 axis magnetic values from HMC5883L chip on the a GY-88A board.

I am using an Arduino MEGA 2560 connected to the GY-88A module like this:
MEGA -- GY-88A
3V -- 3V#
5V -- VIN
A4 -- SDA
A5 -- SCL

I tried the "Arduino\libraries\HMC5883L\examples\HMC5883L_raw\HMC5883L_raw.ino" example program, it outputs "HMC5883L connection failed".

It's a bit frustrating. I can not find any examples of usage of the GY-88A online.

Welcome to the forum

You are using the wrong pins

Below is a table that lists the different board form factors and what pins are for I2C.

Form factor SDA SCL SDA1 SCL1 SDA2 SCL2
UNO SDA/A4 SCL/A5
Nano A4 A5
MKR D11 D12
GIGA D20 D21 D102 D101 D9 D8
Mega & Due D20 D21

Thanks for the quick reply!
I tried this, but with the same result.
Perhaps my GY-88A is toasted?
The green led on the GY-88A lights up permanently.

Please post your sketch, using code tags when you do. Are you sure that you have connected the pins the right way round ?

My sketch is here. I commented out the reading, since mag.testConnection() returns false anyway.

// I2C device class (I2Cdev) demonstration Arduino sketch for HMC5843 class
// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
//     2011-10-07 - initial release

/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2011 Jeff Rowberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"

// I2Cdev and HMC5843 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 "HMC5843.h"

// class default I2C address is 0x1E
// specific I2C addresses may be passed as a parameter here
// this device only supports one I2C address (0x1E)
HMC5843 mag;

int16_t mx, my, mz;

#define LED_PIN 13
bool blinkState = false;

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

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(38400);

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

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(mag.testConnection() ? "HMC5843 connection successful" : "HMC5843 connection failed");

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

void loop() {
    // 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.println(mz);

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

Don't connect anything to the 3V3 pin

Same with 3V3 disconnected.

The above sketch outputs:

Initializing I2C devices...
Testing device connections...
HMC5843 connection failed

Try running the I2C_scanner sketch.
It's located under files->examples-->wire

Hi Jim,

Thanks, tried that and got:
Scanning...
I2C device found at address 0x30 !
I2C device found at address 0x68 !
I2C device found at address 0x77 !
done

Then I tried using all three adresses, none of them worked
I changed the constructor of the HMC5843 to the following three and made three tests:
HMC5843 mag(0x30);
HMC5843 mag(0x68);
HMC5843 mag(0x77);

They all says: "HMC5843 connection failed"

0x77 is the BMP085
0x68 is the MPU6050
0x30 is ??

The address of the HMC5843 is 0x1E. So it was not found by the scanner.
Not sure what is wrong.

When I do a google searsh for "GY-88A" I get zero hits. Plenty for "GY-88"
Do you know if there is a difference?

Yes, the same here. Can't really find any info for "GY-88A", except from where I bought it.

Product Description:

The original GY-88 has been discontinued

New: GY-88A

GY-88A vs. GY-88

The same size, the same interface, the software does not need to be modified, the chip is also a new imported original,
Yes, there is no difference between using direct replacement.
The GY-88 chip is :MPU6050+HMC5883+BMP085
The GY-88A chip is : MPU6050+HMC5983+BMP180

10DOF module (triaxial gyro + triaxial acceleration + triaxial magnetic field + pressure)

Using gold sink PCB process

Using the chip: MPU6050+HMC5983L+BMP180

Power supply: 3-5v

Communication method: IIC communication protocol (completely compatible with 3-5v system, including LLC circuit)

Size: 2.2cm*1.7cm

10DOF IMU MPU6050 HMC5883L BMP085 Arduino accel gyro baro mag gy-88 uno mega due
3.3-5v compatible.

MPU 6050 Motion Sensor module: 3-axis gyroscope, 3-axis accelerometer
HMC5983L module (three-axis magnetic field module)
BMP180 barometer pressure sensor
Chip: MPU-6050
Power supply: 3v-5V power
Gyroscope range: + 250 500 1000 2000 °/ s
Acceleration range: ± 2 ± 4 ± 8 ± 16 g
HMC5983L: Measuring range: ± 1.3-8 Gauss.

Just an quick update. I bought a " 3 Axis Electronic Compass Magnetometer Sensor Module" from here:

The HMC5883L sensor on this works like a charm. I will throw the other 10 axis board in the trash...

Yeah, sometimes you get a bad one.

Yes Jim, just the frustrating attempts. Luckily, the sensors are cheaper than a beer at the local pub :wink:

I ran a slightly modified version of "Arduino\libraries\HMC5883L\examples\HMC5883L_raw\HMC5883L_raw.ino", where I get the min/max of the three axis.

This is what I ended up with, last numbers in brackets are [min;max] values of mx, my and mz respectively, after tumbling the sensor arround il all axis.

mag: -250 -479 486 heading: 242.44 [-831;762] [-1231;335] [-893;650]

// I2C device class (I2Cdev) demonstration Arduino sketch for HMC5883L class
// 10/7/2011 by Jeff Rowberg <jeff@rowberg.net>
// Updates should (hopefully) always be available at https://github.com/jrowberg/i2cdevlib
//
// Changelog:
//     2013-05-04 - Added Heading Calculation in degrees
//     2011-10-07 - initial release

/* ============================================
I2Cdev device library code is placed under the MIT license
Copyright (c) 2011 Jeff Rowberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================
*/

// Arduino Wire library is required if I2Cdev I2CDEV_ARDUINO_WIRE implementation
// is used in I2Cdev.h
#include "Wire.h"

// I2Cdev and HMC5883L 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 "HMC5883L.h"

// class default I2C address is 0x1E
// specific I2C addresses may be passed as a parameter here
// this device only supports one I2C address (0x1E)
HMC5883L mag;

int16_t mx, my, mz;

//  for calibration
#define INT16_MIN (-32768)
#define INT16_MAX 32767
int16_t mx_min, my_min, mz_min;
int16_t mx_max, my_max, mz_max;

#define LED_PIN 13
bool blinkState = false;

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

    // initialize serial communication
    // (38400 chosen because it works as well at 8MHz as it does at 16MHz, but
    // it's really up to you depending on your project)
    Serial.begin(9600);

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

    // verify connection
    Serial.println("Testing device connections...");
    Serial.println(mag.testConnection() ? "HMC5883L connection successful" : "HMC5883L connection failed");

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


    mx_min = INT16_MAX;
    my_min = INT16_MAX;
    mz_min = INT16_MAX;
    mx_max = INT16_MIN;
    my_max = INT16_MIN;
    mz_max = INT16_MIN;
}

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

    mx_min = min(mx_min, mx);
    my_min = min(my_min, my);
    mz_min = min(mz_min, mz);

    mx_max = max(mx_max, mx);
    my_max = max(my_max, my);
    mz_max = max(mz_max, 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.print(heading * 180/M_PI); Serial.print("\t");

    //  min/max values for calibration
    Serial.print("["); Serial.print(mx_min); Serial.print(";"); Serial.print(mx_max); Serial.print("]\t");
    Serial.print("["); Serial.print(my_min); Serial.print(";"); Serial.print(my_max); Serial.print("]\t");
    Serial.print("["); Serial.print(mz_min); Serial.print(";"); Serial.print(mz_max); Serial.print("]\t");
    Serial.println();

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

void loop1() {
    // 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);

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

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.