mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00: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:
		| @@ -107,9 +107,13 @@ 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); | ||||||
|  |  | ||||||
|  |     // in continuous mode, conversion will always be running, rely on the delay | ||||||
|  |     // to ensure conversion is taking place with the correct settings | ||||||
|  |     // can we use the rdy pin to trigger when a conversion is done? | ||||||
|  |     if (!this->continuous_mode_) { | ||||||
|       uint32_t start = millis(); |       uint32_t start = millis(); | ||||||
|       while (this->read_byte_16(ADS1115_REGISTER_CONFIG, &config) && (config >> 15) == 0) { |       while (this->read_byte_16(ADS1115_REGISTER_CONFIG, &config) && (config >> 15) == 0) { | ||||||
|         if (millis() - start > 100) { |         if (millis() - start > 100) { | ||||||
| @@ -120,6 +124,7 @@ float ADS1115Component::request_measurement(ADS1115Sensor *sensor) { | |||||||
|         yield(); |         yield(); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   uint16_t raw_conversion; |   uint16_t raw_conversion; | ||||||
|   if (!this->read_byte_16(ADS1115_REGISTER_CONVERSION, &raw_conversion)) { |   if (!this->read_byte_16(ADS1115_REGISTER_CONVERSION, &raw_conversion)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user