I am trying to read 16bit from register on BME280 using esp idf i2c api's
till now i did the following
Code: Select all
uint8_t coe11,coe21;
uint8_t* coe1=&coe11;
uint8_t* coe2=&coe21;
int cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, BME280_ADDRESS << 1 | WRITE_BIT, ACK_CHECK_EN);
i2c_master_write_byte(cmd, BME280_ADDRESS << 1 | WRITE_BIT, ACK_CHECK_EN);
i2c_master_write_byte(cmd, BME280_REGISTER_DIG_T1 , ACK_CHECK_EN);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret == ESP_FAIL) {
return ret;
}
vTaskDelay(30 / portTICK_RATE_MS);
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, BME280_ADDRESS << 1 | READ_BIT, ACK_CHECK_EN);
i2c_master_read_byte(cmd, coe1, ACK_VAL);
i2c_master_read_byte(cmd, coe2, ACK_VAL);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
printf("status: %02x\n", coe11);
printf("status: %02x\n", coe21);
could anyone let me know how to read 16bit from BME280