title: ESP8266 to ESP8266 i2C Communication
body: <p>I am trying to get my ESP8266's connect and send messages over an i2c bus. I am using a NodeMcu Development Board. Pins D1,D2 and GND are connected to each other.</p>
  
  <p>The code on my master is :</p>
  
  <pre><code>#include &lt;Wire.h&gt;
  
  void setup() {
    Wire.begin(D1,D2); // join i2c bus (address optional for master)
    Serial.begin(115200); 
  }
  
  byte x = 0;
  
  void loop() {
  
   Wire.beginTransmission(8);
    Wire.write(x);              // sends one byte
    Wire.endTransmission();    // stop transmitting
      Serial.println("Transmitted");
    x++;
    delay(500);
  }  
  </code></pre>
  
  <p>And the code on my slave ESP is:</p>
  
  <pre><code>#include &lt;Wire.h&gt;
  
  void setup() {
    Wire.begin(8);                // join i2c bus with address #8
    Wire.onReceive(receiveEvent); // register event
    Serial.begin(115200);           // start serial for output
  }
  
  void loop() {
    delay(100);
  }
  
  // function that executes whenever data is received from master
  // this function is registered as an event, see setup()
  void receiveEvent(int howMany) {
    Serial.println("Received..");
    /*
    while (1 &lt; Wire.available()) { // loop through all but the last
      char c = Wire.read(); // receive byte as a character
      Serial.print(c);         // print the character
    }
    */
    int x = Wire.read();    // receive byte as an integer
    Serial.println(x);         // print the integer
  }
  </code></pre>
  
  <p>Running this gives no output on the receiver chip.</p>