With no supported PID for battery voltage on my car, I'm pulling it from my adapter via ATRV in my main OBD loop. Not a programmer and never used python, so wonder if there is a more elegant way to do this. Tried to build a custom command but as it's not an OBD response I couldn't make it work.
def obdStuff():
tic=time.time()
c = obd.OBD("/dev/rfcomm0", baudrate=115200)
time.sleep(1)
ser = Serial("/dev/rfcomm0", 115200, timeout=0.5)
while True:
toc=time.time()
try:
if toc-tic > 5:
ser.write(b'ATRV\r')
data_in = ser.read(ser.in_waiting)
if str(data_in, 'UTF8') !="":
#print("V is:", str(data_in, 'UTF8'))
client.publish("Voltage", str(data_in, 'UTF8'))
tic = time.time()
...
With no supported PID for battery voltage on my car, I'm pulling it from my adapter via ATRV in my main OBD loop. Not a programmer and never used python, so wonder if there is a more elegant way to do this. Tried to build a custom command but as it's not an OBD response I couldn't make it work.