Hi all,
I'm trying to get input from MPU9150 using the code in the Playground (Arduino Playground - MPU-9150) but I can't get it to work- it always freezes on Wire.endTransmission (it won't return, so I can't print the error).
I understand it's quite the common problem with the Wire library, but I couldn't find any straight forward solution.
Does anyone have a skatch that would work, or a step-by-step explanation for how to solve the problem (I tried using "I2C" library (arduino/I2C.h at master · ninjablocks/arduino · GitHub) but I got lost trying to figure out how to replace each function.)
Just in case it might be a hardware/connections problem:
I'm using an UNO, and the connections are:
VCC->5V
GND->GND
ACL->A5
SDA->A4
INT->2
I understand it's quite the common problem with the Wire library,
Blaming the library when the device you are trying to talk to is connected incorrectly or does not have the address that you are using is the common problem. The library is fine.
Have YOU confirmed that the device is connected properly AND has the address you are using, by running one of the I2C scanner sketches available on the internet?
PaulS:
Blaming the library when the device you are trying to talk to is connected incorrectly or does not have the address that you are using is the common problem.
LOL it must be, because it seems to be the most common explanation on the net. I actually had no idea, so I thought that must be it- after finding out it was completely my fault, I offer my sincere appologies to the library writer
The answer is pretty embarrassing, but I'll share it in case it would help anyone else in the future:
a. It turns out that I used a broken wire, so the sensor didn't get a VCC in. after fixing it it turned out that-
b. I needed to connect the AD0 pin to 5V as well. Only after doing so did the I2C scanner told me that-
c. The address I used was wrong- I had to go into the header file ("mpu6050.h") and change the default address
Never connect the AD0 to 5V. That is a pin of the sensor, and the sensor is 3.3V. Connect it to 3.3V or GND or use a resistor to connect it to 3.3V or GND. Most modules have that pin connected, are you sure the pin is open ?
Peter_n:
Never connect the AD0 to 5V. That is a pin of the sensor, and the sensor is 3.3V. Connect it to 3.3V or GND or use a resistor to connect it to 3.3V or GND. Most modules have that pin connected, are you sure the pin is open ?
The I2C scanner didn't find the modul when I left A0 unplugged, so I guessed it's not connected. I will move it to 3.3v though. Thanks for the comment