Closed Micha-123 closed 1 year ago
Possible if you specify which options in which form is needed... selector/textbox/numeric box with Integers/Floats, possible values, ranges... as i do not use INA219 since it is implemented i have no idea about its parameters. Although i can find out myself, if there is a plenty of time...
#!/usr/bin/env python
from ina219 import INA219
from ina219 import DeviceRangeError
SHUNT_OHMS = 0.1
MAX_EXPECTED_AMPS = 0.2
def read():
ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
ina.configure(ina.RANGE_16V, ina.GAIN_2_80MV, ina.ADC_128SAMP)
thats my simple script
SHUNT_OHMS -> Textbox MAX_EXPECTED_AMPS -> Textbox
ina.RANGE_16V / ina.Range_32V -> selector of the two possible values
ina.GAIN_AUTO / ina.GAIN_1_40MV / ina.GAIN_2_80MV / ina.GAIN_4_160MV / ina.GAIN_8_320MV -> selector 5 values
ina.ADC_9BIT / ina.ADC_10BIT / ina.ADC_11BIT / ina.ADC_12BIT / ina.ADC_2SAMP / ina.ADC_4SAMP / ina.ADC_8SAMP / ina.ADC_16SAMP/ ina.ADC_32SAMP / ina.ADC_64SAMP / ina.ADC_128SAMP -> Selector with 11 values
on that
https://pypi.org/project/pi-ina219/
are all possible values of the ina,
Its very interesting, that these constants are only available after creating a live INA219 object.. i can add it, but these options wont appear on first adding of the plugin, only after the second.
MAX_EXPECTED_AMPS is already added and selectable in mA.
SHUNT_OHMS is a float, not a text, but i have no idea what is the range it can accept, pi-ina219 project has no information about that
the shunt ohms can only be set as 0,1 or 0.01
my shunt ohms is 0,000357 ohm (yes it is realy low, its an 200A shunt) and yes ina can do this, now i running a simple script and it reads realy good.
on yours i cannot set the shunt ohms for my shunt now.
`from ina219 import INA219 from ina219 import DeviceRangeError import urllib.request as urllib2 import json
SHUNT_OHMS = 0.000375 MAX_EXPECTED_AMPS = 200
def read():
ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
# (either up to 16V or up to 32V with .RANGE_32V)
# Also, configure the gain to be GAIN_2_80MW for the above example
ina.configure(ina.RANGE_16V, ina.GAIN_2_80MV, ina.ADC_128SAMP, ina.ADC_128SAMP)
# Prints the values to the console
print("%.2f" % ina.voltage()) try: print("%.2f" % (ina.current()/1000)) print("%.2f" % ina.shunt_voltage()) except DeviceRangeError as e: print("Current overflow")
if name == "main": read()`
thats my script.
you see ina.configure(ina.RANGE_16V, ina.GAIN_2_80MV, ina.ADC_128SAMP, ina.ADC_128SAMP)
it is double, yes 1x for bus_adc and the second for shunt_adc
Yep addFormFloatNumberBox() only supports input with 2 digits... another input method may be needed for values smaller than 0.01. This was the primary reason i asked for ranges.
Dropped forcing number format, changed to free text input at commit https://github.com/enesbcs/rpieasy/commit/b14193308604bad16edb7f5789e6e30ab628b363
is it possible to add settings like, shunt ohms, (now i have adit it in _P027_INA219.py file also wil be fine to have the Gain and ADC funktion.
i use an external shunt 200Amps, 75mΩ (0,075Ω) and it wil be fine to set it to ADC_128SAMP
in the simple script i have it like
ina.configure(ina.RANGE_16V, ina.GAIN_2_80MV, ADC_128SAMP)
from this site https://pypi.org/project/pi-ina219/