title: How do I connect an Arduino Uno with Raspberry Pi using I²C
body: <p>I'm trying to send data through the <a href="http://en.wikipedia.org/wiki/I%C2%B2C" rel="nofollow">I²C</a> interface from the <a href="http://arduino.cc/en/Main/ArduinoBoardUno" rel="nofollow">Arduino Uno</a> to the <a href="http://en.wikipedia.org/wiki/Raspberry_Pi" rel="nofollow">Raspberry Pi</a> using I²C. This was the code I used.</p>
  
  <p>In Arduino:</p>
  
  <pre><code>#include &lt;Wire.h&gt;
  unsigned int watt;
  unsigned int watt1;
  byte watt2;
  byte watt3;
  void setup()
  {
      Wire.begin(30);
      Wire.onRequest(requestEvent);
      Serial.begin(9600);
  }
  
  void loop() {
      delay(100);
      int sensorValue = analogRead(A0);
      int sensorValue1 = analogRead(A1);
      watt = sensorValue * (5 / 1023) * 2857;
      watt1 = sensorValue1 * (5 / 1023) * 2857;
      watt2 = map(watt, 0, 4294967295, 0, 255);
      watt3 = map(watt1, 0, 4294967295, 0, 255);
      Serial.println(watt2);
      Serial.println(watt3);
  }
  
  void requestEvent()
  {
      Wire.write(watt2);
      delay(30);
      Wire.write(watt3);
  }
  </code></pre>
  
  <p>And in the Raspberry Pi:</p>
  
  <pre><code>import smbus
  import time
  bus = smbus.SMBus(0)
  address = 0x1e
  while (1):
      watt=bus.read_byte_data(address,1)
      watt2=bus.read_byte_data(address,2)
  </code></pre>
  
  <p>I received the following error.</p>
  
  <blockquote>
    <p>Traceback (most recent call last):<br/>
      File "/home/pi/i2ctest.py" , line 8, in &lt;module><br/>
        watt = bus.read_byte_data(address,1)<br/>
    IOError: [Errno 5] Input/Output error<br/></p>
  </blockquote>
  
  <p>How do I fix this? Also, are there any alternatives for using I²C in Raspberry Pi other than the SMBus library?</p>