Arduino + Nunchuck = problem !

Hi,

I'm trying to connect my Wii controller to my arduino. I used the source from http://www.windmeadow.com/node/42.

i wasn't able to get any data because when i connect the nunchuck to the arduino, my arduino just stop. I connect directly on pins 2 to 5 with the WiiChuck Adaptor. The TX and TR pins stop blinking when i connect the controller.

I have no idea where is the problem and i can't continue to go ahead because I just can't read data.

Do I need to use resistor or something else ?

I use an Arduino diecimila, an original Nintento Nunchuck and the Wii Nunchuck Adaptor. I also use the lastest arduino software (012).

Adresse to the WiChuck Adaptor : http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/

Thanks in advance.

No you do not have to use a resistor. The Nun chuck is a 3v device, (but can use 5v safely) and communicates over I2C. The I2C bus is included in the arduino Wire library. The pins that the adapter uses are 2-5 ANALOG in pins. Pins 4 and 5 are the I2C pins. 2 and 3 are power and ground

The Nun chuck is a 3v device, (but can use 5v safely)

What is the basis for saying that 5v is safe? I know it works at that voltage but is there a reliable source indicating that the nunchuck components should be operated at that voltage.

First, we’ll make sure you’ve got good code running on there. I’ve ran several code samples when starting out and everything and have since written my own (I may post someday soon). To make sure you have good code, one that worked great for me a few weeks ago when starting was Tim’s code on the playground here: http://www.arduino.cc/playground/Main/WiiChuckClass .

Second, lets make sure the 4 chuck pins are connected properly…

Wii Nunchuck / Arduino Pin

Red Wire / 3V (Some people connect to 5V)
Green Wire (Data) / Analog In 4
Yellow Wire (Clock) / Analog In 5
White Wire / GND

Lastly, I personally looked and looked for an answer as to whether running the chuck at 5V was safe and came up empty. Many directly commented on it but all were something like, “seems to work fine for now, not sure what long term impact (if any) will be”.

My question is, why is this an issue with people even connecting it to 5V? I run it on the 3V pin and it works perfect, no worries at all.

Any source of the female Wiimote plugs, besides cannibalizing? It’s a plug type I haven’t seen, assumed proprietary. I don’t want to chop the Nunchuck male tail plug off either, but at least those are cheaper.

Update: Oh, darn, the link above ( http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/ ) gives a partial solution. Sorry for the noise.

why is this an issue with people even connecting it to 5V? I run it on the 3V pin and it works perfect, no worries at all

Its an issue because most integrated circuits don't like voltages on their input pins that are more than a fraction of a volt higher than the supply voltage. If powering the nunchuck from 3.3 volts, the voltage levels on the connected pins should be dropped using some form of level shifter.

Powering the nunchuck from 5 volts can be done, but should not be considered 'safe' until some hard facts indicate otherwise.

One of the pleasures of this hobby is to re-purpose things so they are used in ways not intended by their designers. But when going public with advice, lets be clear that something that ' seems to work ok for me for now' does not mean that it will safe or work reliably for everyone else.

I've solve the probleme by using the nunchuck_init_with_power() function instead of nunchuck_init().

Read the french post here : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227720617

But thanks for your help guys, very usefull !

Read the french post ...

Care to summarize that in english?

The french post doesn't contain any new info, but I'll summarize:

  1. brunolatortue complains of same problem as he did here, but in french.

  2. cataclypse tells brunolatortue that running the chuck at 3.3V creates an I2C frequency of 100Khz while running it at 5V creates a 400Khz frequency per this site: http://www.wiili.org/index.php/Wiimote/Extension_Controllers/Nunchuk . There's no real mention of this this might be relevant to his problem, but an idea.

  3. cataclypse recommends running code that does 'something' (that he doesn't yet understand) with the power pins required if the chuck is connected directly to the arduino. at this site: http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/

Note: I research this a bit and I don't understand what's going on here either. The init function is more/less identical to every other wiichuck example, but the _with_power() is indeed new. Can anyone tell what the difference is here and what it does!? (Personal note: I run the wiichuck plugged into protoshield with no problems and have never needed this _with_power() function).

// initialize the I2C system, join the I2C bus,
// and tell the nunchuck we're talking to it
static void nunchuck_init()
{ 
    Wire.begin();                // join i2c bus as master
    Wire.beginTransmission(0x52);// transmit to device 0x52
    Wire.send(0x40);// sends memory address
    Wire.send(0x00);// sends sent a zero.  
    Wire.endTransmission();// stop transmitting
}

// General version of nunchuck_init_with_power()beginWithPower().
// Call this first when a Nunchuck is plugged directly into Arduino
static void nunchuck_init_with_power_pins(byte pwrpin, byte gndpin)
{
    DDRC |= _BV(pwrpin) | _BV(gndpin);  // make outputs
    PORTC &=~ _BV(gndpin);
    PORTC |=  _BV(pwrpin);
    delay(100);  // wait for things to stabilize

    nunchuck_init();
}

Craig, thanks for the summary.

The _with_power code in item 3 in yr post provides power for the wiichuck adapter. It sets the levels of analog pins 2 & 3 to +5volts and ground so the adapter only needs to be plugged into the analog ports. It’s convenient if you have that adapter, but otherwise no different than if the nunchuck is powered directly off the 5 volt pin. It does nothing about the issue that the 3.3volt nunchuck is powered by 5 volts.

That makes so much sense, thanks... I see the creator of the chuck adapter is plugging in all 4 pins into the analog pins but that never registered until you said something.

I'm just getting started with the Arduino (and electronics in general to some extent) so I didn't actually realize it was possible to set the 6 exposed ADC pins to 5V/GND! Very helpful...

So, in other words there really isn't a solution in the French post, the user still has a problem elsewhere. Did you follow my earlier post to ensure the chuck I2C pins were all in the right places? If so, want to post your code and I can test it for you?

In facts, its a solution for me because i’ve used the wiichuck adaptor.

So i have to use the init_with_power function.

Do you use the adaptor?

Hi Bruno, re-read post #5. the issue is the chance of shortening the life of the nunchuck by running at 5 volts, which is 50% higher than it gets when connected to the wii.

An early post said it was safe to do so but so far there is no evidence this is true.

i got problem at Arduino+Nunchuck, please help me

i used the code right here todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/

but i can't get the data from Nunchuck,i think the problem at [u]nunchuck_init();[/u] the power seting is ok because i can get the[u]WiiChuck power is ready\n[/u] but i can't get the [u]WiiChuck init is ready\n[/u]

void setup() { Serial.begin(19200); nunchuck_setpowerpins(); Serial.print("WiiChuck power is ready\n"); nunchuck_init(); // send the initilization handshake

Serial.print("WiiChuck init is ready\n");

}

and the nunchuck_init(); is here


static void nunchuck_init() { Wire.begin(); // join i2c bus as master Wire.beginTransmission(0x52);// transmit to device 0x52 Wire.send(0x40);// sends memory address Wire.send(0x00);// sends sent a zero. Wire.endTransmission();// stop transmitting

}

i think the code is OK, but why there happen? :-[

everything is ok now after du check the wire of nunchuck, thank you to all

hi if you need help just send me a msg and ill help no prob

I'm bumping this old thread to share a discovery I just made: It is NOT fine to run the nunchuck on 5V. The one from nintendo seems to handle it ok but my third party one from gigaware (8 bucks at radioshack! :)) gave invalid acceleration data when running on 5V. Thanks to this thread I tried 3.3V and the acceleration data seems fine now, although a bit noisier than the genuine. Not sure if that's my fault or it just being shitty. ::)