I2C devices not found troubleshooting

Problem solved, see last post.

Hi,

I'm trying to troubleshoot an I2C issue between an arduino nano and an ir camera.
I keep getting 'no devices found' using an I2C scanner.

Here is what I've done or tried so far :

I plugged the camera to +5V, GND, SDA to A4 and VCL to A5.
I checked with a multimeter for possible shorts from above inputs. No beeps.
I checked the voltage at +5V when the camera is connected (read 4.7V)
I tried with/without 4.7kohm resistors between SDA/SCL and +5V.
I tried without plugging the camera, same 'no devices found' message.

The camera LED is on. (Operating voltage: 3.3-5v from datasheet)
I'm using a second hand nano board, not sure if it is a copy.
I'm using a portable version of arduino rev 1.8.8.
I tested sucessfully the blinking led program on my nano board.

Thank in advance is someone can help.
I'm still working on it, I'll update this thread if I found something else.

IR camera link : Positioning_ir_camera-DFRobot

Where's your code?

Here it is (from Positioning_ir_camera-DFRobot)

// Wii Remote IR sensor test sample code by kako http://www.kako.com
// modified output for Wii-BlobTrack program by RobotFreak http://www.letsmakerobots.com/user/1433
// modified for http://DFRobot.com by Lumi, Jan. 2014

#include <Wire.h>

int IRsensorAddress = 0xB0;
//int IRsensorAddress = 0x58;
int slaveAddress;
int ledPin = 13;
boolean ledState = false;
byte data_buf[16];
int i;

int Ix[4];
int Iy[4];
int s;

void Write_2bytes(byte d1, byte d2)
{
Wire.beginTransmission(slaveAddress);
Wire.write(d1); Wire.write(d2);
Wire.endTransmission();
}

void setup()
{
slaveAddress = IRsensorAddress >> 1; // This results in 0x21 as the address to pass to TWI
Serial.begin(19200);
pinMode(ledPin, OUTPUT); // Set the LED pin as output
Wire.begin();
// IR sensor initialize
Write_2bytes(0x30,0x01); delay(10);
Write_2bytes(0x30,0x08); delay(10);
Write_2bytes(0x06,0x90); delay(10);
Write_2bytes(0x08,0xC0); delay(10);
Write_2bytes(0x1A,0x40); delay(10);
Write_2bytes(0x33,0x33); delay(10);
delay(100);
}
void loop()
{
ledState = !ledState;
if (ledState) { digitalWrite(ledPin,HIGH); } else { digitalWrite(ledPin,LOW); }

//IR sensor read
Wire.beginTransmission(slaveAddress);
Wire.write(0x36);
Wire.endTransmission();

Wire.requestFrom(slaveAddress, 16); // Request the 2 byte heading (MSB comes first)
for (i=0;i<16;i++) { data_buf*=0; }*

  • i=0;*
  • while(Wire.available() && i < 16) {*
    data_buf = Wire.read();
    * i++;*
    * }*
    * Ix[0] = data_buf[1];
    Iy[0] = data_buf[2];
    s = data_buf[3];
    _
    Ix[0] += (s & 0x30) <<4;_
    _
    Iy[0] += (s & 0xC0) <<2;_
    Ix[1] = data_buf[4];
    Iy[1] = data_buf[5];
    s = data_buf[6];
    _
    Ix[1] += (s & 0x30) <<4;_
    _
    Iy[1] += (s & 0xC0) <<2;_
    Ix[2] = data_buf[7];
    Iy[2] = data_buf[8];
    s = data_buf[9];
    _
    Ix[2] += (s & 0x30) <<4;_
    _
    Iy[2] += (s & 0xC0) <<2;_
    Ix[3] = data_buf[10];
    Iy[3] = data_buf[11];
    s = data_buf[12];
    _
    Ix[3] += (s & 0x30) <<4;_
    _
    Iy[3] += (s & 0xC0) <<2;_
    _
    for(i=0; i<4; i++)_
    _
    {_
    _ if (Ix < 1000)
    Serial.print("");
    if (Ix < 100)
    Serial.print("");

    if (Ix < 10)
    Serial.print("");

    Serial.print( int(Ix) );
    Serial.print(",");
    if (Iy < 1000)
    Serial.print("");
    if (Iy < 100)
    Serial.print("");

    if (Iy < 10)
    Serial.print("");

    Serial.print( int(Iy) );
    if (i<3)
    Serial.print(",");
    }
    Serial.println("");
    delay(15);
    }*_

Actually, I wouldn't even look at my code if an I2C scanner (I use Nick Gammons) doesn't Report the device. If the scanner doesn't see the device, my code probably wouldn't either.

The SCL and SDA lines are usually pulled high so they should read near 5 Volts all the time. While running the I2C Scanner, they will be constantly yanked between ground and 5V at a high Speed, so you should be reading some voltage Level around for example 2.5 Volts while the I2C scanner is active (probably a Little higher).

What camera are you using?

In the code here:

int IRsensorAddress = 0xB0;
//int IRsensorAddress = 0x58;

you might try using 0x58 for the address instead of 0xb0.

0xb0 (0b10110000) is 0x58 (0b01011000) << 1. In looking at the twi.cpp code, when the address is set the parameter is <<1:

void twi_setAddress(uint8_t address)
{
  // set twi slave address (skip over TWGCE bit)
  TWAR = address << 1;
}

When you send 0xb0 (i.e. 0x58 << 1), it could be that there's a 2nd <<1 performed in the library. You can try it and/or check over the lib source.

JaBa:
Actually, I wouldn't even look at my code if an I2C scanner (I use Nick Gammons) doesn't Report the device. If the scanner doesn't see the device, my code probably wouldn't either.

The SCL and SDA lines are usually pulled high so they should read near 5 Volts all the time. While running the I2C Scanner, they will be constantly yanked between ground and 5V at a high Speed, so you should be reading some voltage Level around for example 2.5 Volts while the I2C scanner is active (probably a Little higher).

What camera are you using?

This model : Gravity: IR Positioning Camera For Arduino - DFRobot
I'll try to test the SCL and SDA inputs as you said.
Thanks.

Test AT THE CAMERA, not on the Arduino. That will help detect cabling Problems. Also make sure that you didn't cross SCL/SDA which is also a common mistake.

Blackfin:
In the code here:

int IRsensorAddress = 0xB0;

//int IRsensorAddress = 0x58;




you might try using 0x58 for the address instead of 0xb0.

0xb0 (0b10110000) is 0x58 (0b01011000) << 1. In looking at the twi.cpp code, when the address is set the parameter is <<1:



void twi_setAddress(uint8_t address)
{
 // set twi slave address (skip over TWGCE bit)
 TWAR = address << 1;
}




When you send 0xb0 (i.e. 0x58 << 1), it could be that there's a 2nd <<1 performed in the library. You can try it and/or check over the lib source.

Thank you, will try.
But I guess I have to fix the i2c scaning issue first ?

JaBa:
Test AT THE CAMERA, not on the Arduino. That will help detect cabling Problems. Also make sure that you didn't cross SCL/SDA which is also a common mistake.

You mean unplugged ?
I don't get it.

Edit: I see. Here is a pic of the camera:

It won't be easy to test it. I'll try to measure the metal tip at the connectors end.

dudeabides:
Thank you, will try.
But I guess I have to fix the i2c scaning issue first ?

Yep, sorry; hadn't read things closely enough.

I noticed that the code has this line in setup():

slaveAddress = IRsensorAddress >> 1;   // This results in 0x21 as the address to pass to TWI

(Not sure about the comment here but that basically answers to my suggestion.)

JaBa:
Test AT THE CAMERA, not on the Arduino. That will help detect cabling Problems. Also make sure that you didn't cross SCL/SDA which is also a common mistake.

I dit a test with a multimeter. SCL & SDA are steady at 4.7v.
No variation while scaning with i2c test code.
I also tried the visible conductive part of the ir camera, same result.

Ok, that is strange. Let's do a sanity check here. Run the I2C scanner WITHOUT plugging the camera in. Obviously, the camera can't be found but in order to find the Problem we Need to divide and conquer. If the voltage acts as expected WITHOUT the camera plugged in, then the Problem is something at the camera end. If the voltages act as suspicously WITHOUT the camera, then something is wrong on the Arduino end.

Ok, thank you.
I did a multi test without the camera(while running i2c scanner):
A5 is switching from 4.7v to 0v.
A4 is stuck at 0v.

With the camera :
A5 & A4 at 4.7v

?

JaBa:
Ok, that is strange. Let's do a sanity check here. Run the I2C scanner WITHOUT plugging the camera in. Obviously, the camera can't be found but in order to find the Problem we Need to divide and conquer. If the voltage acts as expected WITHOUT the camera plugged in, then the Problem is something at the camera end. If the voltages act as suspicously WITHOUT the camera, then something is wrong on the Arduino end.

Hello,
I did a gentle scratch with a knife around pin A4, and there was like a dirty layer of burnt plastic.
This was the problem, there was no conductivity with the external pin.
It's all working fine now.

Thank you sir for your help.
Hope it might help someone else one day.

1 Like