Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic implementation of I2C ADC extenders like ADS1115, ADC121 #1033

Open
hyteoo opened this issue Jul 6, 2018 · 3 comments
Open

Generic implementation of I2C ADC extenders like ADS1115, ADC121 #1033

hyteoo opened this issue Jul 6, 2018 · 3 comments
Labels
enhancement New feature or request sensors
Milestone

Comments

@hyteoo
Copy link
Contributor

hyteoo commented Jul 6, 2018

Although there is support for I2C ADC extenders, they are implemented for energy measurement.

Would it be a good idea to just have like a generic ADS1x15 with raw outputs (like the internal ESP8266 ADC), to be used for whatever (voltage measurement, NTC, etc)?

@hyteoo hyteoo changed the title Generic use of I2C ADC extenders liek ADS1115, ADC121 Generic implementation of I2C ADC extenders like ADS1115, ADC121 Jul 6, 2018
@xoseperez xoseperez added enhancement New feature or request sensors labels Jul 10, 2018
@xoseperez xoseperez added this to the 1.14.0 milestone Jul 10, 2018
@flashy02
Copy link

flashy02 commented Nov 3, 2018

Hi, the same issue here. I've bought an ADS1115 to use it as 4 Channel analog Input like the A0 from the ESP8266. It would be nice to get this feature. Thanks.

@xoseperez
Copy link
Owner

See also #199 and #1311

mcspr added a commit that referenced this issue Jun 23, 2021
ref. #1033, this could be used as-is with a generic analog sensor code
by substituting ::analogRead(channel) with I2CPort::read(channel)
@mcspr
Copy link
Collaborator

mcspr commented Jun 23, 2021

As referenced in the commit, there is now EmonADS1X115Sensor::I2CPort:

auto port = std::make_shared<EmonADS1X15Sensor::I2CPort>(
EMON_ADS1X15_I2C_ADDRESS, EMON_ADS1X15_TYPE, EMON_ADS1X15_GAIN, EMON_ADS1X15_DATARATE);

where I2CPort::read(N) is effectively an analogRead(N)

Only noticed the issue after the fact though. I guess it could be further modified as something virtual once again so there's a generic virtual unsigned int Class::analogRead(int channel);, but not inheriting from the BaseSensor stuff.
edit: or, make it chain with baseanalogsensor, and simply make another class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sensors
Projects
None yet
Development

No branches or pull requests

4 participants