Go Down

Topic: I2C communications (Read 1 time) previous topic - next topic

fasp_asp

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

Erdin

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.

Headroom

Please add code tags to you post so the code is easier to read.
http://trippylighting.com

http://ledshield.wordpress.com/

cjdelphi

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



Erdin

E-Health sensor shield:
http://www.cooking-hacks.com/index.php/ehealth-sensor-shield-biometric-medical-arduino-raspberry-pi.html

Tutorial and documentation and schematic:
http://www.cooking-hacks.com/index.php/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical

The sensor:
http://www.cooking-hacks.com/index.php/patient-position-sensor-accelerometer-ehealth-medical.html

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.

fasp_asp

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!


fasp_asp

Can anyone help me please?

Regards for all

Go Up