Can't find ESP on Wire

I tried using GPIO 4/5 Data/Clock for wire on my ESP8266 12E and a wire scanner on an Uno can't find it. It only finds my LCD display. Is there anything else I need to do to get Wire working on the ESP8266?

13:02:01.578 -> Scanning...
13:02:01.578 -> No I2C devices found
13:02:01.578 ->

Code on ESP8266

// Wire Master Reader
// by devyte
// based on the example of the same name by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Reads data from an I2C/TWI slave device
// Refer to the "Wire Slave Sender" example for use with this

// This example code is in the public domain.


#include <Wire.h>
#include <PolledTimeout.h>

#define SDA_PIN 4
#define SCL_PIN 5
const int16_t I2C_MASTER = 0x42;
const int16_t I2C_SLAVE = 0x08;

void setup() {
  Serial.begin(115200);  // start serial for output
  Wire.begin(SDA_PIN, SCL_PIN, I2C_MASTER);        // join i2c bus (address optional for master)
}

void loop() {
  using periodic = esp8266::polledTimeout::periodic;
  static periodic nextPing(1000);

  if (nextPing) {
    Wire.requestFrom(I2C_SLAVE, 6);    // request 6 bytes from slave device #8

    while (Wire.available()) { // slave may send less than requested
      char c = Wire.read(); // receive a byte as character
      Serial.print(c);         // print the character
    }
  }
}

Code on Uno

