I2C scanner code for the IMU chip

Hi,

I run the I2C scanner code on the gr lychee ide for gy80 chip.

It has 4 sensors, hence there should be 4 adddresss detected, but when i run the code it gets compiled and uploaded, but address detected are from 1 , 2 , 3 , 4 and so on and it continues..

Any inputs on this , the code below is :

 


#include <Wire.h>


void setup()
{
Wire.begin();

Serial.begin(9600);
Serial.println("\nI2C Scanner");
}


void loop()
{
byte error, address;
int nDevices;

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();

if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");

nDevices++;
}
else if (error==4)
{
Serial.print("Unknow error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");

delay(5000); // wait 5 seconds for next scan
}

  • Hi SBW,

    Your issue is that, it detects more than 4 addresses, right? What supply voltage did you use for the GY80 board? Did you check the I2C connections if it's wired correctly?

    JB
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    https://en-us.knowledgebase.renesas.com/

  • In reply to JB:

    Hi.
    I am using 3.3V for Voltage to the chip, and I2C connections are given as below
    scl - pin21
    sda - pin 22
    of the the GR Lychee Board,
    When i run the i2c scanner code, it starts detecting all the addresses, say from beginning till the loop ends.

    Like 1
    2 , 3 ,4 .........A, B,........... and so on.

    What could be the Error ? How to know if the IMU chip is working one or not ?

    Thanks
    sbw
  • In reply to JB:

    Hi
    I am connecting and testing ,

    Mag:0.00,0.00,0.00 Acc:0.000,0.000,0.000 Gyro:0.0,0.0,0.0 P:0.00236 T:0.0
    Mag:0.00,0.00,0.00 Acc:0.000,0.000,0.000 Gyro:0.0,0.0,0.0 P:0.00236 T:0.0

    Getting these values, Also once i run the scanner code it shows me the wrong address for 2 devices , !!
    Thanks