ESP32 Sends weird stuff on I2C

So i have a simple I2C use in my project but if i measure the data with a scope it shows absolutely something different than what I’m trying to send. Can anyone help?

This is the decoded data on the scope in I2C Mode.

TwoWire myBus = TwoWire(2);
myBus.begin(I2C_SDA, I2C_SCL, 100000);
    myBus.beginTransmission(0x01);
    myBus.write(0xFF); 
    myBus.endTransmission(1);

That’s the stuff i have in the code…

Did you test this in an absolutely minimal sketch with nothing else going on?

Does this also appear then in the Arduino IDE? If yes → Issues · espressif/arduino-esp32 · GitHub

Hi,

No, but i did test it with a TCN75A library and with the exact same bus. That way it works fine, but as soon as i try to use the

myBus.Write()

nothing works anymore…

In the library the code looks like this:

float TCN75A::readTemperature(){
  float data[1];
  _wire->beginTransmission(_adr);
  _wire->write(0x00);
  _wire->endTransmission(false);
  _wire->requestFrom(_adr,uint8_t(2)); //need 2 btyes
  //force data to fit with int8_t then convert it to float
  data[0] = float(int8_t(_wire->read()));
  //now with problem
  data[1] = float((uint8_t(_wire->read() >> 4)) / 16.0); //IS THAT EASY ??? REALLY!?
  _wire->endTransmission();
  return data[0] + data[1];
}

and mine is just these three lines:

esp.beginTransmission(0xAA);
esp.write(0xEC);
esp.endTransmission(false);

I really don’t know any further here…

This is a buffer overflow… float data[1] is an array of length one, meaning only index 0 is valid. But it’s writing to index 1 as if it was a 2 element array.

1 Like