Another Teensy 4.0 and MPU9250 thread

jcun4128

Member
Alright hopefully this is short, my background is web developer type, trying to get into hardware so far just using Arduino/Raspberry Pi. Know some C++ but it's not a daily driver.

I have started a blank repo, I cloned an MPU9250 repo along with this Eigen thing it needs.

I'm trying to run one of their examples externally of those folders. For the moment I'm using full paths instead of relative.

I can program my Teensy 4.0 fine eg. put the cliche servo sweep on there. I'm just stuck with messages like this:
Code:
undefined reference to bfs::Mpu9250::Begin()

I don't know if I'm missing something obvious like an IDE setup to link stuff or what. When I trace the example code the bfs::Mpu9250 object exists... I don't understand what this imu call is on this line:

Code:
bfs::Mpu9250 imu(&Wire, 0x68);

Is that an arbitrary name or is it in code somewhere, I don't think I see that anywhere as a defined thing doing ctlr + f so I'm thinking it's just a random nice name.

If it is a board/wiring issue. I'm powering the Teensy by the USB, separate power supply 5V for the MPU9250, using pins 17/16 for SDA/SCL. I don't know if it even matters this far yet but I did try a pull up resistor thing 5K with 5V parallel to the SDA/SCL as mentioned in another post on here.

Repo is here, it's not modified from the original example/cloned repos other than the full path imports.

I would appreciate any thoughts sorry I'm a complete noob.

Edit:

There is one other thing I would like advice on is the structure of your folders. I imagine I will be importing/using more libraries than this one.

So if I have a structure like:


Code:
- actual code
  - import filea.h, fileb.h
- libraries
  - thing a
    - filea.h
  - thing b
    - filea.h



Is that going to work?
 
I'm going to try and install the libraries into Arduino itself as the README says (look at that) and that will probably fix this.

What I tried to do was clone these into my VS Code editor that Teensyduino is linked to. Then compile the test file that's using these libraries I guess it doesn't work like that (Arduino IDE has to have the library paths somewhere).
 
That is the one I'm using. I think I just need to do as it says and bring the repos into the Teensyduino editor.
I'm doing this on a 2015 MBP. I will post an update once I try it, that might be my issue is just including those libraries.

Thanks

edit: I wonder if I have to undo those full paths now, will see.
 
If using the ide has to be in the arduino libraries folder that is shown in the ide (File>preferences)
Capture.PNG
 
Yeap that was it. I just installed everything on Arduino by Boulder Flight (MPU9250, units, eigen) and then now I'm onto the next error lol IMU comm error but this is good.

I did have to take out those full path edits I did.

edit: Saw your post above

On a side note, I was doing C++ stuff in VSC just using G++ but I imagine in the future I have to actually use something like VS, to deal with stuff like this.

Anyway I appreciate the response.

I'm sticking with Teensyduino for this because I'm using the Teensy currently most familiar with Arduino.

"Are not 5V tolerant" ooh... anyway no smoke/still works but I'll keep that in mind.
 
Hi,

I wrote that library. Should be as simple as downloading or cloning into your Arduino / libraries folder:
1. Our MPU9250 library (https://github.com/bolderflight/mpu9250)
2. Our unit conversion library (https://github.com/bolderflight/units)
3. Our matrix math / Eigen library (https://github.com/bolderflight/eigen)

Shouldn't have to do anything with paths and the example should "just work". Let me know if you continue to have issues or if installing into Arduino fixes it.

EDIT: I took too long to reply and just saw that you got that error fixed. Comm error might be easiest to solve if you take a good picture of the wiring between Teensy and the MPU-9250.
 
> I wrote that library.

Haha that's really cool. I hope to get to your level some day. I'm just an npm install script kiddie.

Anyway, yeah after I just installed your libraries through the Arduino search it did just work. vs cloning it directly into my VSC editor.

Here's my wiring that I have. I took off the pull-up attempts, not sure if it is mandatory. I did measure the IMU is getting power. I have used these before with an RPi/another library. Maybe I cooked it.

Thanks for the help

wiring.png

EDIT: that red wire on the 3V Teensy is not attached to anything. Initially it was with the pull resistors on the right side.
 
Looks like you have it on pins 16 and 17 (Wire1) instead of 18 and 19 (Wire). So, you would need to modify the example to use Wire1 instead of Wire. You definitely need pullups from SCL and SDA to power. I'm not super familiar with that particular breakout board, but I would double check the expected voltage level - looks like it's hooked up to 3.3V, but you mention that it's on 5V.
 
We're good, the matrix is flowing. I just had a dunce move trying 69 over 68... I remember that was way to use another device vs. as you said the Wire/Wire1.

Thanks for the help, now I can figure out what a quaternion is.

I updated the wiring, the IMU is powered from the Teensy's 3V out, and it's using 2K resistors off the same line. I will actually use a dedicated 3V regular when the time comes.
I'm going to try and get it to work off 5V as I'm stepping up from a single cell battery anyway.

Screenshot 2021-12-31 at 12.05.11 PM.jpg

EDIT: I deleted the referenced repo in post #1 since it was just clones/didn't want to mislead future people.
 
Last edited:
Back
Top