-
Notifications
You must be signed in to change notification settings - Fork 20
Description
hello, I'm working on a project where Im using the ads1115 with esp32 .
Im using ESPIDF v4.2 in let me know if you getting feel any update or need to change here.
// Select configuration register(0x01)
// AINP = AIN0 reading voltage
// Continuous conversion mode, 128 SPS(0xC1, 0x83)
hardware is fine and working I checked in Arduino IDE but here I'm only getting reading 0x5E, 0x5E
static esp_err_t i2c_master_sensor_test(i2c_port_t i2c_num, uint8_t *data_h, uint8_t *data_l)
{
int ret;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, 0x90, 0x01);
i2c_master_write_byte(cmd, 0x01, 0x01);
i2c_master_write_byte(cmd, 0xC1, 0x01);
i2c_master_write_byte(cmd, 0x83, 0x00);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret != ESP_OK) {
return ret;
}
vTaskDelay(30 / portTICK_RATE_MS);
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, 0x91, 0x01);
i2c_master_write_byte(cmd, 0x00, 0x01);
i2c_master_read_byte(cmd, data_h, 0x00);
i2c_master_read_byte(cmd, data_l, 0x01);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
printf(" >> data_h: %X\n", *data_h);
printf(" >> data_l: %X\n", *data_l);
return ret;
}