-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fix for #203 batteryVoltage() returns zero #204
Conversation
Needs fix for parsing.
Next task, update foundCodes[] array properly.
Next do cleanup on debug messages
…mber of current DTC codes.
…o MIL_status_example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WTH am I doing wrong that every PR includes a whack of old commits!? This fix was only one commit and one new example program file.
Idk, maybe delete your branch and refork? I'll merge this for now and hopefully it won't break my last update. |
@PowerBroker2 In which version this will be available to platformio ? |
I don't know how platformio or it's library manager works, so I'm not sure. If it mirrors the Arduino IDE's library manager, it will be available in the next tagged release. For now, you can use the main branch as it has these updates already. |
When you are coding in VS Code and you are using platformio, you just add the follow lines into the platformio.ini file and it just works. So I cannot use the main branch. anyway, thank you for your answer |
I use platformio - you can work with any branch/version/commit of a library in a couple of ways:
First method is easiest if you just want to track a remote branch and use PIO tools to keep it up to date. Second method is easier if you want to be working on the lib itself. |
Good to know that. |
@jimwhitelaw I have tested your fix, indeed the "V" removed from your payload but the function still returns zero |
Can you please provide a sample of the code you are using and the debug (serial) output that is produced? |
@jimwhitelaw I am using the same code as described on the description when I open the ticket. int newValue = int(obd->batteryVoltage() * 10); Query ODB value |
@jimwhitelaw I added some lines (take a look to the end of this post). Sending the following command/query: AT RV
|
OK, I have found the issue and implemented a fix. I will do some additional testing with a couple ELM327 devices before I submit a PR with the change. Stay tuned... |
After some investigation, I found that some ELM327 devices respond to the voltage command differently than others. I have submitted a PR (#217) that handles both scenarios. Also, I should note that the code you have provided may not do what you expect, even when batteryVoltage() is working properly. When the voltage value (a float) is multiplied by int value 10, the result is a float, but it only includes the integer portion of the original value. So the following code, given a voltage value of 13.1V: int newValue = int(obd->batteryVoltage() * 10); Will return 130, not 131. You could probably mitigate this with the following: int newValue = (int)(obd->batteryVoltage() * 10.0) |
) * Added currentDTCCodes() method - works for a single code * Preparing for mulitple code responses * First pass at multiple response support * Implemented non-blocking version. * Simplified code, implemented loop * Modifications to support both blocking and non-blocking * Fixed up check for number of codes present. * Added bluetooth PIN * Updates for actual returned DTC code format * Working to fetch codes. Needs fix for parsing. * Fixes for parsing codes correctly. Next task, update foundCodes[] array properly. * Working with foundCodes arrray now. Next do cleanup on debug messages * Removed no longer needed debug statements * Working as designed. * Moved dtcResponse into ELMduino class * Updated to get correct byte of monitorStatus() response * Added MIL Status reporting * Removed need to pass numCodes to currentDTCCodes() * Added blocking call to currentDTCCodes() * Updated comments * Added method to check / retrieve current DTCs * Added example program to check MIL (Check Engine Light) status and number of current DTC codes. * fix for batteryVoltage() returns zero PowerBroker2#203
Fix batteryVoltage = 0.
Payload is char array ending in V (ie, "12.5V") causing srttod to return zero. Fix removes the last char from payload so it converts properly.