Go Down

Topic: Hello? Who's out there? I2C address unknown, how to obtain it? (Read 4 times) previous topic - next topic

gelfling6

Retrolefty, Thanks!  I'll give the sketch a try.

RE:Nick G:, using the demo sketch someone made for the nunchuck, and expanding it to read more than just the accelerometer, (also get the joystick X & Y, as well as buttons C & Z), as I mentioned in the original post, it responds back with all 7 values = 255.. (and none chance with any of the buttons pressed.)

This is a link to the device,  http://www.airaccent.com/arcade-fighter-joystick-controller-for-nintendo-wii-white-p-35437.html
Although, I bought mine from a local Ocean State Job-Lot ("Inventory close-out" store for those unfamiliar with the place.)

I'm not using the turbo or macro functions (yet, once I am sure I can talk to it, maybe.....)  but the arduino (either a UNO or a Duemilinova, programmer 0.23, as it seems even more than just Ethernet or charlieplexing libraries are changed under 1.0  :smiley-zipper:) reports back 255, 255, 255, 255, 255, 255, 255.....

wanting to use this in a remote control to another arduino, on a robot..


Nick Gammon

Oh well, run the I2C scanner suggested above. At least that confirms the address, and confirms you have it wired up right.

retrolefty

Quote
it responds back with all 7 values = 255.. (and none chance with any of the buttons pressed.)


That's a typical default value when something is not even responding due to the pull-up resistors used on a I2C bus. I have a DS1307 I2C real time clock that works fine, and if I start the sketch but don't have the RTC attached to the arduino the sketch does not stall or hang-up it just returns 0xff for all transactions.

Lefty



s-light

Hey comunity,

i found this by searching for an I2C / TWI  Scanner.
in the sketch posted here is a smal error with the Arduino IDE 1.0.3 (others not tested.)

Corrected Sketch:
Code: [Select]

/**
* TWI_I2C_Scanner.ino
* I2CScanner.pde -- I2C bus scanner for Arduino
*
* 2009, Tod E. Kurt, http://todbot.com/blog/
* http://todbot.com/blog/2009/11/29/i2cscanner-pde-arduino-as-i2c-bus-scanner/comment-page-1/
* http://arduino.cc/forum/index.php/topic,95067.msg714094.html#msg714094
* https://getsatisfaction.com/thingm/topics/cant_get_blinkm_communicator_to_compile_and_upload
*
*/

#include "Wire.h"
extern "C" {
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr,
                void(*callback)(byte address, byte result) )
{
  byte rc;
  byte data = 0; // not used, just an address to feed to twi_writeTo()
  for( byte addr = from_addr; addr <= to_addr; addr++ ) {
    rc = twi_writeTo(addr, &data, 0, 1, 0);
    callback( addr, rc );
  }
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
  Serial.print("addr: ");
  Serial.print(addr,HEX);
  Serial.print( (result==0) ? " found!":"       ");
  Serial.print( (addr%4) ? "\t":"\n");
}


byte start_address = 1;
byte end_address = 127;

// standard Arduino setup()
void setup()
{
    delay(2000);
    Wire.begin();
    Serial.begin(115200);
    Serial.println("\nI2CScanner ready!");

    Serial.print("starting scanning of I2C bus from ");
    Serial.print(start_address,HEX);
    Serial.print(" to ");
    Serial.print(end_address,HEX);
    Serial.println("...Hex");

    // start the scan, will call "scanFunc()" on result from each address
    scanI2CBus( start_address, end_address, scanFunc );

    Serial.println("\ndone");
}

// standard Arduino loop()
void loop()
{
    // Nothing to do here, so we'll just blink the built-in LED
    digitalWrite(13,HIGH);
    delay(300);
    digitalWrite(13,LOW);
    delay(300);
}


the correction is in line 27:
twi_writeTo needs one additional parameter: 0 for a normal stop command.
i found this info here: https://getsatisfaction.com/thingm/topics/cant_get_blinkm_communicator_to_compile_and_upload

Have fun with I2C / TWI
sunny greetings
stefan

gelfling6

#9
Oct 07, 2013, 04:50 am Last Edit: Oct 15, 2013, 03:43 am by gelfling6 Reason: 1
Well, after 3/4 of a year since this thread was active, I pulled the controller out, and hooked it up, changing slightly, running +3.3V & GND externally. (Using the THINGS.Com nunchuck plug, external from the Arduino.)  and tried the original code someone posted here..  confirmed, it's the same address as the actual nunchuck controller (52), but when I tried various ways of talking to it to send data, nothing came back...    just sat there..  So, apparently, it's something the master controller of the Wii sends, that it understands..  Also, internally, this controller is nothing but switches under the joystick, 8 external switches to the right, but no ideas how the turbo and macro control keys work..  I'll check that new URL someone just posted..  just downloaded the PDF.. So, hopefully, I'll learn something from it.  Thanks.


Update: the URL was for another of Tod Kurt's devices, but I couldn't make heads or tails of it..

I understand, the sketch he wrote long ago for the Nunchuck looks for data from memory address 0x40 (decimal 64) of device 0x34 ( decimal 52), But, how do I (a) figure what memory address is this thing using, if not 0x40? and (b) how many bytes will it send?

Go Up