Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get voltage from adapter while connected to vehicle #233

Open
rack201 opened this issue Dec 25, 2021 · 1 comment
Open

Get voltage from adapter while connected to vehicle #233

rack201 opened this issue Dec 25, 2021 · 1 comment

Comments

@rack201
Copy link

rack201 commented Dec 25, 2021

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()
                    ...
@incense
Copy link

incense commented Jan 18, 2022

The following might be what you have been looking for:
cmd = obd.commands.ELM_VOLTAGE
(found in commands.py).
Haven't tested it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants