Hello,
I am trying to understand code in a library for a temperature and humidity sensor. The Library works correctly but I do not understand how. The function to write commands to the sensor is:
void Adafruit_SHT31::writeCommand(uint16_t cmd) {
Wire.beginTransmission(_i2caddr);
Wire.write(cmd >> 8);
Wire.write(cmd & 0xFF);
Wire.endTransmission();
}
My question about this snippet of code:
-
The address for the device is 0x44 (1000100) which is 7 bit; according to the data sheet the 8th bit should be 1 if reading and 0 if writing, where is this assigned in the code since the only thing given to Wire.beginTransmission was a 7 bit address?
-
Lets say that cmd in this example is 0x30A2 (0011000010100010) which is a reset command for the sensor. I understand that the two write commands are giving the MSB and the LSB but how? The argument to the write functions are still 16 bits long just with the first 8 bits all 0. Why not just send cmd by itself in one line? i.e. Wire.write(cmd);
Thanks in advance for any help you may provide.