TwoWire::endTransmission always return 0

Status
Not open for further replies.

sumotoy

Well-known member
I'm tying to write a simple I2C scanner but since seems I cannot use the twi.h lib I've tried to use the ability of wire.endTransmission() function to check if device acknoledge.

small example

Code:
 byte  dummy;
  for (char  id=1; id<=100; id++) {
    Wire.beginTransmission(id);
    Wire.write(&dummy, 0);
    if (Wire.endTransmission() == 0)
    {
      Serial.print("[[0x");
      Serial.print(id,DEC);//found
      Serial.print("]] ");
    } 
    else {
      Serial.print("0x");
      Serial.print(id,DEC);
      Serial.print(" ");
    }
  }

This will aways return all devices found since wire.endTransmission() on teensy 3 always return 0! Th's a way to get around this?
 
I've figured out a patch which will make the scanner respond properly (at least it does for me).
Line 150 in teensy\arduino-1.0.2\libraries\Wire\Wire.cpp is a "break;" statement.
Change it to:
Code:
return 4;


Pete
 
thanks pete, I will try later, good catch! :) I think this fix (plus the 3 other possible returns, if applicable) must be included in next release!
 
Status
Not open for further replies.
Back
Top