Datasheet of the GY-26 says to send 0xC0 to the module and it will return 000.00 confirming it has entered to the calibrating mode. then user should turn the device two circle very slowly. One circle should be more than one minute. Then to finish calibration send the compass 0xC1. This is the method explained in the official datasheet of GY-26 compass module. But unfortunately this method is completely wrong. I guaranteed on my word.
I faced a huge problem with this module because my robot has more metal parts so the compass sensor will give inaccurate values. So i need to calibrate the compass before i use it with my robot to get the accurate reading. I tried many ways to send 0xC0 to the module but it did not respond 000.00 to me anyway.
So i found a new method to calibrate the module myself after doing many experiments.
Method is just fix the compass module to whatever device you are using (in my case its my metal robot). Then ground and release the PIN 9 (CAL pin) of the module. now you will see the module is sending 000.00 and the green LED on the module is keep on. So this means your module is now on calibrating mode. Next step is just turn clockwise and anti-clockwise the device two three times (no need to turn the device so slowly as they have asked on the datasheet, and no need to turn complete rounds). Finally again ground the CAL pin and release it. That's it. Now your GY-26 compass module is fully calibrated.
Hope this will help you guys on your projects.
hi,
i want to buy this compass too. is this the module you are using?
Can you please post the code to read the direction from the compass..
thanks
Yes you have found the correct compass module. But it.
Here is the code for this compass module to get the value to a single variable. If you have any questions regarding this matter just ask i will help you.
#include <NewSoftSerial.h>
NewSoftSerial mySerial(5, 6);
void setup()
{
pinMode(5, INPUT);
pinMode(6, OUTPUT);
Serial.begin(9600);
// set the data rate for the NewSoftSerial port
mySerial.begin(9600);
}
void loop() // run over and over again
{
char val[7];
{
Serial.print(31, HEX);
delay(200);
}
for (int i = 0; i < 8; i++) {
char deg = Serial.read();
val = deg;
-
}*
-
int all[] = {val[2], val[3], val[4]};*
-
switch(all[0]){*
-
case 48: //When 0.*
-
all[0] = 0;*
-
break;*
-
case 49: //When 1.*
-
all[0] = 1;*
-
break;*
-
case 50: //When 2.*
-
all[0] = 2;*
-
break;*
-
case 51: //When 3.*
-
all[0] = 3;*
-
break;*
-
}*
-
switch(all[1]){*
-
case 48: //When 0.*
-
all[1] = 0;*
-
break;*
-
case 49: //When 1.*
-
all[1] = 1;*
-
break;*
-
case 50: //When 2.*
-
all[1] = 2;*
-
break;*
-
case 51: //When 3.*
-
all[1] = 3;*
-
break;*
-
case 52: //When 4.*
-
all[1] = 4;*
-
break;*
-
case 53: //When 5.*
-
all[1] = 5;*
-
break;*
-
case 54: //When 6.*
-
all[1] = 6;*
-
break;*
-
case 55: //When 7.*
-
all[1] = 7;*
-
break;*
-
case 56: //When 8.*
-
all[1] = 8;*
-
break;*
-
case 57: //When 9.*
-
all[1] = 9;*
-
break;*
-
}*
-
switch(all[2]){*
-
case 48: //When 0.*
-
all[2] = 0;*
-
break;*
-
case 49: //When 1.*
-
all[2] = 1;*
-
break;*
-
case 50: //When 2.*
-
all[2] = 2;*
-
break;*
-
case 51: //When 3.*
-
all[2] = 3;*
-
break;*
-
case 52: //When 4.*
-
all[2] = 4;*
-
break;*
-
case 53: //When 5.*
-
all[2] = 5;*
-
break;*
-
case 54: //When 6.*
-
all[2] = 6;*
-
break;*
-
case 55: //When 7.*
-
all[2] = 7;*
-
break;*
-
case 56: //When 8.*
-
all[2] = 8;*
-
break;*
-
case 57: //When 9.*
-
all[2] = 9;*
-
break;*
-
}*
_ int final = ((all[0] * 100) + (all[1] * 10) + (all[2]));_ -
mySerial.println(final);*
}
Hello Sir
Im new to gy-26. Im asking for your kind help. I connected my GY-26 to a UBS -> RS232 converter. Everything is working fine. When I send C0 as hex to the GY-26 the led turns on and after I send C1 it turns off again so something is changing. It gets my input.
What Im not getting is the reading when I send 31 to the compass. Im getting back 1 as reading. Im sending hex and receive as Text. What Im doing wrong.
Im connecting the vcc together and the gnd together and rx and tx to the rx and tx of the usb -> rs232 converter. Your kind help will be really appreciated