integrated with I2C code