The GY-26 Compass sensor module

Hi. anyone who has any experience with the GY-26 digital compass sensor module....
having a hard time finding something usefully anywhere.
starting to think it was a bad idea buying one of these.

Anyone with any info will be highly appreciated. :slight_smile:

best regards...

starting to think it was a bad idea buying one of these

Why?

Nesredna:
Hi. anyone who has any experience with the GY-26 digital compass sensor module....
having a hard time finding something usefully anywhere.

No experience but it looks fairly simple:

[http://www.elechouse.com/elechouse/images/product/GY-26-USART%20Digital%20Compass/gy-26%20manual.pdf](http://"http://www.elechouse.com/elechouse/images/product/GY-26-USART Digital Compass/gy-26 manual.pdf")

Hi,
I was just ordering this module....

Using it in IIC mode, how would I get compass reading.
I mean it sais in the manual that reading 0x01 address gives the 8bit HIGH of the angle and address 0x02 gives the low 8bits
So how do I translate this into real degrees??

Is the output in steps of 0.1 or 0.01 degrees per bite or what (since serial response is in 0.1deg resolution) ? the manual is somwhat unclear on I2c response and only shows what to write to get response...
Do I need to map UART (serial) response against I2c response to decode this?

The program provided by drix at:
http://iteadstudio.com/iforum/viewtopic.php?f=16&t=1963&p=9229#p9229
is sufficient to talk to the compass. It also prints the first three bits from the compass' measurement, of which only the second and third bits are meaningful. HOWEVER, the compass reading stays the same. The three bits output appears as 0 239 239 over and over again. The calculated angle is then -411, and that doesnt change either. Nothing changes no matter what angle the compass is when it is started or while the program is running. I tried a few program variations but nothing seems to work. I really need this to work because my project is due in a few weeks. PLEASE HELP ME.Butchman2000

Posts: 1
Joined: Tue Jan 10, 2012 8:21 pm

Butchman2000:
It also prints the first three bytes from the compass' measurement, of which only the second and third bits are meaningful. HOWEVER, the compass reading stays the same. The three bytes output appears as 0 239 239 over and over again.

That is very strange. The value 239 (decimal) will not fit in a byte. The code actually shows the values are displayed in HEX so 0x239 is 569 which is WAY too big to fit in a byte. You also don't show the part where is prints "Received angle: ". Perhaps you copied and pasted the code incorrectly?

The value 239 (decimal) will not fit in a byte.

Wuh?

Hello everyone.

Im new here. I just got the gy-26 compass and i connected it to a usb->rs232 converter. Im using a common comport transmitter to send data to my compass. When I send C0 as hex the led does turn on so it means im in calibration mode. Thats fine

But after i get out of calibration mode i try to send 31 as hex and i get nothing back accept for a 31hex back. I cannot get any readings from it. I connected everything directly without any use of capacitors etc etc. All gnd together and both vcc together. Ok like that?

Appreciate your help.
Thanks

someone already managed to put it to work?

Hello, here's an example of the code in this link, serial connection Página padrão

Nesredna:
Hi. anyone who has any experience with the GY-26 digital compass sensor module....
having a hard time finding something usefully anywhere.
starting to think it was a bad idea buying one of these.

Anyone with any info will be highly appreciated. :slight_smile:

best regards...

Do you have a sample code including library for a digital compass ? Or do anyone else have ?? I also have trubble to find a sample code.

What compass sensor is on the board? QMC5883L HMC5883? There are LOTS of examples for those sensors!

rmvansomeren:
What compass sensor is on the board? QMC5883L HMC5883? There are LOTS of examples for those sensors!

Some references say it is an "HMC1022" but the Honeywell HMC1022 is just the sensor part of a compass and doesn't do serial or I2C I/O. Perhaps there is a chip that is called an HMC1022 that is NOT the Honeywell HMC1022.
The elechouse.com manual (link above) says that in I2C-mode it is read like a 24C04 I2C EEPROM for which there are likely even more libraries available.

rmvansomeren:
What compass sensor is on the board? QMC5883L HMC5883? There are LOTS of examples for those sensors!

I'm sorry for answering so late. As Johnwasser said, it has a Honeywell HMC1022 Sensor. Could you please help me to get a code ? Or at least show me a good understandable Video for "how communicate with I2C".

The manual says that you read it like a 24C04 I2C EEPROM. If they use the default address of 0x28, this sketch should display the contents of the 8 registers.

#include <Wire.h>


const byte ChipAddress = 0x28;


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


  // Send the read address
  Wire.beginTransmission(ChipAddress);
  Wire.write(0);  // Start reading at memory address zero
  Wire.endTransmission();


  // Request 8 bytes of data
  Wire.requestFrom(ChipAddress, (byte)8);


  // Display the 8 bytes of data
  for (byte address = 0; address < 8; address++)
  {
    Serial.print("Address ");
    Serial.print(address);
    Serial.print(" contains 0x");
    Serial.println(Wire.read(), HEX);
  }
}


void loop() {};

If the results show this, the chip is at another address (probably in the range 0x29 through 0x2F) or is not wired correctly.

Address 0 contains 0xFFFFFFFF
Address 1 contains 0xFFFFFFFF
Address 2 contains 0xFFFFFFFF
Address 3 contains 0xFFFFFFFF
Address 4 contains 0xFFFFFFFF
Address 5 contains 0xFFFFFFFF
Address 6 contains 0xFFFFFFFF
Address 7 contains 0xFFFFFFFF

If you get something other than F's, show us the data and maybe we can make some sense out of it.

Try while pointing the compass SOUTH so we expect a heading around 180°. If you point it NORTH it's hard to say if the value should be near 360 or near 0.

@johnwasser I've just tried it... as you said, it has shown:

Address 0 contains 0xFFFFFFFF
Address 1 contains 0xFFFFFFFF
Address 2 contains 0xFFFFFFFF
Address 3 contains 0xFFFFFFFF
Address 4 contains 0xFFFFFFFF
Address 5 contains 0xFFFFFFFF
Address 6 contains 0xFFFFFFFF
Address 7 contains 0xFFFFFFFF

I'll try another adress.... will replay here again... thanks.

johnwasser:
The manual says that you read it like a 24C04 I2C EEPROM. If they use the default address of 0x28, this sketch should display the contents of the 8 registers.

#include <Wire.h>

const byte ChipAddress = 0x28;

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

// Send the read address
  Wire.beginTransmission(ChipAddress);
  Wire.write(0);  // Start reading at memory address zero
  Wire.endTransmission();

// Request 8 bytes of data
  Wire.requestFrom(ChipAddress, (byte)8);

// Display the 8 bytes of data
  for (byte address = 0; address < 8; address++)
  {
    Serial.print("Address ");
    Serial.print(address);
    Serial.print(" contains 0x");
    Serial.println(Wire.read(), HEX);
  }
}

void loop() {};




If the results show this, the chip is at another address (probably in the range 0x29 through 0x2F) or is not wired correctly.


Address 0 contains 0xFFFFFFFF
Address 1 contains 0xFFFFFFFF
Address 2 contains 0xFFFFFFFF
Address 3 contains 0xFFFFFFFF
Address 4 contains 0xFFFFFFFF
Address 5 contains 0xFFFFFFFF
Address 6 contains 0xFFFFFFFF
Address 7 contains 0xFFFFFFFF





If you get something other than F's, show us the data and maybe we can make some sense out of it.


Try while pointing the compass SOUTH so we expect a heading around 180°. If you point it NORTH it's hard to say if the value should be near 360 or near 0.

I've run the Arduino I2C Scanner. It has found one address: 0x70

I replaced your code with:

const byte ChipAddress = 0x70;

The result was:

Address 0 contains 0x0
Address 1 contains 0x0
Address 2 contains 0x0
Address 3 contains 0x0
Address 4 contains 0x0
Address 5 contains 0x0
Address 6 contains 0x0
Address 7 contains 0x0

[quote author=johnwasser link=msg=4625906 date=1591057600]
Address 0 contains 0xFFFFFFFF
Address 1 contains 0xFFFFFFFF
Address 2 contains 0xFFFFFFFF
Address 3 contains 0xFFFFFFFF
Address 4 contains 0xFFFFFFFF
Address 5 contains 0xFFFFFFFF
Address 6 contains 0xFFFFFFFF
Address 7 contains 0xFFFFFFFF

[/quote]

I've run the Arduino I2C Scanner. It has found one address: 0x70

I replaced your code with:

const byte ChipAddress = 0x70;

The result was:

Address 0 contains 0x0
Address 1 contains 0x0
Address 2 contains 0x0
Address 3 contains 0x0
Address 4 contains 0x0
Address 5 contains 0x0
Address 6 contains 0x0
Address 7 contains 0x0

Well... That's something.

It is possible that the chip doesn't (like many chips) allow reading sequential memory locations. Let's try sending an address for each read:

#include <Wire.h>


const byte ChipAddress = 0x70;


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


  for (byte address = 0; address < 8; address++)
  {
    // Send the read address
    Wire.beginTransmission(ChipAddress);
    Wire.write(address);  //  memory address to read
    Wire.endTransmission();


    // Request one byte of data
    Wire.requestFrom(ChipAddress, (byte)1);


    // Display the byte of data
    Serial.print("Address ");
    Serial.print(address);
    Serial.print(" contains 0x");
    Serial.println(Wire.read(), HEX);
  }
}

void loop() {};

So I found this piece of documentation:
https://botland.com.pl/pl/index.php?controller=attachment&id_attachment=3222.

I think this board is quite outdated though. What is your purpose with the compass?
Nowadays there are way more accurate sensor for which libraries exist etc.