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

Sensor INA219: Use optional i2c_bus_num #328

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mqtt_io/modules/sensor/ina219.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# - gain (40, 80, 160 or 320) -> maximum shunt voltage (milli volt)
# Optional:
# - low_power: send ina219 to sleep between readings
# - i2c_bus_num: if auto detection fails - like on Pi4

# Output:
# - power (in watt)
Expand All @@ -30,7 +31,8 @@
REQUIREMENTS = ("pi-ina219",)
CONFIG_SCHEMA: CerberusSchemaType = {
"chip_addr": dict(type="integer", required=True),
"shunt_ohms": dict(type="float", required=False, empty=False, default=100),
"i2c_bus_num": dict(type="integer", required=False, default=1),
"shunt_ohms": dict(type="float", required=False, empty=False, default=0.1),
"max_amps": dict(type="float", required=False, empty=False),
"voltage_range": dict(
type="integer", required=False, empty=False, allowed=[16, 32], default=32
Expand Down Expand Up @@ -71,6 +73,7 @@ def setup_module(self) -> None:
self.config["shunt_ohms"],
max_expected_amps=self.config.get("max_amps"),
address=self.config["chip_addr"],
busnum=self.config["i2c_bus_num"],
)

## Configure ina sensor with range and gain from config or default
Expand Down
Loading