I2C communications

Googd afternoon,

I put on my arduino Uno the following code do test one sensor on my board for I2C communications.

The code 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
}

It appears the following in serial monitor:

No I2C devices founded

What happened?

Regards

What kind of sensor is it ?
How did you connect it ?

If you click on "Additional Options..." when writing a post, you could upload a photo, so we can see how it is connected.

Please add code tags to you post so the code is easier to read.

You have your sensor hooked to the correct pins sda/scl not backtofront?

2.jpg

1.jpg

E-Health sensor shield:

Tutorial and documentation and schematic:

The sensor:

Reading the documenation, it seems that sometimes the usb power is not enough. Could you try with a power supply for the Arduino Uno ?
The schematic does not show how it is connected to the Arduino. It seems that the new I2C pins are used, those are only on the Arduino Uno V3. Do you have that, or an older version of the Uno ?
And there are jumpers for the accelerometer. Did you set those ?
The MMA8452Q has an I2C interface, so the i2c_scanner should be able to detect it, once it is connected.

Hi Edison,

Thanks very much for your rapid response.

I have an arduino Uno R3.

And there are jumpers for the accelerometer. Did you set those ?
R: Yes, i have the jumpers in the right place.

The schematics od this board goes in attachment.

Regards and thanks for help me!

e-Health_v3_esquemas.pdf (34.2 KB)

Can anyone help me please?

Regards for all

hi all....
i need full tutorial about using i2c communication with 3 or more slaves. in my project i am using arduino due as master. and uno's as slaves. arduino due is connected with touch screen. and slaves connected to sensor. sensor values are continuously transferring to due for displaying. i used Wire.library. the project is working fairly.but not 100% good. some data are missing. the sensor values are floats. i used value/100 and value%100 method. then i heard about i2c anything and easyTransfer header files. both are tested.but sadly,not working. i couldnt implement slave sending by these methods. plzz help me.....