i2c bit order
Posted: Sat Oct 29, 2016 6:36 am
Don't know if I'm doing anything wrong or if it's a bug/feature.
I'm having a ESP-01 as i2c master and a Arduino Pro Mini 3.3V 8Mhz as slave.
I can scan the i2c bus and find the Pro Mini slave.
But when i request a response from the slave the bit order of the respons is reversed.
On the ESP-01 Master:
This outputs the bytes "0" and "127" on the serial monitor.
On the Arduino slave:
This of course outputs the bytes "0" and "1" on the serial monitor.
So basically, if the slave sends "00000001" but the master receives "10000000";
Is this a known fact or am I doing something wrong?
I'm having a ESP-01 as i2c master and a Arduino Pro Mini 3.3V 8Mhz as slave.
I can scan the i2c bus and find the Pro Mini slave.
But when i request a response from the slave the bit order of the respons is reversed.
On the ESP-01 Master:
Code: Select all
Serial.print("Request from slave, ");
err = Wire.requestFrom(i2cSlaveDeviceId, 2); // request 2 bytes from slave device
Serial.print(err);
Serial.print(" bytes received: ");
while(Wire.available()) { // slave may send less than requested
byte b = Wire.read(); // receive a byte as character
Serial.print(b,DEC); // print the character value
Serial.print(" ");
}
This outputs the bytes "0" and "127" on the serial monitor.
On the Arduino slave:
Code: Select all
byte buffer[] = {0,1};
Serial.flush();
Serial.print("i2c send: ");
Serial.print(buffer[0],DEC);
Serial.print(" ");
Serial.println(buffer[1],DEC);
Wire.write(buffer,2);
This of course outputs the bytes "0" and "1" on the serial monitor.
So basically, if the slave sends "00000001" but the master receives "10000000";
Is this a known fact or am I doing something wrong?