-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add new component mcp3426 7 8 #6675
base: dev
Are you sure you want to change the base?
Conversation
This reverts commit 7eac405.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #6675 +/- ##
==========================================
+ Coverage 53.70% 53.78% +0.07%
==========================================
Files 50 50
Lines 9408 9660 +252
Branches 1654 1704 +50
==========================================
+ Hits 5053 5196 +143
- Misses 4056 4140 +84
- Partials 299 324 +25 ☔ View full report in Codecov by Sentry. |
} | ||
) | ||
.extend(cv.COMPONENT_SCHEMA) | ||
.extend(i2c.i2c_device_schema(None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Devices with address pins still have a default address if the pins are left floating.
.extend(i2c.i2c_device_schema(None)) | |
.extend(i2c.i2c_device_schema(0x58)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but left floating the address is 0x68, like with grounded pins. Addressed it in a separate commit.
ESP_LOGCONFIG(TAG, "Setting up MCP3426/7/8..."); | ||
uint8_t anwser[3]; | ||
if (this->read(anwser, 3) != i2c::ErrorCode::NO_ERROR) { | ||
this->mark_failed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put useful error messages here so users can look back at logs and see why it failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added context that communication failed
// leave channel at 1, gain at 1x, and resolution at 12 bit | ||
|
||
if (this->write(&config, 1) != i2c::ErrorCode::NO_ERROR) { | ||
this->mark_failed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
ESP_LOGCONFIG(TAG, " Multiplexer: %u", this->multiplexer_); | ||
ESP_LOGCONFIG(TAG, " Gain: %u", this->gain_); | ||
ESP_LOGCONFIG(TAG, " Resolution: %u", this->resolution_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be converted back to the human friendly values that were entered in yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like I forgot to change this when I changed the numerical values of the enums. Fixed in a commit.
sda: 4 | ||
|
||
mcp3428: | ||
address: 0b1101000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use hex here to keep consistent with all other i2c examples.
address: 0b1101000 | |
address: 0x68 |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Co-authored-by: Jesse Hills <[email protected]>
Co-authored-by: Jesse Hills <[email protected]>
Co-authored-by: Jesse Hills <[email protected]>
Co-authored-by: Jesse Hills <[email protected]>
Not sure why |
What does this implement/fix?
Adds support for the 4 channel 16 bit ADC chips of the MCP3426/7/8 family. Structure is based on the ADS1115, but the measurement is done asynchronously.
Types of changes
Related issue or feature (if applicable): fixes -
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3810
Test Environment
Example entry for
config.yaml
:Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: