Using clone ELM327 Bluetooth OBDII adapter with Leaf

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Turbo3

Well-known member
Leaf Supporting Member
Joined
Jul 19, 2010
Messages
2,014
Location
San Jose, CA
Warning: This app will only work with original unmodified ELM327 devices connecting to the CAR-CAN.

9/12/2013 The Leaf Battery app has been renamed "Leaf Spy" and is now available on Google's Play Store. There are three versions:

* Leaf Spy Lite - https://play.google.com/store/apps/details?id=com.Turbo3.Leaf_Spy_Lite (Free)
* Leaf Spy - https://play.google.com/store/apps/details?id=com.Turbo3.Leaf_Spy1 ($9.99)
* Leaf Spy Pro - https://play.google.com/store/apps/details?id=com.Turbo3.Leaf_Spy_Pro ($14.99)

Please use the two new forum topics to discuss the Leaf Spy app. Not this one which is way too long now.

The free Lite version has only screens 1 & 2 and no logging. Use it to verify that you have the correct hardware that works with the app and your Leaf before buying either of the more advanced versions. I don't want you spending money on something that is not going to work for you.

The current version is v0.27
* Fixes bug where app would crash or do other strange things on exit (All versions)
* Lots of other small fixes (All versions)
* Battery temperature thermometer is now functional (full and Pro versions)
* New Service menu that lets you do the following: (only in Pro version)
- Change automatic door lock/unlock settings
- Read Diagnostic Trouble Codes (DTC)
- Register Tire locations, required so Leaf knows location of each tire after tire rotation or seasonal swap
- (future) Clear selected DTCs


Features/Fixes in v0.26c
* Version number is correctly reported by Android
* Touch area to cycle DTE now includes the label under the DTE value
* Tapping the lower left corner screen indicator steps to the next screen. A tap and hold will step back to the previous screen

Feature added in v0.26b
* Screen 1 second line added better labeling for QC count and L1/L2 count if the screen has the room (normally in Landscape)

Feature added in v0.26a
* Tire Pressure Alarm max value changed from 40 to 50 PSI

Features in v0.26
* Better support for OBDII ELM 327 adapters
* Screen 1 displays new Health %, VIN number, QC count and Normal Charge count
* Real GIDs are now displayed
* Screen 4 - Now displays tire Pressure with user set Alarm level for low pressure
* By tappng DTE number on screen 4 you can select remaining distance to LBW, LVBW or Reseve level. The reserve level is user defined as either percent of capacity or a fix number of Whs.

It will take a little while before the user generated documentation is updated for all the new features in this version.

Start of user generated documentation.
http://www.mynissanleaf.com/wiki/index.php?title=Leaf_Battery_Application

Screen 1 - Battery Cell Pair Voltages (red color means cell being balanced)
qu2l.png


Screen 2A - Battery Voltage Histogram
s7jg.png


Screen 2B - Battery Temperature (tap screen 2 to toggle between 2A and 2B)
yuda.png


Screen 3 - Original Summary (no change to this old screen)
leafbat025f.png


Screen 4 - Summary
gspg.png

===========================================================================
Here is what a couple of these adapters look like. The mini cost me $14.74 on eBay. They are based on the original Elm Electronics ELM327 chip that has been cloned using a PIC processor. They display firmware version 1.5 but the highest one produced by Elm Electronics was 1.4b.

p1010121rm.jpg


I was asked by a BayLeaf member last year to look into the possibility of using one of these to monitor the Leaf SOC. He even loaned me the one he had. It sat around for a few months before I had time to look into it. My first thought was that I would need to move the CAN bus monitor wires from the standard CAR-CAN to the EV-CAN. It was not obvious how to open his unit up so I decided to just buy my own so I would not damage his in the process.

As you can see in the pictures, opening it involves removing four screws covered up by the label. Rather than try to peel off the label I just punched through it. So moving the wires would not be a problem. But before I did that I decided that I need to see if I could read out the VIN number though the CAR-CAN so I did not move the wire at this time.

I needed the VIN for another project (CANary) to add to the Cell Pair Voltage log file I am creating (that is now possible due to the work of GregH and TickTock).

So far I have not had any success reading the VIN using the standard protocol but since I was play around with the commands I decided to see if I could read out the CP voltages. This is possible because in CAN traces taken by the CANary code we have seen that EV-CAN requests and responses are echoed on the CAR-CAN. So I figured that the opposite was true too and I could send the Cell Pair voltage request out the CAR-CAN and see the results on the CAR-CAN too.

My first try got me the first response packet with voltages for the first two Cell Pair (CP) voltages. Reading the ELM327 manual and changing the Flow Control message got me a second packet and 3 ½ more CP voltages. I have been stuck there for the last couple of days until I downloaded a few more specs with ISO 15765-2 holding the information I needed to make it work. The problem was that the ELM327 was not auto sending additional Flow Control messages to request the remaining packets.

The solution contained in ISO 15765-2 was I could modify the first and only Flow Control message the ELM327 is sending to request all the remaining packets. So I changed the Flow Control message to request all the data but delay each packet by 32 msec to give the ELM327 time to process it and send it out over the Bluetooth link.

