Nunchuck fails on rp2040 CP 7.3.3

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Nunchuck fails on rp2040 CP 7.3.3

Post by bbx10node »

I have 3 nunchucks working with QT Py ESP32-S3 (5426) via the STEMMA connector. CP 7.3.3. One nunchuck is from Adafruit (PID: 342). The other two are cheap clones. The nunchuck breakout adapter (PID: 4836) is also from Adafruit.

nunchuk_simpletest.py modified to use STEMMA_I2C.

Code: Select all

import time
import board
import adafruit_nunchuk

nc = adafruit_nunchuk.Nunchuk(board.STEMMA_I2C())

while True:
    x, y = nc.joystick
    ax, ay, az = nc.acceleration
    print("joystick = {},{}".format(x, y))
    print("accceleration ax={}, ay={}, az={}".format(ax, ay, az))

    if nc.buttons.C:
        print("button C")
    if nc.buttons.Z:
        print("button Z")
    time.sleep(0.5)
I am considering a cheaper solution using QT Py RP2040 (PID: 4900) or Trinkey QT2040 (PID: 5056) but none of the nunchucks work. All fail like this. Note all nunchucks work on the ESP32-S3 so the message is misleading.

Code: Select all

code.py output:                                                                 
Traceback (most recent call last):                                              
  File "code.py", line 8, in <module>                                           
  File "adafruit_nunchuk.py", line 64, in __init__                              
ValueError: No I2C device at address: 0x52                       
Based on the following forum message I modified nunchuck_simpletest.py so it works for ESP32-S3, QT Py RP2040, and Trinkey QT2040.

viewtopic.php?p=889779

Code: Select all

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import adafruit_nunchuk

i2c = board.STEMMA_I2C()

if board.board_id in ('adafruit_qt2040_trinkey', 'adafruit_qtpy_rp2040'):
    i2c.try_lock()
    i2c.scan()
    i2c.unlock()

nc = adafruit_nunchuk.Nunchuk(i2c)

while True:
    x, y = nc.joystick
    ax, ay, az = nc.acceleration
    print("joystick = {},{}".format(x, y))
    print("accceleration ax={}, ay={}, az={}".format(ax, ay, az))

    if nc.buttons.C:
        print("button C")
    if nc.buttons.Z:
        print("button Z")
    time.sleep(0.5)

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Nunchuck fails on rp2040 CP 7.3.3

Post by adafruit_support_carter »

Does your work around fix the issue?

Do you see any difference in behavior between the different Nunchucks?

User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Re: Nunchuck fails on rp2040 CP 7.3.3

Post by bbx10node »

All 3 nunchucks work the same. The workaround fixes the problem for my RP2040 boards. CP 8 does not fix the problem. I forgot which beta version I tried.

User avatar
adafruit_support_carter
 
Posts: 29056
Joined: Tue Nov 29, 2016 2:45 pm

Re: Nunchuck fails on rp2040 CP 7.3.3

Post by adafruit_support_carter »

OK, sounds like you have something that'll work for your setup. The whole nunchuck protocol is reversed engineered, so may potentially have some quirks. And there appears to be minor vendor specific differences as well.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”