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

Add CS5460A power-meter component #1474

Merged
merged 6 commits into from May 31, 2021
Merged

Conversation

balrog-kun
Copy link
Contributor

Description:

CS5460A is a chip that calculates power, RMS current, voltage, energy
etc. and communicates over SPI. Easy to buy on a breakout board.

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#944

Checklist:

  • The code change is tested and works locally.
  • [kinda] Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@balrog-kun
Copy link
Contributor Author

Ok, thanks @glmnet. Doing all the work in set_timeout() callbacks now, loop() is empty and everything works.

After each measurement we schedule STATUS register reads (through SPI) at 0.8x the expected time left until next reading but not less than 30ms. So for example when we expect a new data at T + 1 second, we do an SPI read at:
T + 800ms
T + 960ms
T + 992ms
and then every 30ms until data ready or until 500ms have passed.

Also added runtime reset logic for when the device gets stuck for 15s, and added the usage of status_momentary_warning() on non-fatal errors.

@balrog-kun balrog-kun force-pushed the cs5460a branch 2 times, most recently from c425b3f to 6030452 Compare January 20, 2021 09:55
@balrog-kun balrog-kun force-pushed the cs5460a branch 3 times, most recently from 465c6e3 to 73378fe Compare March 3, 2021 08:20
CS5460A is a chip that calculates power, RMS current, voltage, energy
etc. and communicates over SPI.  Easy to buy on a breakout board.
@balrog-kun
Copy link
Contributor Author

balrog-kun commented Mar 3, 2021

Rebased on esphome/dev, added default device_class params to the sensor_schema() usages and added the CODEOWNERS tag.

@jesserockz jesserockz added this to In Review in ESPHome Dev May 19, 2021
@jesserockz jesserockz merged commit 4d586b1 into esphome:dev May 31, 2021
ESPHome Dev automation moved this from In Review to Done May 31, 2021
@balrog-kun balrog-kun deleted the cs5460a branch May 31, 2021 08:35
This was referenced Jun 9, 2021
This was referenced Jun 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants