BeagleBoard Trainer Nunchuk

Revision as of 15:26, 5 November 2010 by Prpplague (Talk | contribs) (Hardware)

Jump to: navigation, search

BeagleBoard + Trainer + Nunchuk using I2C

using the Nintendo Wii Nunchuk or clones with a BeagleBoard and TinCanTools Trainer board.

Many possibilities are gained using a joystick, 3-axis accelerometer and two user buttons provided with the nunchuk. These wired nunchuks are inexpensive, much less than buying the components individually. The insides or electronics can be easily removed from the nunchuk and applied as one sees fit. Build a balancing robot, add a gyroscope, compass and use it in flight projects.

This is my proposal to the TinCanTools Challenge "First person to post a "HowTo" for use with the Nintendo Wii NunChuk and Trainer board wins $150 cash".

What a great way to motivate people. Offer them cash :) So i was motivated but had no TinCanTools Trainer board or Wii nunchuk to work with. Ordering the Trainer from TinCanTools was simple and quick. A few days later it was here. I picked up Wii nunchuk at a local pawn shop and a nunchuk clone at our kmart store. Each cost me $10 US. Got all the hardware, I already had my BeagleBoard revC2.So lets begin to review the steps I took to implement communication over I2C with the BeagleBoard, Trainer and a wired nunchuk.




  • i2c-tools
  • i2c-dev (program requires i2c-dev.h)
  • task-sdk-native (the toolchain, gcc and all that)
  • Geany (optional ide)
  • beagleboard_trainer_chuk.tar.gz (the program)


1) Prepare BeagleBoard to accept Trainer board 2) Prepare trainer board for connecting nunchuk 3) Prepare nunchuk connector adapter 4) Verify i2c is functioning 5) Troubleshoot i2c connection

Step 1

Following the directions given on the link above for Step 1, it is a simple matter of soldering the connector provided with the Trainer board onto the BeagleBoard.

Step 2

I prefer having easy access to all user connections on the Trainer. The two rows of headers are easy to find. I used a couple of these [1] male headers]. Simply snip off the number of pins needed and solder to the bottom of the board. Optionally you might choose to use female headers like [2].


If you use female headers on the trainer you will need male on the WiiChuck Adapter and vice versa. The nunchuk is a 3 volt DC device so be sure the I2c voltage header is jumpered to +3.3V. See close up image farther down this page.

Step 3

I can't describe any better than the todbot blog how one should setup the nunchuk connector adapter. Theirs is the easiest, quickest and least challenging I am aware of. Having lots of stuff around and being a hacker I did manage my own adapter. Either way I recommend making a cable that splits the SCL SDA pins from the 3.3V and GND pins. This splitter is handy later on for using the Trainer boards atmega328 AVR for nunchuk data. I do not recommend using the AVR I/O pins for power and ground sourcing. There will be more discussion about using the AVR. This wiki focuses on the Trainer boards I2c and Beagleboard with the Wii and clone nunchuks.

Step 4

Now some fun. With all pieces checked, assembled and checked again it is time to power up. It is expected that before you began this project you have already gotten the BeagleBoard up and running with either a serial console or gui desktop. I recommend a X11 desktop like is available in Sakoman, Inc. gnome or Angstrom or Ubuntu. The X console is more responsive to the fast data throughput of the test program I provide though just a simple serial console connection will suffice. After booting and opening a serial or X console follow these steps to verify the nunchuk is connected properly. At prompt type i2cdetect -r 2

I2c detect.png

If you did not get the 52 showing then the nunchuk is not communicating with the BeagleBoard, Proceed to Step 5, Troubleshoot i2c connection. If the nunchuk is detected as device 52 we can go forward. Download and install beagleboard_trainer_chuk.tar.gz to your home directory. In the image I have a directory I keep all my projects in, "/home/projects/trainer_chuk".

Type "tar -xvf beagleboard_trainer_chuk.tar.gz" to extract.

You should now have a trainer_chuk directory. With your console enter the trainer_chuk directory.

Type "./chuk_trainer" to execute program.

You should get the next display. Moving the joystick , chuk or pressing the two buttons should change the shown data for that item. Pressing both the buttons at the same time exits the program.

Bb trainer chuk demo.png

I used my revC2 BeagleBoard to build the test app locally. I prefer the Geany IDE. By setting up some arguments in the "Build/Set includes and Arguments" drop down this simple program compiles easily. Your directory paths may differ from mine. These same arguments can be used to compile and build the application.

Compile: gcc -Wall -c chuk_trainer.c chuk_com.c

Build: gcc -Wall -o chuk_trainer chuk_trainer.o chuk_com.o

The warning option -Wall enables warnings for many common errors.

Geany incl args.png

Step 5: I had hoped you would not need to read this section. But in case of issues not seeing the nunchuk on the i2c bus i do provide some steps. The TincanTools Trainer boards i2c is connected to the beagleboard header pin 23, I2C2_SDA and pin 24, I2C2_SCL with a 3.3V or 5v (jumper selectable) voltage translator. This is i2c bus 2 in user space or i2c bus 1 in u-boot. As I have explained above how to test in user space we will now look at testing in u-boot.

  When powering up the beagleboard using the serial console there is a countdown during u-boot to interrupt the image loading process. Press a key during the countdown to interrupt booting. From here we can use other i2c utilities to verify whether or not the nunchuk device address is visible.
   In the serial console enter "i2c dev 1" which sets the i2c bus to the second bus. Then type "i2c probe" to display detected devices on bus 1 (remember that in user space this is bus 2). See below.
I2c probe.jpg

Notice our device 52 is showing. If it is not then there is most likely a problem with the wiring of your nunchuk to the Trainer board header. The 50 is the eeprom code for the Trainer board. So obviously it too should be shown. Here is a closeup image of the Trainer.

I2c header.jpg

This image clearly shows the I2C connections on the header pins I installed, from left to right, [gnd, 3.3V, SDA, SCL]Also notice the I2C voltage select jumper (JP1) is on the 3.3V or 3v3 position.

AVR connections: My splitters yellow/white (SCL and SDA) are the i2c clock and serial data. The red/blk lead is for 3.3V and ground.


See below that the avr voltage selector header (JP4) is in the 3.3V position. Also see my power leads are on the Trainer boards ground and I2c voltage header. The AVR data A5 is SCL and A4 is SDA.

Chuk spliter avr.jpg

credits: Tin Can Tools,, Sakoman, Inc.