Reading gyro and accleration sensor data from Wii Nanchuck + Motion Plus

31 Aug 2010

Has anyone managed to get reading of acceleration and sensor data from the Wii Nanchuck and Motion Plus working. It has been done extensively with Arduino and PIC processors, but for some reason roughly the same code does not work properly on the mbed lpc1768. In fact the sensors work perfectly on an Arduino Mini Pro 328/5V and with that processor there are quite a number of multikopters flying around using these two sensors as their 6DOF IMI. But on the mbed they just don't want to play ball. I suspect this is due to the implemention of the I2C commands with mbed which may be causing timing problems. On the other platforms there is clearer separate transmission of bytes and possible some build in wait states within the I2C commands.

One of the peculiarities is that in the combination the motion plus first has I2C address A6 (53 on the other platforms), which has to be changed through some write commands to A4. After that the Nanchuck becomes the slave of the MP+, which in turn remains slave to the mbed. The alternative is to have them both as slave to the mbed but that requires some general pins to be used to turn select them as in that configuration they sit on the same addres. The "passthrough" configuration is more popular.

01 Sep 2010 . Edited: 01 Sep 2010

Problem partially solved: the mbed lpc1768 seems to need pull up resistors (I tried 4.7kOhm) on both SDA and SCL lines. Maybe something to explicitly also add into the I2C information in the library and the handbook. In addition, I-m not accustomed to use one of those plug in proto strips, usually do soldered prototyping, and thus hadn't realized that the side bars don't continue full lenght on this particular version so although I thought I had connected the pull ups to 3.3V, they were in fact hanging in thin air during quite some time of experimenting (very red face, here).

Now to figure out why I-m not yet getting valid results..... but then by now I-ve put in so many additional lines of code that are probably not needed that I-ll have to do some cleaning.

30 Oct 2010

Please keep us posted of your progress! I am very interested in getting this to work.

01 Nov 2010

I also use the Wii-sensors WMP + Nunchuck for Tricopters and Quadcopters

Now I want them to work here as well...

14 Mar 2011

I've started working on this myself and have finally made progress on both the nunchuck and WM+. I didn't need to use any pull up resistors on mine, but I cut off the connectors and used short wires - maybe it makes a difference?

I am using cheap 3rd party versions of both Nunchuk and WMP, picked up off eBay. I discovered the initialization process for the Nunchuck (alone) that worked for me:

To I2C address 0xA4, write: 0xF0, 0x55, then 0xFB 0x00

This is instead of writing 0x40, 0x00, as is done in most of the Wii libraries I found for mbed - apparently that only works on genuine Wii components.

Initializing the WMP (alone) can be a little more tricky, because if you're already got it running and you update code on the mbed and restart, it won't reset the state of the WMP, so a two-stage initialization process is required:

Step 1: To I2C address 0xA4, write: 0xF0, 0x55 - this will initialize whatever controller is already at 0xA4, and if the WMP has been initialized previously, it will deactivate it. Ignore any results from the I2C write.

Step 2: To I2C address 0xA6, write: 0xFe, 0x04 - this remaps the WMP to the 0xA4 I2C address.

Now the WMP can be read using the same method as the Nunchuk (write 0x00 and read 6 bytes back).

In reality, I think I should be reading to identify the codes of the controllers, but since I know what controller is plugged in, I'm not wasting the time.

My code is a mess, so I don't want to post it right now. There's a lot of conflicting information on the net from various sources, and what I've done doesn't quite match up with some of what I've read, but it has worked for me.

A pretty good reference can be found here: http://wiibrew.org/wiki/Motion_Plus#Wii_Motion_Plus

I found that both components I have will do 100K or 400K I2C communications rate.

I haven't tried to tackle the Nunchuk + WMP in pass through mode yet...and so far I am just reading raw data. But I know how frustrated I have gotten over this, so I wanted to share my results. I'm not claiming to know what I'm doing , just hopefully it will help someone else.

28 Apr 2011

So did anyone got the nuchuck working so you can read the values from the nunchuck? can you alsow do this with a wireless nunchuck?