Hello everyone
Measurement of power and energy is relatively well known, there are a lot of DIY measuring systems and the meters themselves. But most often it concerns significant power ... above 1W. When building battery-powered systems, and additionally with a hasvesty energy type, you can talk about the power in mW. And the dynamics will appear asie a few seconds, a few watts and then a mile. In trying to solve this problem based on your hardware, it turned out to be a minor problem. The UNI-T UT71E multimeter does have an adapter, but for 230V and probably kW I also have a RIGOL DM3058E. Good multimeter, but in the manual not a word about power measurement ... It has the ability to measure two quantities (2ND). The meter itself cannot do anything about it, except for the display, but ... when connected to a computer, many possibilities open up that I would like to share.
The RIGOL DM3058E multimeter, after connecting via USB, can be operated, among others, by VISA (
https://pl.wikipedia.org/wiki/Virtual_Instrument_Software_Architecture)
After analyzing the documentation,
https://www.batronix.com/pdf/Rigol/ProgrammingGuide/DM3058_ProgrammingGuide_EN.pdfI have created a program that supports the meter by carrying out long-term measurements, e.g. battery capacity, energy consumption of measurement systems ...
The first approach in Labview, - due to reporting and integration with other elements.
The second approach in Python - for stability reasons
Of course, the topic is trivial, it involves sending a few commands to the meter and reading the answer, but, ... I didn't find the ready, so I'm sharing it
import pyvisa
import time
rm = pyvisa.ResourceManager()
print(rm.list_resources()) # select the appropriate port and enter it below
inst = rm.open_resource('USB0::0x1AB1::0x09C4::DM3R221100226::INSTR') # this is an example port from my resource
print(inst.query("*IDN?"))
#inst.write(":FUNCtion:VOLTage:DC") # ustawienie na 1 VDC
print(inst.query(":FUNCtion?"))
#inst.write(":FUNCtion2:CURRent:DC") # ustawienie na 2 VDC
# the rest of the configuration in https://www.batronix.com/pdf/Rigol/ProgrammingGuide/DM3058_ProgrammingGuide_EN.pdf
try:
while True:
dcvolt=float(inst.query(":FUNCtion2:VALUe1?"))
dccur=float(inst.query(":FUNCtion2:VALUe2?"))
print()
print(" Voltage = ",dcvolt," Current = ",dccur, " power = ",dcvolt*dccur)
time.sleep(1)
except KeyboardInterrupt:
print("Press Ctrl-C to terminate while statement")
pass