adafruit / adafruit/Adafruit_CircuitPython_INA219

Some variables are class descriptors instead of instance variables

Open
#38 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
28
Forks
27
PR merge metrics
No merged PRs in 30d

Description

I am using 18 INA219 boards in parallel using 3 [PCA9548 multiplexers](https://www.adafruit.com/product/5626) and the `threading` Python package, and I am running triggered measurements.

So I create a few instances of the INA219 class and then I send triggers to them, check when the measurements are ready and fetch the measurement data.

The problem I observed is that `conversion_ready` is a class variable, as defined here outside of the `__init__` function:

https://github.com/adafruit/Adafruit_CircuitPython_INA219/blob/66dc89e1b1ecc12e79011484092cbecf342cf601/adafruit_ina219.py#L177

So the value will not be instance-specific and all the INA219 objects will share the same values for `conversion_ready`. Clearly, this is a problem for me.

In the same way, I suspect I can have the same issue also with the other data I acquire from the INA219 boards, no?

For example, also the `bus_voltage` property relies on the `raw_bus_voltage` class variable and the `current` property relies on the `raw_current` class variable. Should I expect the same issue also for these?

https://github.com/adafruit/Adafruit_CircuitPython_INA219/blob/66dc89e1b1ecc12e79011484092cbecf342cf601/adafruit_ina219.py#L176-L182

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in adafruit_ina219.py around lines 176-182 and inspect how conversion_ready, raw_bus_voltage, and raw_current are defined and accessed. Check that each INA219 instance keeps separate measurement state, then verify the affected properties behave independently when multiple instances are used.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.