"Wire" library error? Porting MPU6050 driver with related library [SOLVED]

Hi,

I am trying to hook up MPU6050 from Sparkfun. What I am doing is trying to merge three trunks: 1) MP6050 driver 2) I2Cdev driver 3) Arduino sample code for MPU6050.

The process I’ve tried,

  1. copy files for MPU6050 from here.
  2. copy file for I2Cdev from here.
  3. And also with one Arduino (.ino) example from here.

In this project, I have the file list as following

  1. MPU6050_raw.ino (arduino file)
  2. helper_3dmath.h
  3. helper_3dmath.h (empty)
  4. MPU6050_9Axis_MotionApps41.h
  5. MPU6050_9Axis_MotionApps41.cpp (empty)
  6. MPU6050_6Axis_MotionApps20.h
  7. MPU6050_6Axis_MotionApps20.cpp (empty)
  8. I2Cdev.cpp
  9. I2Cdev.h

I also noticed that these libraries relate with “Wire” library which is porting to Spark internal firmware. So that I try to put //#include “application.h” to “I2Cdev.h”.

However, I got this error message as below,
It looks like the Wire object isn’t compatible somehow? No member function implemented? I’ve gone through forum but couldn’t get the right answer, any one experience this issue can give me some hint or suggestion?

Thanks!! xoxo
Harry

In file included from ../inc/spark_wiring.h:30:0,
from ../inc/application.h:31,
from I2Cdev.cpp:46:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
I2Cdev.cpp:53:14: warning: #warning Using outdated Arduino IDE with Wire library is functionally limiting. [-Wcpp]
I2Cdev.cpp:54:14: warning: #warning Arduino IDE v1.0.1+ with I2Cdev Fastwire implementation is recommended. [-Wcpp]
I2Cdev.cpp:55:14: warning: #warning This I2Cdev implementation does not support: [-Wcpp]
I2Cdev.cpp:56:14: warning: #warning - Repeated starts conditions [-Wcpp]
I2Cdev.cpp:57:14: warning: #warning - Timeout detection (some Wire requests block forever) [-Wcpp]
I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readBytes(uint8_t, uint8_t, uint8_t, uint8_t*, uint16_t)':
I2Cdev.cpp:231:22: error: 'class TwoWire' has no member named 'send'
I2Cdev.cpp:237:40: error: 'class TwoWire' has no member named 'receive'
I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readWords(uint8_t, uint8_t, uint8_t, uint16_t*, uint16_t)':
I2Cdev.cpp:351:22: error: 'class TwoWire' has no member named 'send'
I2Cdev.cpp:360:44: error: 'class TwoWire' has no member named 'receive'
I2Cdev.cpp:363:45: error: 'class TwoWire' has no member named 'receive'
I2Cdev.cpp: In static member function 'static bool I2Cdev::writeBytes(uint8_t, uint8_t, uint8_t, uint8_t*)':
I2Cdev.cpp:597:14: error: 'class TwoWire' has no member named 'send'
I2Cdev.cpp:611:18: error: 'class TwoWire' has no member named 'send'
I2Cdev.cpp: In static member function 'static bool I2Cdev::writeWords(uint8_t, uint8_t, uint8_t, uint16_t*)':
I2Cdev.cpp:652:14: error: 'class TwoWire' has no member named 'send'
I2Cdev.cpp:666:18: error: 'class TwoWire' has no member named 'send'
I2Cdev.cpp:667:18: error: 'class TwoWire' has no member named 'send'
make: *** [I2Cdev.o] Error 1

Error: Could not compile. Please review your code.

Yeah, that’s not going to port over easily. Someone is going to need to rewrite that I2C abstraction library I think.

I actually started writing an MPU6050 library a couple of weeks ago on a unit I’ve had for months. That is until I realized their whole “9-Axis Sensor Fusion” claim was a huge crock of horseshit and doesn’t even exist. (It’s only 6-Axis and to this day they still haven’t officially released the I2C registers needed to enable it, someone had to reverse engineer one of their preprogrammed dev boards to figure it out.)

That said, I will take a deeper look at that library for you in the next few days, unless someone else wants to take a crack at it.

2 Likes

Try library from DFRobot.com. They have a nice & cheaper MPU6050 alternative with wiki + Arduino library source (pins should be the same or can be changed easily if it will compile at least):
http://www.dfrobot.com/index.php?route=product/product&path=36_65&product_id=880#.UxMSUIU4NTQ

They have also nice 10-DOF sensor with Arduino support:
http://www.dfrobot.com/index.php?route=product/product&path=36_65&product_id=818#.UxMSeYU4NTQ

I’m from EU, so it does not matter if ordering gadgets from USA, Canada or China :smiley: everything is expensive :-D.

1 Like

mamahow, just a few things right off the bat. To compile theMPU6050_raw example you included these files:

In this project, I have the file list as following
1. MPU6050_raw.ino (arduino file)
2. helper_3dmath.h
3. helper_3dmath.h (empty)
4. MPU6050_9Axis_MotionApps41.h
5. MPU6050_9Axis_MotionApps41.cpp (empty)
6. MPU6050_6Axis_MotionApps20.h 
7. MPU6050_6Axis_MotionApps20.cpp (empty)
8. I2Cdev.cpp
9. I2Cdev.h

However, the RAW sketch does not use these files:

2. helper_3dmath.h
3. helper_3dmath.h (empty)
4. MPU6050_9Axis_MotionApps41.h
5. MPU6050_9Axis_MotionApps41.cpp (empty)
6. MPU6050_6Axis_MotionApps20.h 
7. MPU6050_6Axis_MotionApps20.cpp (empty)

I am looking at the code now to try and compile it for the Spark. Stay tuned!~ :smile:

I got everything compiling and it should work with the Spark from what I can see. I will post the code on my github as soon as I get a few things done. Back soon. :smile:

UPDATE: The MPU6050_raw demo code is up on my github.

I am working on getting the MPU6050_DMP6 demo up as well.

I will be doing the 9150 soon.

How did you deal with the calibration code? Or isn’t that in the library you are working with?

Mike43110, I’m only porting the code for you as I can’t actually test it. The only reference to calibration code is in the MPU6050_6Axis_MotionApps20.h file which I am still working on porting. Is that what you mean by the calibration code?

Mike43110, for some reason, I cannot compile the MPU6050_DMP6.cpp sketch that uses MPU6050_6Axis_MotionApps20.h on the web IDE. However, with the latest firmware master, it will compile locally. I put all the code on my github and if you want, I can put the firmware.bin if you want to dfu via USB to your core.

I was going to try your library with a MPU6050 breakout board I’ve got, but I don’t see where to set the pins to use for SCL and SDA? Am I missing something?

dougal, on the Spark, those pins are fixed:

D0 = SCL
D1 = SCA

http://docs.spark.io/#/hardware/pins-and-i-o-i2c

Make sure you use 10K ohm or so pull-up resistors on both lines. :smile:

I did find the pin information after posting, but haven’t had a chance to try the pull-ups yet.

Thanks!

Well bummer. I added the 10K pull-ups, but I’m still getting “connection failed”. I’ve even tried forcing the AD0 line low or high, and changing the I2C address from 0x68 to 0x69.

The module I have is the GY-521 from here:
http://www.electrodragon.com/product/mpu-6050-three-axis-acceleration-gyroscope-6-dof-module/

I’m powering my Spark Core via USB (also for the Serial debug output), and I have it wired like so:

Spark                               GY-521
3V3                                 VCC
GND                                 GND
D0                                  SCL
D1                                  SDA
GND                                 AD0 (for 0x68)
3V3          -> 10K ohm ->          SCL
3V3          -> 10K ohm ->          SDA

I’ve also tried powering from the Spark’s VIN instead of 3V3, with no change. Any ideas for further debugging?

Dougal, I looked at the specs for the module and it already has pull-ups so you can remove the other ones. let me take a look at everything and get back to you later. :smile:

Got it! Those clock and data lines are reversed, it should be:

D0 <–> SDA
D1 <–> SCL

Also, I did remove the external pull-ups. Thanks for your time. :smile:

1 Like

Hey!
I was looking for ported libraries of MPU6050 and I2Cdev. @peekay123, there’s one repository that’s been assembled from yours that I suddenly found today: https://github.com/kraken-down/MPU6050

Unfortunately, there are a lot of errors in those files and some are fatal, which stops compilation.
Is there a solution to these?

Here’s what I get:

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:29,
from /I2Cdev/I2Cdev.h:49,
from /I2Cdev/I2Cdev.cpp:46:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
#warning “Defaulting to Release Build”
^
In file included from …/inc/spark_wiring.h:37:0,
from …/inc/application.h:29,
from /I2Cdev/I2Cdev.h:49,
from /I2Cdev/I2Cdev.cpp:46:
…/inc/spark_wiring_ipaddress.h: In member function ‘IPAddress::operator uint32_t()’:
…/inc/spark_wiring_ipaddress.h:53:52: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
operator uint32_t() { return ((uint32_t)_address); };
^
…/inc/spark_wiring_ipaddress.h: In member function ‘bool IPAddress::operator==(const IPAddress&)’:
…/inc/spark_wiring_ipaddress.h:54:72: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
bool operator==(const IPAddress& addr) { return (((uint32_t)_address)) == (((uint32_t)addr._address)); };
^
…/inc/spark_wiring_ipaddress.h:54:105: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
bool operator==(const IPAddress& addr) { return (((uint32_t)_address)) == (((uint32_t)addr._address)); };
^
/MPU6050/MPU6050.cpp:37:29: fatal error: MPU6050.h: No such file or directory
#include “MPU6050.h”
^
compilation terminated.
make: *** [/MPU6050/MPU6050.o] Error 1

@LIGHThouse, I’m just glad the library is out there. It looks like Kraken did not include all the files and I2Cdev.h and .cpp files are missing. Also the example program was not separated. I will build a correct library and should have it posted in the next 30mins or so. :slight_smile:

@peekay123, Kraken has kept I2Cdev in a separate repository, which i guess is because there are two separate libraries. Anyway, the repo looks recently modified and I’m glad I found it soon after. :smiley:

@LIGHThouse, I saw that. However, he did not make any reference in the README file. There are other issues as well. There is an ongoing discussion with library dependencies on the IDE.

Thanks for that update, @peekay123!
What are the other issues? I don’t think it might be with the 2 libraries inherently because they’re individually ported nicely.
Again, the problem is was about MPU6050.h referring to I2Cdev.h, just the way you’re saying. There isn’t anything else, is there?