So all you need to read out all 96 CP voltages in your Leaf is one of these ELM327 clone BT adapters and a terminal emulator program like HyperTerminal. It takes just 5 commands to do it. I added two more AT commands at the start to turn on displaying the message Header ID (always 7BB) and data length (always 8). I will write a little program to process a text file of the dump into the actual decimal voltages as they are dumped as two byte hex mV values.

Code:
>at h1
OK

>at d1
OK

>at sh 79b
OK

>at fc sh 79b
OK

>at fc sd 30 00 20
OK

>at fc sm 1
OK

>21 02
7BB 8 10 C6 61 02 0F C6 0F CD
7BB 8 21 0F CC 0F C4 0F D5 0F
7BB 8 22 D1 0F CB 0F C4 0F D1
7BB 8 23 0F C6 0F C8 0F C4 0F
7BB 8 24 D2 0F D6 0F D2 0F D3
7BB 8 25 0F D2 0F C8 0F C8 0F
7BB 8 26 C9 0F D2 0F C8 0F CD
7BB 8 27 0F C4 0F D1 0F CD 0F
7BB 8 28 CC 0F C8 0F CD 0F D2
7BB 8 29 0F CD 0F D2 0F CF 0F
7BB 8 2A CF 0F D4 0F D2 0F C6
7BB 8 2B 0F CB 0F CB 0F C8 0F
7BB 8 2C C4 0F C4 0F C8 0F C4
7BB 8 2D 0F D1 0F CF 0F D5 0F
7BB 8 2E D1 0F CF 0F D1 0F D5
7BB 8 2F 0F C8 0F D4 0F D0 0F
7BB 8 20 D4 0F D1 0F D7 0F D2
7BB 8 21 0F C8 0F CD 0F C3 0F
7BB 8 22 D2 0F C9 0F CE 0F C4
7BB 8 23 0F CD 0F C4 0F C8 0F
7BB 8 24 CD 0F CD 0F CD 0F CD
7BB 8 25 0F CC 0F CC 0F CB 0F
7BB 8 26 C8 0F C4 0F CD 0F C3
7BB 8 27 0F C9 0F CF 0F CF 0F
7BB 8 28 D5 0F CD 0F D5 0F D1
7BB 8 29 0F DA 0F C8 0F CD 0F
7BB 8 2A CD 0F D1 0F D6 0F C8
7BB 8 2B 0F CD 0F D1 0F C1 97
7BB 8 2C CA 97 B6 FF FF FF FF

There seems to be a need for an Android app that uses ELM327 type adapters with the Leaf. Programs like Torque do not currently work and I had no luck with any of the other apps. It is not a problem with the ELM327 as I have had it do a dump all messages (filtered) to the termianl. You can filter for brake light on and see a message on the terminal.

I think these apps are looking for an engine control module and transmission control module at standard locations that do not match where the Leaf ECUs are located.

Jim
 
That's pretty cool! Maybe we should be spending more time working on ELM327 bluetooth apps for our smartphones rather than new CAN display boards... hmm...
 
GregH said:
That's pretty cool! Maybe we should be spending more time working on ELM327 bluetooth apps for our smartphones rather than new CAN display boards... hmm...
:eek:
 
The ELM bluetooth might not have the bandwidth to handle
more than a selected subset of the CAN Messages, and from
one CAN bus only.

But, within those constraints, the iMiEV folks in France
have made some reasonable Android apps, using
a Basic4Android programming system. Quite nice.
 
What I would love to see is a simple iphone app that would show the same info as displayed by the Wattsleft meter. If this bluetooth module would allow that, all the better, since updating a phone app is much faster than building a new CAN board.
 
The limitation of the ELM327 is that it only connects to the CAR-CAN. However, it seems likely that all the requests that use message IDs in the 0x700 thru 0x7FF get echoed onto the EV-CAN. This is the case for the battery request messages. I need to look into the other three pack request messages to see if they contain SOC information. So it might be possible to make a subset of the WattsLeft type display for a smartphone but not an Apple product (iOS).
 
Turbo3 said:
There seems to be a need for an Android app that uses ELM327 type adapters with the Leaf. Programs like Torque do not currently work and I had no luck with any of the other apps. It is not a problem with the ELM327 as I have had it do a dump all messages (filtered) to the termianl. You can filter for brake light on and see a message on the terminal.

I think these apps are looking for an engine control module and transmission control module at standard locations that do not match where the Leaf ECUs are located.

Jim
This may be the case. I'd asked the question in this Torque forum and it sounds like it might be possible to send a custom init string, but the way Torque is currently written, it sounds like it needs a valid response from request '0100' in order to validate there's an ECU present.

Perhaps someone knowledgeable with CAN and OBD-II could talk to the Torque devleoper in that forum to work something out. Torque certainly seems to be about the best (most customizable) Android app out there for the purpose. It'd sure be nice to be able to get SOC this way rather than a dedicated piece of hardware (at least for some of us).
 
