I am having trouble initializing and reading data from an I2C MPU3050 Gyro sensor designed for the Arduino. I am able to get the sensor working on an Arduino and read the data; however, the same code and connection on the Spark Core produces no output. The first command issued was a WhoAmI request that failed. The wire.endtransmission() produced an error value of 4. I would appreciate any feedback.
Hi @jdhchow
One of the differences between Spark and Arduino is that Spark always requires pull-up resistors on I2C.
Do you have pull-ups on the two I2C lines? 4.7KOhm is ideal but lots of values will work OK.
Thanks for you quick comment!
I only have 10k, 1k and 330 Ohm resistors.
Would you happen to know if any of these work?
Hi @jdhchow
I would stick the 1kOhm resistors from D0 and D1 to 3.3V.
Also do you know if your gyro is a 3.3V compatible device? The I2C pins are 5V tolerant but you may need to power your gyro from +5V.
Yes, the gyro is 3.3v compatible.
You mentioned the ports D0 and D1, are they able to read analog data or just digital?
Spark has built-in I2C on pins D0 and D1. They are digital pins (which is what I2C uses).
Thanks a million!
It worked perfectly!
Would it be better though to get 4.7k resistors?
The 1kOhms are fine. You can go to high resistances if you want to be say battery powered.
Glad it worked for you!
Okay, perfect!
Thanks again for all your help!