#include <Wire.h>
 
 
void setup()
{
  Wire.begin();
 
  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  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("Unknown 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
}

https://arduino-esp8266.readthedocs.io/en/latest/libraries.html#i2c-wire-library

master only

I did everything and I still can't get it to be picked up by a wire scanner! I tried both the ESP8266 and ESP32S and made sure I set pins correctly. Still, no go. It only finds the LCD at 0x27. I even am using a LLC so voltages are properly shifted. I've been working on this for hours trying new pins, flipping SDA and SCL, tried disconnecting the LCD, etc... please help me.

14:58:23.670 ->  Scanning I2C Addresses
14:58:23.670 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. 27 .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.704 -> .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 
14:58:23.737 -> Scan Completed, 1 I2C Devices found.
14:58:23.737 -> 
14:58:23.737 -> Discovering eeprom sizes 0x50..0x57
14:58:23.805 -> 0x50: Not Present.
14:58:23.941 -> 0x51: Not Present.
14:58:24.009 -> 0x52: Not Present.
14:58:24.110 -> 0x53: Not Present.
14:58:24.211 -> 0x54: Not Present.
14:58:24.312 -> 0x55: Not Present.
14:58:24.413 -> 0x56: Not Present.
14:58:24.515 -> 0x57: Not Present.

I know, I'm using master reader to setup the ESP32S with pins 21 and 22 but still no luck.

mattlogue:
I know, I'm using master reader to setup the ESP32S with pins 21 and 22 but still no luck.

i2c scanner can run only on master

Here is what I'm using. Is this appropriate to scan from an Uno to find an ESP?

Also, when ran on the ESP, i2cScanner reports Zero devices (doesn't see Uno or LCD). I have the thing hooked up on Uno side on pins A4/5 and past two pullup resistors, then into LLC -> 3.3V then into pins 21 and 22 on the ESP32S. The LCD is hooked up to Uno pins SDA/SCL. What on earth am I doing wrong?

/* I2C slave Address Scanner
for 5V bus
 * Connect a 4.7k resistor between SDA and Vcc
 * Connect a 4.7k resistor between SCL and Vcc
for 3.3V bus
 * Connect a 2.4k resistor between SDA and Vcc
 * Connect a 2.4k resistor between SCL and Vcc

 */

#include <Wire.h>

void scan(){
Serial.println(" Scanning I2C Addresses");
uint8_t cnt=0;
for(uint8_t i=0;i<128;i++){
  Wire.beginTransmission(i);
  uint8_t ec=Wire.endTransmission(true);
  if(ec==0){
    if(i<16)Serial.print('0');
    Serial.print(i,HEX);
    cnt++;
  }
  else Serial.print("..");
  Serial.print(' ');
  if ((i&0x0f)==0x0f)Serial.println();
  }
Serial.print("Scan Completed, ");
Serial.print(cnt);
Serial.println(" I2C Devices found.");
}

bool i2cReady(uint8_t adr){
uint32_t timeout=millis();
bool ready=false;
while((millis()-timeout<100)&&(!ready)){
  Wire.beginTransmission(adr);
  ready=(Wire.endTransmission()==0);
  }
return ready;
}

void eepromSize(){
Serial.println("Discovering eeprom sizes 0x50..0x57");
uint8_t adr=0x50,i;
uint16_t size;
char buf[64];
while(adr<0x58){
  i=0;
  size = 0x1000; // Start at 4k
  i += sprintf_P(&buf[i],PSTR("0x%02X: "),adr);
  if(i2cReady(adr)) { // EEPROM answered
    uint8_t zeroByte;
    Wire.beginTransmission(adr);
    Wire.write((uint8_t)0); // set address ptr to 0, two bytes High
    Wire.write((uint8_t)0); // set address ptr to 0, two bytes Low
    uint8_t err=Wire.endTransmission();
    if(err==0){// worked
      err=Wire.requestFrom(adr,(uint8_t)1);
      if(err==1){// got the value of the byte at address 0
        zeroByte=Wire.read();
        uint8_t saveByte,testByte;
        do{
          if(i2cReady(adr)){
            Wire.beginTransmission(adr);
            Wire.write(highByte(size)); // set next test address
            Wire.write(lowByte(size));
            Wire.endTransmission();
            err=Wire.requestFrom(adr,(uint8_t)1);
            if(err==1){
              saveByte=Wire.read();
              Wire.beginTransmission(adr);
              Wire.write(highByte(size)); // set next test address
              Wire.write(lowByte(size));
              Wire.write((uint8_t)~zeroByte); // change it
              err=Wire.endTransmission();
              if(err==0){ // changed it
                if(!i2cReady(adr)){
                  i+=sprintf_P(&buf[i],PSTR(" notReady2.\n"));
                  Serial.print(buf);
                  adr++;
                  break;
                  }
                Wire.beginTransmission(adr);
                Wire.write((uint8_t)0); // address 0 byte High
                Wire.write((uint8_t)0); // address 0 byte Low
                err=Wire.endTransmission();
                if(err==0){
                  err=Wire.requestFrom(adr,(uint8_t)1);
                  if(err==1){ // now compare it
                    testByte=Wire.read();
                    }
                  else {
                    testByte=~zeroByte; // error out
                    }
                  }
                else {
                  testByte=~zeroByte;
                  }
                }
              else {
                testByte = ~zeroByte;
                }
              //restore byte
              if(!i2cReady(adr)){
                i+=sprintf_P(&buf[i],PSTR(" notReady4.\n"));
                Serial.print(buf);
                adr++;
                break;
                }
              
              Wire.beginTransmission(adr);
              Wire.write(highByte(size)); // set next test address
              Wire.write(lowByte(size));
              Wire.write((uint8_t)saveByte); // restore it
              Wire.endTransmission();
              }
            else testByte=~zeroByte;
            }
          else testByte=~zeroByte;
          if(testByte==zeroByte){
            size = size <<1;
            }
          }while((testByte==zeroByte)&&(size>0));
        if(size==0) i += sprintf_P(&buf[i],PSTR("64k Bytes"));
        else i+=sprintf_P(&buf[i],PSTR("%dk Bytes"),size/1024);
        if(!i2cReady(adr)){
          i+=sprintf_P(&buf[i],PSTR(" notReady3.\n"));
          Serial.print(buf);
          adr++;
          continue;
          }
        Wire.beginTransmission(adr);
        Wire.write((uint8_t)0); // set address ptr to 0, two bytes High
        Wire.write((uint8_t)0); // set address ptr to 0, two bytes Low
        Wire.write(zeroByte);  //Restore
        err=Wire.endTransmission();
        }
      else i+=sprintf_P(&buf[i],PSTR("Read 0 Failure"));
      }
    else i+=sprintf_P(&buf[i],PSTR("Write Adr 0 Failure"));
      
    }
  else i+=sprintf_P(&buf[i],PSTR("Not Present."));
  Serial.println(buf);
  adr++;
  }
}

void setup(){
Serial.begin(115200);
Wire.begin();
scan();
Serial.println();
eepromSize();
}

void loop(){}

Now it can find the LCD THRU the Uno, but not the Uno itself! How weird is that? That confirms the pins are right.

I nedd to learn difference between i2c slave and master.

I can't even get wire working from an ESP8266 to an ESP32. I put the scanner (master mode) on the ESP32 and it does not find anything although a ESP8266 is connected.

mattlogue:
Now it can find the LCD THRU the Uno, but not the Uno itself! How weird is that? That confirms the pins are right.

it is a bus. master can find slaves on the bus. A4 is SDA and A5 is SCL. this Uno pins are wired together.

do you run Wire library in slave mode in Uno?

I got it working for a second on the ESP32 with wire slave on Uno, but when I changed to ESP8266 it couldn't find the uno.

Esp are 3.3V. Uno is 5V. Maybe you need to use logic level converters.

I had a defective LLC I think. Halfway through my testing last night I stopped using it. I also tend to think an LLC protects the ESP more than it facilitates communication. I may try using another LLC, kind of gave up on Wire and went back to Serial for time being. Wire isn't easy to get working, that's for damned sure.