Wii Nunchuk I2C troubles

I’m trying to talk to my nunchuk via i2c. I’ve had no problems with my arduino micro so I know the driver is good.

I’ve got two 10k pullup resistors on D0 and D1 connected to 3v3 (one of the two coming out of the top of the spark). I’m using a PCB adapter with Data going to D0 and Clock going to D1 as the docs specify.

I think something is wrong with the voltage, I either get all 255 bytes when reading from the device or get a cycle where a few reads are super low (mostly zeroes) then a few higher and then several of full 255 bytes.

I tried removing and adding pullups, swapping data and clock, trying different ground and 3v3 ports on the core. I’m powering over usb (powered by a laptop) since I’m using serial to monitor.

Any idea if I need external power supplement or am I doing something wrong?

@creationix What is the voltage on your PCB adapter? The Arduino typically runs at 5V (some of the micros run at 3.3v) I have been using the Spark I2C extensively and not experienced any problems - but I run everything at 3.3v

The Nunchucky pcb says it needs 3v3 power. I’m pretty sure I was using the 3v3 side of the micro when working with that.

If you are are you using something like this -> http://www.adafruit.com/product/345 then how are you connecting the 3.3v and GND with the core? Also do you have a multimeter to check voltages?

Yes, that’s the PCB I’m using.

PCB -> Core

3.3V -> 3V3
Gnd -> GND (next to the 3v3 pin)
Data -> D0 (with 10k resistor going to 3v3 rail
Clk -> D1 (with 10k resistor going to 3v3 rail

My 3v3 rail is connected to the other 3v3 pin on the core.

I do have a multimeter. Not sure what to check for though.

The GND is between 3.3* and D7 one one side and between TX and VIN on the other.

Right, I edited my post. I’m using the one between 3V3 and D7.

Measuring on the pcb, the difference between Gnd and 3.3V is 3.27.
Between Gnd and Data is a steady 3.26 and between Gnd and Clk is a steady 0.06.

It's a pretty cheap multimeter, but I would expect some movement from the digital clock and signal right?

GND and CLK should not be 0.6. The clock should be floated high by the 10K resistor and the Spark Core will pull it low when it needs to clock.

@creationix, can you share which library you are using to read the Nunchuk?

I'm currently using GitHub - GabrielBianconi/arduino-nunchuk: Improved Wii Nunchuk library for Arduino. But I also tried reading raw values using Wire directly.

For simplicity, I inlined the library into a single file. Here is my entire program: spark-chuk.ino · GitHub

Hmm, on a whim I tried another Nunchuk (this time a clone) and it’s working. I wonder if I somehow fried my official nunchuk while wiring.

The two devices are different brands (Nintendo official and Kama)

That’s surprising, I would have expected the official one to work and the clone to possibly not work. Oh well, at least now you know your SW and Spark connections are correct.

Yeah, not sure what’s wrong. But with the working clone the multimeter reads much higher on clock. I’m guesing that something is wrong with initialization on the official device.

It’s a shame it’s not working. It was giving much better values on my micro. I’ll try the official device on my micro in hopes it works there.

2 Likes

I cleaned up and published the wii nunchuk library as https://github.com/creationix/spark-nunchuk.

It’s available in the cloud ide as nunchuk.

Thanks for the help!

2 Likes

@creationix just found this to use with my Argon–thanks!