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?
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:
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.