Arduino Motion Shield

3,083

13

1

Hey everyone! A couple of days ago, I got my hands on Arduino.org's "9 Axes Motion Shield". In other words, this baby.

Now, this thing has somewhat complicated instructions, and needs you to install the Arduino.org IDE to be able to use the library, but instead of that, we'll be using codebender* instead, to get this thing working right away

So as it turns out, this shield is pretty awesome, and it can give you Acceleration, Magnetometer & Gyroscopic data on all three axes (X, Y, Z), but it can also calculate the Euler vector. This is essentially Roll, Pitch, and Heading, which is cool if you wanna visualize where your device is pointing, track movement, etc. But I don't want to get into too many details on this 'ible, so I'm just going to show how we can use this shield, program our Arduino, get some data, and visualize it.

*yes, this is my shameless plug, deal with it! And so: disclaimer, I'm the founder of codebender

Step 1: Program the Shield!

To make this as easy as possible, I've created a sample sketch, which includes all the necessary library files, and I've even embedded it here using codebender's embedding functionality.

It's a slightly modified version of Arduino.org's Accelerometer example, that just gets the values and prints them on the screen. I've removed some extra comments so that we get a nice clean output for visualization.

If you want to use the code on your own Arduino, just install codebender's browser plugin/app, if you haven't already. Then select your Board and Serial Port from the dropdown boxes, and click Run on Arduino. This will compile the code and program your Arduino board with it.

Step 2: Serial Monitor - Get Data

I've also embedded codebender's serial monitor here, so we can take a quick look at the data. Alternatively you can go to the codebender Serial Monitor page, or use your program of choice to connect to your Arduino, i.e. CoolTerm, Putty, etc.

Make sure to select 115200 as the Baudrate/Speed, since this is the speed our Arduino is programmed to talk to.

After connecting to your Arduino, you should start getting data soon, and it should look like the picture above.

Step 3: Visualize It!

In the interest of making this as simple as possible, I'm using Graphite, a small, experimental service by codebender that we just coded on a weekend as a cool idea. Because it's an experimental free-time project, it only works on Firefox, so keep that in mind if you try to use it.

Of course, you can use any kind of visualization tool that talks to a serial port. I'm not aware of any, but I'm sure there must be some Python library or whatnot. And at the end of the day, you can always gather the data from the Serial Monitor of your choice and copy-paste them to an Excel Spreadsheet (or similar).

Share

    Recommendations

    • PCB Contest

      PCB Contest
    • Big and Small Contest

      Big and Small Contest
    • Toys Contest

      Toys Contest

    Discussions

    0
    None
    WillyS21

    Question 3 months ago on Step 1

    Good morning: I am just practicing with the baby and could not run the code.

    it appears something with "tokens" and I am not familiar with it.

    Would you explain to me how to run your code?

    I tried and had following result:

    Arduino:1.8.1 (Windows 10), Tarjeta:"Arduino/Genuino Uno"

    In file included from C:\Users\USUARIO\Documents\Arduino\Big Compilation\Big Compilation Example\Big Compilation Example.ino:1:0:

    sketch\NAxisMotion.h:625:8: warning: extra tokens at end of #endif directive

    #endif __NAXISMOTION_H__

    ^

    In file included from sketch\NAxisMotion.cpp:3:0:

    sketch\NAxisMotion.h:625:8: warning: extra tokens at end of #endif directive

    #endif __NAXISMOTION_H__

    ^

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateCalibStatus':

    sketch/NAxisMotion.cpp:192: undefined reference to `bno055_get_accel_calib_stat'

    sketch/NAxisMotion.cpp:193: undefined reference to `bno055_get_mag_calib_stat'

    sketch/NAxisMotion.cpp:194: undefined reference to `bno055_get_gyro_calib_stat'

    sketch/NAxisMotion.cpp:195: undefined reference to `bno055_get_sys_calib_stat'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateAccelConfig':

    sketch/NAxisMotion.cpp:249: undefined reference to `bno055_get_accel_range'

    sketch/NAxisMotion.cpp:250: undefined reference to `bno055_get_accel_bw'

    sketch/NAxisMotion.cpp:251: undefined reference to `bno055_get_accel_power_mode'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `resetSensor':

    sketch/NAxisMotion.cpp:40: undefined reference to `bno055_init'

    sketch/NAxisMotion.cpp:46: undefined reference to `bno055_set_data_output_format'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `setOperationMode':

    sketch/NAxisMotion.cpp:85: undefined reference to `bno055_set_operation_mode'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateAccel':

    sketch/NAxisMotion.cpp:114: undefined reference to `bno055_convert_float_accel_xyz_msq'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateLinearAccel':

    sketch/NAxisMotion.cpp:170: undefined reference to `bno055_convert_float_linear_accel_xyz_msq'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateGravAccel':

    sketch/NAxisMotion.cpp:181: undefined reference to `bno055_convert_float_gravity_xyz_msq'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateAccel':

    sketch/NAxisMotion.cpp:114: undefined reference to `bno055_convert_float_accel_xyz_msq'

    sketch/NAxisMotion.cpp:114: undefined reference to `bno055_convert_float_accel_xyz_msq'

    sketch/NAxisMotion.cpp:114: undefined reference to `bno055_convert_float_accel_xyz_msq'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateLinearAccel':

    sketch/NAxisMotion.cpp:170: undefined reference to `bno055_convert_float_linear_accel_xyz_msq'

    sketch/NAxisMotion.cpp:170: undefined reference to `bno055_convert_float_linear_accel_xyz_msq'

    sketch/NAxisMotion.cpp:170: undefined reference to `bno055_convert_float_linear_accel_xyz_msq'

    C:\Users\USUARIO\AppData\Local\Temp\ccWbFisT.ltrans0.ltrans.o: In function `updateGravAccel':

    sketch/NAxisMotion.cpp:181: undefined reference to `bno055_convert_float_gravity_xyz_msq'

    sketch/NAxisMotion.cpp:181: undefined reference to `bno055_convert_float_gravity_xyz_msq'

    sketch/NAxisMotion.cpp:181: undefined reference to `bno055_convert_float_gravity_xyz_msq'

    collect2.exe: error: ld returned 1 exit status

    exit status 1

    Error compilación en tarjeta Arduino/Genuino Uno.

    Este reporte podría tener más información con

    "Mostrar salida detallada durante la compilación"

    opción habilitada en Archivo -> Preferencias.

    I will highly appreciate to give some tips how to overcome

    regards

    Willy