Wiimote as bluetooth transciever for an Arduino

After some trying, I have been able to use a wiimote for two-way communication for an Arduino. So far I just have a proof of concept. The code is very rough. For the set up and wiring, first look at my earlier entry on using the wiimote for one way communication.

Data is sent to/received from the Nunchuk by writing to/reading from address space 0x04A400xx. Data written to that location, then gets transmitted through expansion port using TWI. The arduino then reads it in.

My test code runs on linux and requires libcwiimote. You need to have version .3 of libcwiimote installed. Download my sample code at: test1.c. Just copy it over test1.c that comes with libcwiimote and run make again.

The test code will send the numbers 1 to 15 to the wiimote/arduino. The data will be transmitted to the wiimote and written to registers 0x04a40001 to 0x04a4000F where it will be sent to the arduino.

The sample code for the arduino is wiimotetest.pde. It will listen for input from the wiimote and write that input to a buffer. Once 50 bytes have been written to the buffer, the arduino prints the buffer out over its serial connection (just to prove that the data made it to the arduino. I used minicom to read the data). The arduino will transmit 6 bytes of data to the wiimote. This data will be transmitted back to the PC over bluetooth.

A sample of the input the arduino reads from the wiimote is:

Start Data Dump
:0,:0,:0,:1,1,:0,:2,2,:0,:3,3,:0,:0,:4,4,:0,:5,5,:0,:6,6,:0,:7,7,:0,:8,8,:0,:0,:9,9,:0,:10,10,:0,:11,11,:0,:12,12
End Data Dump
Each set of input is separated by ":". As you can see the wiimote seems to be constantly sending "0" to the expansion port. This is probably some type of handshaking used by the nunchuck. The numbers 1 to 15 you see where sent by the test1.c program. When test1.c sends a byte, the arduino reads two bytes. The first byte is the address and the second byte is the number. So for "2,2", I sent the number 2 to address 0x04a40002, for "3,3" I sent the number 3 to address 0x04a40003 and so on. That seems to be the pattern at least. At the same time, I had the arduino transmit back 6 bytes. Test1.c also show those bytes. The arduino can't read in TWI transmissions at the same time it sends serial data, so sometimes the data was a little weird. With a little work, I think a library could be written to adequately use the wiimote as a low cost bluetooth transceiver.

nice

nice article
Regards

-----------------
Zurna~radyo dinle~chat odaları

I need Help

i tried the wiimotetest but nothing happens, i tought it should emulate an nunchak on the extension port....
I use DarwinRemote but it dosent show any nunchak to me .....

Please can some one help me, and point me in a direction.

What OS are you running?

What OS are you running? DarwiinRemote is a windows app right? I am not sure if my code 100% mimics the nunchuck, so I could understand darwiinremote not recognizing it.

Do you have a linux system? If so, try my libcwiimote examples. It dumps the raw packets. See if there is a way in darwiinremote to view the raw packets send over from the nunchuck. I don't have a windows box, so check for myself.

Also, did you make the required header changes for the I2C speed? Take a look at http://www.windmeadow.com/node/42

good luck

OSX

I use mac osx 10.5 on a MBP and the Darwin remote.
But also if i use the wiiflash server i get also the not data and no information that a nunchak is connectet.

The arduino is an decemilia with an atmel 168 and also i used an Ng bord with an mega 8. I did the changes on the twi.h lib like this:

#define ATMEGA8

#ifndef CPU_FREQ^M
#define CPU_FREQ 16000000L
#endif

#ifndef TWI_FREQ^M
#define TWI_FREQ 100000L
#endif

the only thing waht i get if i plug the cable on the extension port, is one time this 3 numbers -> 64 0 254 by tracing the variable "c" in the receive function.

so may be it will not work on osx or on my arduino bords.

thnks martin

decimilia

first off thankyou for posting this information.. :-)

second ;_; i have hit a dead end.

has anybody else reported problems with using a decimilia board for this?

oddly enough while trying the example the arduino can receive i2c messages fine

i.e. it sends a sucessfull data dump over serial

but when data is requested from it..(or if).. it does nothing

your version of test1.c reads all zeroes for the six nunchuck bytes
I have tried reading the adresses directly from a number of different libraries (glovepie & wiiuse) and get error 7 (ie nunchuck not attached).

(is the status of the nunchuck updated after receiving the bytes over i2c).

oh .. also I have just realised there are no zeroes in my serial data dump

i'm confused

I would be vary gratefull if anyone can shed any light on this, hopefully i just have the dumb

happy toying :-)

thanks for information..

thanks for information..

What version of Arduino software

One thing I just thought about. What version of the arduino software are you using? There may have been a change to the I2C libraries between the old version .07 of the software I used and the newer versions. Look at my update at:
http://windmeadow.com/node/42

thankyou chad .. you were

thankyou chad .. you were right i am using the 0010 arduino ide.

the updated header additions, have me up and running, (i should have looked harder :-),

.. on a side note the old gamecube conectors work perfectly well in the wiimote if you dremel off the round top and connect pins1&3

thanks a million. now off to make something funky.

Shoot me an email once you

Shoot me an email once you have built something.

Did you also get all zeroes

Did you also get all zeroes when a nunchuck was attached? I haven't worked on this in a while, but if I remember correctly my sample test1.c program should write output that is sent from a regular nunchuck. See if that works.

I can understand glovepie and wiiuse not recognizing it. I am sure my code does not completely mimic the nunchuck.

Well done! --Zudini

Well done! --Zudini

Awesome

That's great. Thanks for pushing on that. I'm just waiting for my Arduino to arrive and then will start hacking away. -Stoph

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is used to make sure you are a human visitor and to prevent spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.