mirror of
https://github.com/esphome/esphome.git
synced 2024-11-09 09:51:20 +01:00
Correct ADS1115 handling of multiple sensors in continuous mode (#2016)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
5c57b51378
commit
73ead5f328
@ -107,17 +107,22 @@ float ADS1115Component::request_measurement(ADS1115Sensor *sensor) {
|
|||||||
}
|
}
|
||||||
this->prev_config_ = config;
|
this->prev_config_ = config;
|
||||||
|
|
||||||
// about 1.6 ms with 860 samples per second
|
// about 1.2 ms with 860 samples per second
|
||||||
delay(2);
|
delay(2);
|
||||||
|
|
||||||
uint32_t start = millis();
|
// in continuous mode, conversion will always be running, rely on the delay
|
||||||
while (this->read_byte_16(ADS1115_REGISTER_CONFIG, &config) && (config >> 15) == 0) {
|
// to ensure conversion is taking place with the correct settings
|
||||||
if (millis() - start > 100) {
|
// can we use the rdy pin to trigger when a conversion is done?
|
||||||
ESP_LOGW(TAG, "Reading ADS1115 timed out");
|
if (!this->continuous_mode_) {
|
||||||
this->status_set_warning();
|
uint32_t start = millis();
|
||||||
return NAN;
|
while (this->read_byte_16(ADS1115_REGISTER_CONFIG, &config) && (config >> 15) == 0) {
|
||||||
|
if (millis() - start > 100) {
|
||||||
|
ESP_LOGW(TAG, "Reading ADS1115 timed out");
|
||||||
|
this->status_set_warning();
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
yield();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user