Write to the slave device *and I2C DOES NOT SEND STOP*
Read from the slave device immediately.
In this case it is a pressure sensor. Sequence:
Start Pressure measurement. Write Start Pressure Conversion Command
Wait 10 ms
Write "Read Sensor" command (No Stop bit must be sent after this command)
Read byte 1
Read byte 2
Read byte 3
My Code to test:
Code: Select all
def read_raw_pressure(self):
#Reads the uncompensated pressure from the sensor
self.i2c_bus.write_byte(self.addr, self.P_Res)
time.sleep(0.02) #20 ms pause
data_0, data_1, data_2 = self.i2c_bus.read_i2c_block_data(self.addr, self.ADC_Read, 3)
return((data_0 << 16) | (data_1<<8) | data_2)
def read_raw_temp(self):
#Reads and returns the uncompensated temperature from the sensor
self.i2c_bus.write_byte(self.addr, self.T_Res)
time.sleep(0.02) #20 ms pause
self.i2c_bus.write_byte(self.addr, self.ADC_Read)
data_0 = self.i2c_bus.read_byte(self.addr)
data_1 = self.i2c_bus.read_byte(self.addr)
data_2 = self.i2c_bus.read_byte(self.addr)
return((data_0 << 16) | (data_1<<8) | data_2)
read_raw_pressure does not write a command to fetch the result. It does return data but it is incorrect.
read_raw_temp initiates the conversion, writes the command to fetch the result, sends a stop bit, and then the I2C bus is unavailable.
Can one do a Write ->Repeated Start on the Raspberry Pi model 3B, if so is this a hack, if not how must I approach this?
Thanks in advance