Wii Nunchuck trouble

Hi everyone, I was attempting to try out the following library -


And use a Wii nunchuck with the Pokitto, but I’ve slipped at the first hurdle.
It gives the following error that I can’t seem to figure out…

main.cpp|258|error: request for member ‘read’ in ‘nunchuck’, which is of non-class type ‘WiiChuck()’|

What does it mean? How do I fix it?


How have you defined nunchuck?
And how are you calling read?

doesn’t matter, it was a typo, I defined nunchuck wrong :stuck_out_tongue:

1 Like

I thought that would be the case.

What the ‘non-class type’ error translates as is that you’ve tried to call a member function on a type that isn’t a class (only classes can have member functions).
That’s why I was asking about the definition and the calling line, the answer to that error is usually an incorrect definition or something funky with the way something’s being called.

hmmm, it doesn’t seem to work though.
Can anyone tell me, are the i2c clock and data pins P0_4 and P0_5 as suggested here?

Or are they different on Pokitto?

swap p0_4 and p0_5

long story

1 Like

hmmm, then the pokitto fails to boot. Does that effect the hat pinout also? or is that still correct?

could we see your application code please?

1 Like

Its simple this library… https://os.mbed.com/users/d34d/code/WiiChuck/docs/be9ce129de7c/classWiiChuck.html

With this…

#include "Pokitto.h"
#include "WiiChuck.h"

Pokitto::Core game;
WiiChuck nunchuck(P0_5, P0_4);

void setup(){
    game.display.width = 110; // half size
    game.display.height = 88;

int main(){
    nunchuck_data_t nunchuckData;


    int FPS = 0;
    int frameNumber=0;
    long tempTime=game.getTime();
    int myFPS=40;
    char tempText[20];


    while (game.isRunning()) {

                sprintf(tempText,"%d, %d %d %d %d %d %s %s", FPS,
                      nunchuckData.joyX, nunchuckData.joyY, nunchuckData.accX, nunchuckData.accY,
                      nunchuckData.accZ, nunchuckData.buttonC ? "X" : "", nunchuckData.buttonZ ? "X" : "");
                game.display.print("No NunChuck");

            unsigned long currentTicks = game.getTime();



    return 1;

And clk to I2C_SLK, dat to I2C_SDA, gnd to GND and pwr to 3.3v according to this…

please move declaration of nunchuck instance inside main() function and see if that helps

if its a global instance, it gets initialized before boot and may clash with the I2C sound vol control

i will make a fix for it

switched it to this…

int main(){

    WiiChuck nunchuck(P0_5, P0_4);
    nunchuck_data_t nunchuckData;

Didn’t help.

Maybe that library doesn’t work, I found with arduino libraries, a lot of wii nunchuck code just din’t work at all, despite everyone saying that it did.

After resoldering the connector, it seems to nearly work.

The current issue is that it looks like it crashes after the first successful read.

[edit] I tried with and without pullups on the data and clock.

1 Like

I know the cause. I will try to get involved in this as soon as I have time.


No rush, as long as I know it’s possible :slight_smile:


You can get around the problem already:

create nunchuck instance every time you talk to it.

i know it sounds weird / wasteful but believe me what actually happens is just a couple of IO port writes

The problem is the sound volume controller (which is also hooked to P0_4 and P0_5) grabs control and doesn’t give it back.

By reinitializing the nunchuck instance when you need it, you get back control of the I2C line

1 Like

I’ll give that a try :slight_smile:

1 Like


Using the following to detect i2c devices, I’m getting mixed results.
I have a wireless wii classic controller adapter (8bitdo) which will return the correct address (0xA4), but a real classic controller and two nunchucks that return 8 addresses from 0x00 to 0x0E.

game.display.clear(); I2C i2c(P0_5, P0_4); // sda, scl game.display.setCursor(0,0); game.display.print("Searching...\n"); int count = 0; for (int address=0; address<256; address+=2) { if (!i2c.write(address, NULL, 0)) { // 0 returned is ok sprintf(tempText,"I2C address 0x%02X\n", address); game.display.print(tempText); count++; } } sprintf(tempText,"%d devices found\n\n\n", count); game.display.print(tempText);

I wonder is this a quirk or Pokitto, or of the wii controllers?

@spinal I just hooked up a ADXL345 I2C 3-axis accelerometer. Worked immediately with no issues on hardware I2C when PROJ_ENABLE_SOUND = 0; (yes, accelerometer lib will be added to the repository)

So not sure about what the problems are that you’re facing with the nunchucks

Yes, we have a go for the ball in cup game !! :smile:

1 Like

Marble madness with accelerometer