The Wii MotionPlus (wm+) uses i2c (Inter-Integrated Circuits) for all of its communications. To learn how to make the Arduino talk to the wm+, weโll program the Arduino to talk to it using the i2c protocol. This tutorial will show you how to wire the wm+ to the Arduino and toss some code into a sketch in order to gather gyroscope data.
The there are many pre-existing tutorials on how to use i2c with the Arduino.
>> This project is brought to you by element14. Be sure to check out the e14 Arduino page.
Project Steps
First youโll want to lay out all of the parts you will need. (You can use this photo for reference).
Wii MotionPlus
Jumper Wires
WiiChuck Adapter
2x 470 Ohm Resistors (picture shows 3)
Optional 2 โ 3 Servos
In this layout image, there are two Wii MotionPlus units shown. One has been removed from its housing. The other has not. Only one is needed for this project. If you plan on removing the housing, see the last step in this project before continuing.
Additional reading material/ references can be found on the last step of this project.
Insert the WiiChuck Adapter into the wm+ (See picture for WiiChuck Adapter Orientation. On the third picture the โclkโ side is circled. Make sure yours is the same.)
Connect the Arduino to the headers on the WiiChuck Adapter.
See below for correct Pin Mappings:
+ goes to 3v
D (SDA) goes to Analog 4 (A4)
C (SCL) goes to Analog 5 (A5)
Be sure to remember to place 470 Ohm pull-up resistors between SDA and A4 and SCL and A5. See circuit drawing for reference. I used female jumpers and the resistors to create a male end to plug into the Arduino. See this as a reference: http://bit.ly/gJuqUu
Next, download the Arduino sketch from: http://bit.ly/e7Y1zr Special thanks to Miles Moody for providing the source code!
Be sure to have your wm+ sensor sitting upright and somewhat level with the WiiChuck adapter pointing skyward.
Load the sketch onto the Arduino. (See http://bit.ly/7cymtl for help with this.)
Click on the Serial Console button in the Arduino development environment.
You should see lots of numbers for Pitch, Roll, and Yaw screaming by.
Now, when you pick up the wm+, you should see the Pitch, Roll, and Yaw numbers start to change!
You now are reading 3-axis gyroscope data on the Arduino platform. Well done, hardware hacker!
Note: In picture 3 there is a circle around the 2 resistors. This is to remind you that you do not just plug the jumpers straight into the Arduino. REMEMBER TO RESIST!
Now that youโre able to read data from the wm+, there are many uses for your hack! They include:
Cheap DIY inertial measurement (IMU) for a quadcopter
Sharks with gyroscopes!
DIY motion control for a robot
Controlling up to three servomotors (one for each axis)
If you are feeling ambitious, Iโve uploaded some code to control two servos with the wm+ here: http://bit.ly/h13uAj Go ahead and give it a tryโฆ
There are a few reasons why one might want to remove the wm+ electronics from its housing. Here is the data youโll need to solder to the board and access your gyro data.
The newer boards use a ribbon cable to attach to the gyro board. I recommend you solder headers or wires directly to the pads vs. using the ribbon cable.
6 = GND
5 = SDA
2 = SCL
1 = Vcc (CAUTION: 3v MAX!)
The obscured label at the top of the wm+ diagram reads: IDG-600. Thatโs the InvenSense gyro controller chip.
Additional Reading Materials/Reference:
wm+ hardware information: http://bit.ly/rnOi1
Arduino i2c basics: http://bit.ly/8Y5sQ1
Arduino servo lib: http://bit.ly/gzHr6l
Miles Moodyโs wm+ orginial post: http://bit.ly/gr2Zx
Advanced wm+ & servo code thread: http://bit.ly/fLgONk
Conclusion
For Arduino news, features, tutorials, a buyer's guide, and more, visit the Make: Arduino page.