I have been trying for some time now to get any sort of data from a gyro module. I posted a message earlier specifically about the l3g4200d module, but I think the question is probably not specific to the module, so I am starting a new thread.
So, I need to communicate on I2C, at least that what all the example show. I have a readI2C method like so:
int readI2C (byte regAddr) {
Wire.beginTransmission(Addr);
Wire.write(regAddr); // Register address to read
Wire.endTransmission(); // Terminate request
Wire.requestFrom(Addr, 1); // Read a byte
while(!Wire.available()) { };
return( Wire.read() );
}
I have seen numerous examples just like this. However the while loop runs forever and I get no return. I was starting to think the gyro module was bad...
So, I tried to read data using analogRead just to see if there was anything.
I am getting values reading pins A4 and A5, which are hooked to SDA/SCL respectively. As I move the gyro the analog values change, so I assume the thing is working. I just need to be able to read the proper registers to get x,y,z data...
Anyone know why waiting for Wire.available() would hang?
Yes, I was doing analogRead(A4) or A5 and getting changing values in the 500 or so. I was just trying to get something is all.
I tried the i2c scanner and got nothing. Based on a couple of replies in my other thread I think I can get it worked out though. I seem to not have things hooked up quite right for i2c to work. I'll continue this in that thread, so I don't have two conversations going about the same thing. I just wasn't sure, so I had two threads. That other one is 'could use a hand with l3g4200d gyro module'.
OK, the datasheet says the level shifters have built-in pullups.
However, that rather begs the question - "Why were analogReads only returning around half the supply voltage?"
(A schematic would be useful, Parallax)
I believe the 105 is correct, but the i2c scanner sketch is not finding it and it tries 105, so I'm really not sure. Anyone offer any suggestions? Could the gyro be defective? Based on their docs, and other sources it seems everything is hooked up properly.
No, it doesn't find anything - though the gyro is the only thing connected to the Arduino.
I think Power is fine - if I measure power at the gyro, I get 5.08, or 3.30 on my multimeter, depending on which voltage I connected to from the Arduino. I have 5V from the Arduino connected to VIN on the gyro, ground to ground, pin 4 to SDA and pin 5 to SCL.