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 INA226 usermod for reading current and power over i2c #3986

Merged
merged 5 commits into from
May 21, 2024

Conversation

LordMike
Copy link

@LordMike LordMike commented May 17, 2024

This pull request introduces a new usermod for integrating the INA226 voltage, current and power sensors into WLED. It uses the wollewald/INA226_WE library to handle the wire stuff, and implements settings like (more options in readme):

  • I2CAddress: The I2C address in decimal. Default is 64 (0x40).
  • CheckInterval: Number of seconds between readings. This should be higher than the time it takes to make a reading, determined by the two next options.
  • INASamples: The number of samples to configure the INA226 to use for a measurement. Higher counts provide more accuracy.
  • INAConversionTime: The time to use on converting and preparing readings on the INA226. Higher times provide more precision.
  • ShuntResistor: Shunt resistor value in milliohms. An R100 shunt resistor should be written as "100", while R010 should be "10".
  • CurrentRange: Expected maximum current in milliamps (e.g., 5 A = 5000 mA).

It also implements MQTT publishing and HA discovery documents.

Images:

@LordMike
Copy link
Author

LordMike commented May 17, 2024

As this is likely to be used to measure currents and powers of the lights WLED controls, would it make sense to react to changes in the effects, on/off, brightness and then trigger a measurement, regardless of what interval is set?

F.ex. if I set the brightness to something new, then ~2 seconds later I get a measurement - even if I just got one on an interval of 60 seconds. Effects will always have the possibility of being dynamic, so it's not going to become more "true" because of this, but maybe more responsive.

If so, how would I hook into relevant events?

@blazoncek blazoncek merged commit c1fed6d into Aircoookie:0_15 May 21, 2024
18 checks passed
@LordMike
Copy link
Author

No notes? Wild. :)

@LordMike LordMike deleted the feature/ina226_usermod branch May 27, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants