Package: voltOTG
voltOTGPython class to interface with a USB volt meter named voltOTGBackgroundWhile surfing online I spotted a15$ volt metercalled "voltOTG" from china that connects to a smartphone, I thought it sounded fun and ordered it.When I got it I started playing with it in the android app and saw some potential for use with for example a raspberry pi for logging voltages. So I reversed engineered the usb communications and wrote them up as a python classHow to useBasicAutomatically connect to the voltOTG readerimportvoltotgreader=voltotg.voltOTG()reader.autoConnect()Manually connectimportvoltotgreader=voltotg.voltOTG()reader.connectDevice("/dev/tt...")Reading and printing the voltage every 10 secondsimportvoltotgfromtimeimportsleepreader=voltotg.voltOTG()reader.autoConnect()whileTrue:volts=reader.reatVolt()print(volts)sleep(10)Execute serial command (basic)importvoltotgreader=voltotg.voltOTG()reader.autoConnect()command="ReadVersion"reply=reader.bcom(command)print(reply)Execute serial command (With empty reply fail-safe*)importvoltotgreader=voltotg.voltOTG()reader.autoConnect()command="ReadVersion"reply=reader.scom(command)print(reply)Commands avaivable within voltOTGvoltOTG commandserial commandExplinationscom (command)N/AExecutes a serial command, returns the reply, even if emptybcom (command)N/AExecutes a serial command, retries if the reply is empty. Returns the reply or errorconnectDevice(devicePath)N/AAttemps to connect to a specified devicefindDevice()N/ALooks for a voltOTG device by matching the VID:PIDautoConnect()N/ARuns findDevice() and uses the reply to connectDevice()getVersion(none,list,version,name) (1)ReadVersionReturns the device version, by default it returns just the versionreadVolt(none,list,voltage,info,raw) (2)ReadVoltOnly returns the voltage read by the device by defaultreadScale(none,list,scale,calib,raw) (3)ReadScaleOnly returns the scale value by defaultsetScale(float,int)SetScale:int,float>Sets the scale value, whatever that isreadPga()ReadPgaReturns the PGA, not that I have any idea what it doessetPga(1,2,4,9)SetPga:int>"Sets the PGA, which does something I assumereadMode()ReadModeReturns the mode versionsetMode(0,1)SetMode:int>Sets the mode, if only I had any idea what the modes are(1): getVersion() will return the version number, getVersion(list=True) will provide both version and name, getVersion(name=True) will return the name only, getVersion(version=True) will do the same as providing no argument(2):readVolt() will return a voltage reading in mV, readVolt(list=True) will provide more info from the command, readVolt(raw=True) will return the raw reply from the device, readVolt(info=True) returns a weird one-off inside-the-code documentation, readVolt("voltage=True") does the same as no arguments,(3) readScale() will return the scale value, readScale(list=True) will return a list of scale and calib, readScale(raw=True) will return the raw reply from the device, readScale(calib=True) will return the calib value, readScale(scale=True) does the same as providing no argumentCommands on device not in voltOTGDue to me having no idea how to handle consistant data streams the first 2 commands were not implemented in the package, the last one was simply left out since I thought it was a bad idea to implement an automatic Zero-ing function, not sure if I agree with that anymore though ........CommandExplinationSetAutoSend:1>Activates a command that causes the device to send about 1 volt reading per second until it is told to stopSetAutoSend:0>Deactivates the AutoSend feature of the deviceSetZeroCauses the device to take the current reading and set it as the zero point for future reads. "reader.bcom("SetZero") would run this command