hey, i have this device, i tried to run the simple example code of L3G (and some other code) but i keep getting random readings of the gyro sensor, while the device is flat on the surfaces
it’s important to say that i didn’t solder it yet and it is just working while lying on the pins,
i also checked the numbers of the magnumeter and the accelerometer , they looked accurate, so i assumed the device is connected ok.
those are the numbers we get as output:
G X: 98 Y: -66 Z: 81
G X: 121 Y: -14 Z: -113
G X: 227 Y: 419 Z: 30
G X: 186 Y: 394 Z: 293
G X: 226 Y: 90 Z: -7
G X: 178 Y: 466 Z: -142
G X: 226 Y: 388 Z: 178
G X: 258 Y: 305 Z: 178
G X: 15 Y: -7 Z: -9
G X: -44 Y: 4 Z: -36
G X: 110 Y: 178 Z: -69
G X: 6 Y: 113 Z: -92
G X: 63 Y: 118 Z: 88
G X: 127 Y: 114 Z: -101
G X: 68 Y: -243 Z: -18
G X: 102 Y: 184 Z: 104
G X: 108 Y: 167 Z: 208
G X: 9 Y: 15 Z: -44
G X: 22 Y: 166 Z: 5
G X: 20 Y: -130 Z: -192
G X: 73 Y: 151 Z: -262
G X: -26 Y: 95 Z: 239
G X: 1 Y: 102 Z: -213
G X: 120 Y: -201 Z: -17
G X: -90 Y: 132 Z: 23
G X: 104 Y: 223 Z: 105
G X: 176 Y: -48 Z: -105
G X: 39 Y: 13 Z: 55
G X: 96 Y: 113 Z: -47
G X: 112 Y: 111 Z: 147
G X: 183 Y: 432 Z: 16
this is the code:
/*
The sensor outputs provided by the library are the raw 16-bit values
obtained by concatenating the 8-bit high and low gyro data registers.
They can be converted to units of dps (degrees per second) using the
conversion factors specified in the datasheet for your particular
device and full scale setting (gain).
Example: An L3GD20H gives a gyro X axis reading of 345 with its
default full scale setting of +/- 245 dps. The So specification
in the L3GD20H datasheet (page 10) states a conversion factor of 8.75
mdps/LSB (least significant bit) at this FS setting, so the raw
reading of 345 corresponds to 345 * 8.75 = 3020 mdps = 3.02 dps.
*/
#include <Wire.h>
#include <L3G.h>
L3G gyro;
void setup() {
Serial.begin(9600);
Wire.begin();
if (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
while (1);
}
gyro.enableDefault();
}
void loop() {
gyro.read();
Serial.print("G ");
Serial.print("X: ");
Serial.print((int)gyro.g.x);
Serial.print(" Y: ");
Serial.print((int)gyro.g.y);
Serial.print(" Z: ");
Serial.println((int)gyro.g.z);
delay(100);
}
and we attached :
SCL—> A5
SDA —>A4
GND —>GND
VIN—>5V
and we use arduino unoPreformatted text