-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Update and improve INA226 usermod #5411
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
Changes from all commits
9fc745c
d2346d8
f571916
c06af7f
afc5e18
85c6da8
7bf8617
34466cc
97c6171
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ The following settings can be configured in the Usermod Menu: | |
| - **Decimals**: Number of decimals in the output. | ||
| - **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). | ||
| - **CurrentOffset**: Current offset in milliamps, subtracted from raw readings. Useful for compensating a consistent bias in the sensor. Default is 0. | ||
| - **MqttPublish**: Enable or disable MQTT publishing. | ||
| - **MqttPublishAlways**: Publish always, regardless if there is a change. | ||
| - **MqttHomeAssistantDiscovery**: Enable Home Assistant discovery. | ||
|
|
@@ -63,4 +64,30 @@ extends = env:esp32dev | |
| custom_usermods = ${env:esp32dev.custom_usermods} INA226 | ||
| build_flags = ${env:esp32dev.build_flags} | ||
| ; -D USERMOD_INA226_DEBUG ; -- add a debug status to the info modal | ||
| ``` | ||
| ``` | ||
|
|
||
| ### Compile-time Defaults | ||
|
|
||
| Several parameters can be overridden at compile time via `-D` build flags. This is useful for setting board-specific defaults so the device works correctly on first boot without manual configuration. | ||
|
|
||
| | Build Flag | Default | Unit | Description | | ||
| |---|---|---|---| | ||
| | `INA226_ADDRESS` | `0x40` | — | I2C address of the INA226 | | ||
| | `INA226_SHUNT_MICRO_OHMS` | `1000000` | μΩ | Shunt resistor value (1 000 000 μΩ = 1 Ω) | | ||
| | `INA226_DEFAULT_CURRENT_RANGE` | `1000` | mA | Expected maximum current (1000 mA = 1 A) | | ||
| | `INA226_CURRENT_OFFSET_MA` | `0` | mA | Current offset subtracted from readings | | ||
|
|
||
| Example for a board with a 4.8 mΩ shunt, 10 A range, and 53 mA offset: | ||
|
|
||
| ```ini | ||
| [env:my_board] | ||
| extends = env:esp32dev | ||
| custom_usermods = ${env:esp32dev.custom_usermods} INA226 | ||
| build_flags = ${env:esp32dev.build_flags} | ||
| -D USERMOD_INA226 | ||
| -D INA226_SHUNT_MICRO_OHMS=4800 | ||
| -D INA226_DEFAULT_CURRENT_RANGE=10000 | ||
| -D INA226_CURRENT_OFFSET_MA=53 | ||
| ``` | ||
|
|
||
| All compile-time defaults can still be changed at runtime through the Usermod settings page. | ||
|
Comment on lines
+69
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the MQTT/topic migration in this section. This PR intentionally renames 🤖 Prompt for AI Agents
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this belongs in the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A lightweight middle ground could be:
That way users who land on the README without reading the release notes are still warned. But if the project's convention is to keep only release notes for such notices, that's perfectly reasonable too — ultimately it's your call as the maintainer. 🧠 Learnings used |
||
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.
Use
%luformat specifier foruint32_t._checkIntervalMsisuint32_t, but%uis forunsigned int. While this works on ESP32/ESP8266 where both are 32-bit,%luis the correct portable specifier foruint32_t.Proposed fix
🤖 Prompt for AI Agents