Sparkfun CSS811 Reading HW ID

vibnwis
Posts: 89
Joined: Thu Aug 24, 2017 1:13 am

Sparkfun CSS811 Reading HW ID

Postby vibnwis » Sun Sep 10, 2017 2:11 am

Hi there,

I have a Sparkfun combo CCS811/BME280 board. I managed to get the program working on BME280 chips. HOwever, don't have much luck on CCS811.

I revert my work to the very initial by reading the hardware ID to make sure I have got the communication between the host and CCS811 setup as it should. For the same routine i used to read the hardward ID on BME280, but modified to suit CCS811, ie, the routine is proven working on BME280 ( See below). The results of the routine, 0x2e, which is not 0x81 as expected. My questions are:
1) Has anyone experienced this?
2) I read about someone use having problems reading through I2C, but resolved it by strecthing the SCL. HOw is it done using esp32-idf i2c routines?

Appreciate any comments.

Thank you
Vi



com_rslt = CCS811_I2C_bus_read(CCS811_I2C_ADDRESS, CCS811_CHIP_ID_REG, ccs811_i2c_buff, 1);
ESP_LOGE(TAG_CCS811, "CCS811_init: %d CCS811_I2C_bus_read() = %x result = 0x%X", loop_cnt, ccs811_i2c_buff[0], com_rslt);

reading is E (19149) CCS811: CCS811_init: 19 CCS811_I2C_bus_read() = 2e result = 0x0
and the routne
s8 CCS811_I2C_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
{
s32 iError = BME280_INIT_VALUE;
esp_err_t espRc;

i2c_cmd_handle_t cmd = i2c_cmd_link_create();

i2c_master_start(cmd);
i2c_master_write_byte(cmd, (dev_addr << 1) | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, reg_addr, true);

i2c_master_start(cmd);
i2c_master_write_byte(cmd, (dev_addr << 1) | I2C_MASTER_READ, true);

if (cnt > 1) {
i2c_master_read(cmd, reg_data, cnt-1, CCS811_I2C_MASTER_ACK);
}
i2c_master_read_byte(cmd, reg_data+cnt-1, CCS811_I2C_MASTER_NACK);
i2c_master_stop(cmd);

espRc = i2c_master_cmd_begin(I2C_NUM_0, cmd, 10/portTICK_PERIOD_MS);
if (espRc == ESP_OK) {
iError = SUCCESS;
} else {
iError = FAIL;
}

i2c_cmd_link_delete(cmd);

return (s8)iError;
}

vibnwis
Posts: 89
Joined: Thu Aug 24, 2017 1:13 am

Re: Sparkfun CSS811 Reading HW ID

Postby vibnwis » Sun Sep 10, 2017 3:46 am

Hm.. Having reduced the I2C bus speed from 1Mhz to 400Khz, I got the correct reading immediately.

Who is online

Users browsing this forum: EG1966 and 99 guests