Turbo3 said:
The limitation of the ELM327 is that it only connects to the CAR-CAN.
Wait - isn't that what you said you did with your unit - opened it up and modified it to talk on the EV-CAN bus (different pins)? Or are you saying that there's another limitation (other than the different pins)?
 
The "limitation" is on the stock ELM327. If you open it up and swap from CAR-CAN pins to EV-CAN then you can duplicate the WattsLeft live screens.

In the picture at the top I show two versions of the ELM327. The larger one uses four screws so would be fairly easy to change for someone with moderate soldering skills. The "mini" one is sealed closed and looks to be directly connected to the OBDII pins. So one would need to break open the case and cut traces and solder in jumper wires. This is more complicated.

At this time I have not swapped from CAR to EV pins. I want to see what can be done with a standard ELM327 that anyone can buy and use. Having to open it up and make changes greatly limits the number of people who could do this. I am looking for a low cost, easy to get setup monitor for everyone (standard ELM327 + Android APP total cost <$20). The software might even be a Plug-In for Torque but I have not looked into their API.
 
Turbo3 said:
Having to open it up and make changes greatly limits the number of people who could do this. I am looking for a low cost, easy to get setup monitor for everyone (standard ELM327 + Android APP total cost <$20).
Agreed. Perhaps a CAR to EV adapter could be built. It's another unnecessary complication, but perhaps easier to do for the end user than swapping pins.
 
surfingslovak said:
GregH said:
That's pretty cool! Maybe we should be spending more time working on ELM327 bluetooth apps for our smartphones rather than new CAN display boards... hmm...
:eek:
Ha! Only kidding myself I guess.. I'm an embedded hack, not an iOS hack..
 
See this "Android CAN Monitoring App" thread:
http://myimiev.com/forum/viewtopic.php?f=10&t=764" onclick="window.open(this.href);return false;
and deciphering CAN...
http://myimiev.com/forum/viewtopic.php?f=10&t=763" onclick="window.open(this.href);return false;
and iMiEV CAN...
http://myimiev.com/forum/viewtopic.php?f=10&t=727" onclick="window.open(this.href);return false;

They have made some good use of Bluetooth and
ELM-like devices.

Warning: I tried to modify the OBDLink SX
to read other CAN buses, but it seems to have died. :oops:
 
Usings Gary's above links I have made some quick and dirty changes to the iMiev APP to take Leaf battery data and work with the ELM327. Needs more work to clean up the display to display all 96 CP voltages. There should be max/min values on the y-axis and the x-axis only goes from CP 1 to 88. I took two traces to see if the data would be the same or close.

p1010126si.jpg


p1010127u.jpg


Ok, I see now that it only goes up to CP 79 on the ATT Fusion 2 (on the Nexus 7 it goes to 88). So the bars and/or labels for 80 to 88 are probably messing up the y-axis label. Should be easy to fix. For some reason my Nexus 7 running this program will not open a serial connection. Other programs on the Nexus 7 do link to the ELM327 so seems like a Basic4android issues.

These pictures were taken of my ATT Fusion 2 Prepaid phone. Only $39 at Fry's. Don't use the phone part so no service (always in Airplane mode).

It appears that the white background is the problem. The background should be black as it is on the test data before the Leaf data is read in.
 
Ok, fixed two bugs in moving the battery data into the internal display array. There was no problem with the graphing routine. It was just doing what I told it to do with the bad data I gave it.

If you count you will see that all 96 Cell Pair Voltages are displayed.

p1010136hr.jpg


p1010135cd.jpg


Need to add some validation code to make sure only valid data is moved into the array in the case where a response message is lost.

I also want to add a button to request an update. Right now I have to stop then restart the program to get another reading. Also want to try speeding up the data from the Leaf. Right now the frames are sent every 32 msec.

p1010138s.jpg
 
Good work.

What inexpensive smartphone is Android, with Bluetooth, and
can operate on WiFi or Bluetooth, and has Google Play (to get apps),
all without a monthly phone payment?

My Vizio Android Tablet is/was just shy $200 at Costco, but
I have used it with these iMiEV apps, taking a CAR CAN log from
them and having CAN-Do send selected messages out the PC's
USB port using a mini USB-to-Bluetooth adapter.

Your Fusion 2 at Fry's for $39 seems to be... gone.
 
You need to watch the Fry's weekly ads. The first one I bought was $79.99 then a few weeks later they dropped it to $59.99 so I went back to Fry's and got $20 back from them. Then in the 3/15/2013 ad it was going for $39.99 so my brother was able to pick up another one for me. Stock number is #7312974.

The code to save the battery/temp is actually from TickTock's CANary code. So adding Temp is just a matter of sending "2104" after I load all the battery data. The code is already there to receive and save the temp data.
 
Added the four pack temperatures below the graph. Converted to F using raw thermistor number.

Added simple check to force all pack voltages to be between 3.0 to 4.4 volts. If not it is replaced with 4.0. Later it will be changed to set a flag to get another set of values. So this is temporary to prevent the all white background seen on the first screens.

p1010139nm.jpg


Next will add max/min/avg voltages like on TickTock's CANary CP screen.
 
Back
Top