-->
Page 1 of 1

LoLin on I2C as slave

PostPosted: Thu Sep 01, 2016 9:00 am
by ramiress
Hello!
I was trying to link two modules together on the I2S and I did not succeed. It turned out that the module is configured as a slave, is not determined by the scanner. In this case both modules work with third-party devices normally.
My code for slave device:
Code: Select all#include <Wire.h>

void setup() {
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // 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) {
  while (1 < 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
}

Re: LoLin on I2C as slave

PostPosted: Thu Sep 01, 2016 1:28 pm
by martinayotte
ESP Wire library doesn't support Slave mode yet ...

Re: LoLin on I2C as slave

PostPosted: Fri Feb 15, 2019 9:04 am
by Gotfredsen
ESP8266 to ESP8266 over I2C works from 2.5.0: See my comments here at the ESP8266 GitHub