bmartin
Posts: 16
Joined: Thu Dec 31, 2015 1:55 pm
Delivery Date: 20 Jun 2015
Leaf Number: 2012

[W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Wed Mar 01, 2017 8:43 pm

Hello Leaf community,

I've been writing an Android/iOS app that borrows interface elements from other Hybrid/EV cars to display data from a Bluetooth ELM327 OBDII device for the past month or so. It's really shaping up well, but before it's ready for the Google Play store, I have a lot of work ahead of me. I don't think I'll be able to perfect the ELM237 interaction without some insight and feedback, so without further ado, I present to you, Happy Leaf 0.2!

Happy Leaf is now on Google Play

If you would like to try the app out, please sign up for the beta. (iOS Testflight will be emailed after your Beta application)

(Updated images 05/01/17)
Image
Image
Image
Image
Image
Image
Image
Image

0.2

- [NEW] Battery Health notification
When the battery SOH changes a notification is triggered that displays the previous SOH, current SOH and odometer at the time of the SOH change.
- [NEW] BLE support for iOS
All BLE devices will show in "Nearby Devices"
Only tested on one model of BLE, please let me know if you can't connect. Please send OBD model.
- [NEW] Flow Manager
Dynamic message requests, based on priority. (non linear request order)
Higher priority messages will be requested more frequently than lower priority messages. Will eventually dramatically increase performance.
May be slower on some commands for now, more optimization will be required over time and future updates to fine tune the flow.
Connection/verification messages now through Flow Manager, increased reliability when trying to reconnect.
- [NEW] Wifi on/off (Android)
New in settings -> Connection -> Allow Wifi. Happy Leaf won't re-enable Wifi if this is disabled.
- [NEW] Distance / Temp unit override
New in settings, should convert units based on preference. Will still auto detect units and adjust accordingly.
Tested converting my U.S. LEAF to Km / C, seemed to work.
- Better, more efficient logging (should be no more memory leaks from logs)
- Fixed issue where newest data would be deleted, now correctly purges oldest data from memory. No longer time based, strictly based on 2,000 history limit.


0.1.8

- [NEW] Multi Language support
- [NEW] Two new notifications
Alert for rapid increase of battery temperature.
Alert for high battery output (>70kWh)
- [NEW] Setting for disabling OS notifications (on be default)
- [NEW] Offline mode
Use app without connecting to ODB device. Requires past history, so Bluetooth OBD still required for functionality. After initial connection, pressing the icon at bottom right of Welcome screen will transition to Home screen, even without Bluetooth enabled. (History still deletes after 24 hours)
- [NEW] Settings icon on Welcome screen.
- Adjusted font sizes on blue title/footer bars.
- Moved charging animation "cable" to right side of diagram, now charging voltage doesn't overlap with dropdown icon.
- Recalculated GID readings over 255. Currently untested, but may resolve GID issues where SOC > 80% but kWh remaining would be near zero (calculated from GIDs)

0.1.7

- [NEW] Save logs / history to sdcard or internal storage.
Disabled by default as this affects performance. Can be enabled from settings page.
Saves to /sdcard/Happy_Leaf/BETA/[date]-history.json and [date_time]-ODB-log.txt
These files will help me troubleshoot issues better
- [NEW] Notifications
New icon by settings, will have green badge showing unread notifications
Should send local notifications to device
Will only send the same notification after 30 minutes.
Currently has notifications for the following:
Low / High Tire pressures
Low / High Battery Temperature (-5c / 46c)
Low 12v Battery voltage
Low SOC (under 20%)
Low Hx (under 50%)
- Can now disable extra data (scrolling down), this should improve performance. (In settings)
- Updated colors, red on SOC meter not as bright, background color closer to white in light mode.
- Enlarged Motor watts / Climate usage charts. Shrunk SOC meter slightly.
- Fixed Tire layout to match reality.
- Cars using Km when manufacture set Miles should now see closer odometer reading
- Ability to delete history data, Settings -> Data
- Various checks to incoming OBD data to ensure consistency.
- Outside temp adjusted to documented spec, still doesn't match Leaf's display, but this could be due to a different thermometer being read. Found other codes that represent outside temp, but currently not implemented.

0.1.6
- [New] Dark Mode
Manually set theme via new menu button at top left of screen. (this override will persist until app is relaunched)
Automatic dark mode via Ambient light sensor on Android device
Settings for toggling light sensor, and sensor sensitivity.
Setting for Dark Mode following headlights on/off
- Better responsiveness
Most font now scales based on percentage of screen. Should look much better on any screen size, any orientation.
Fixed scaling causing app to be able to scroll sideways on smaller devices
Graph data points now average based on screen size. Smaller screens will be more readable when large amounts of data logged.
- Graph Visuals Updated
Data points are smaller now and don't have white border, much easier to read
Graph now displays kWh on left side, much easier to read
Slightly smaller legend
- If codes are failing to read, small circle at top right now turns orange. (green when retrying codes)
- Attempting to address issue where dash set units differ from manufacture units. If your odometer reading is off by ~60%, but displays the correct unit label.

Image
Image
0.1.3
Changed the default graph color
Added m/kw, watts/m and remaining KW%m/kw (ETA miles to absolute zero, based on trip m/kw)
Added total miles driven while app logging, and total miles today calculation.

(0.1.1 below)
Image
(Car off while charging, hence why GIDs/Kw remaining are blank)
Image
Image

I started writing this app midway through 2016. I chose the app framework (HTML/Angular/Phonegap/Cordova), but then came to a loss at what to send to the OBD connection to get real responses (anything but OK). Last month I came across a breakthrough in teaching myself the ELM327 + bluetooth spec, and began seeing data. This forum played a key role in forming my understanding and getting results, thank you everybody who made this possible. I'm using the spreadsheet here for CARCan/EVCan codes: https://docs.google.com/spreadsheets/d/ ... UFm0P7ouwg
Thank you TickTock, Turbo(s), Gary and others for gathering and sharing this knowledge.

In my daily life, I depend on the OBDII connection to track watts used, M/kw per trip, and occasionally diagnostic. I had so many ideas, and wanted to visualize the data deeper than currently available apps. After this breakthrough, the app started taking shape, and works better than I dreamed.

Happy Leaf's primary goal is to be a pretty interface for data, not a diagnostic tool. I created a Leaf diagram using SVG that holds tire data, SOC data, energy movement, climate usage, motor output, and headlight status. This is the meat of the app, it easily visualizes what is going on with the vehicle.

The interface runs extremely well on the two Android devices I have available to me. A $50 Kindle Fire 7" (Android 5.1.1), and a 2012 Motorola Photon Q (Android 6.0.1). Both are rooted and have custom roms, so your results may vary. I highly recommend a tablet for this interface, phones just don't have the real-estate and I haven't spent a lot of time optimizing (though the css wouldn't take long).

Charging Animation

Image

Regen Animation

Image

Motor/Climate Usage Animation

Image

Scroll down and see all data in real time

Image

Scroll farther, press the play button, and watch the logs

Image

The app is clearly far from finished, but it's getting so close that I'm not sure how much farther I can take it alone. There's still many bugs, missing features, and currently slow query times.

If you are interested in testing this app, fill out the form here. There's still much testing/tuning to be done so it's results may vary.

If you would like to contribute to development, see the source code here

Thanks!
Happy Leaf'ing!
Last edited by bmartin on Mon May 01, 2017 9:25 am, edited 11 times in total.
2012 Nissan Leaf SV - Purchased June 2015 with 16.2k miles.
Lost 1st bar 09/2016 at 37.7k miles, 84% SOH
01/01/2017 - 41k miles, 86% SOH, 226 GIDs

Projects:
Happy Leaf Bluetooth ELM app
Carwings Siri Intigration
Leaf Underglow/charging port lights

bmartin
Posts: 16
Joined: Thu Dec 31, 2015 1:55 pm
Delivery Date: 20 Jun 2015
Leaf Number: 2012

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Wed Mar 01, 2017 8:49 pm

Reserved :D

I'm still unable to get certain codes, many EVCan codes I can't find or filter for, and I'm at a loss to any 792/793 codes. I can get detailed SOC with 7BB responses, but that's the extent of ATFCSH messages I'm querying for. I feel like I've read a good third of the OBD discussion on this forum, this has given me a pretty good footing, but many details of how to request certain codes, are not discussed, or my understanding isn't clear enough to make sense of what was discussed.


Here's what Happy Leaf is currently listening to:

Tire Pressures:
Headlights/Turn Signal:
SOH/GIDs: 5B3
Speed (Mph/K/h):
Climate Power usage (Watts), currently this doesn't match other apps or the OEM nav unit:
Transmission status:
Parking break status:
Motor Amps: 180
Motor Volts: 176



Here's the messages/data I need to complete the interface:

Battery current output: 1DB
Any Charging status indication (Plugged in, L2, QC): 100-109 or 5FB
Charging watts in (amps * volts): 1DC
These commands I can't seem to find, even when filtering for them directly.

At first I was reading 1 message at a time, it took over 12s to get a full round of messages (and I was only needing more and more), I discovered the use of ATCF. ATCRA, and ATCM, though ATCM isn't very useful at the moment. Now I do a loop with three or four filter/receive commands to get a second or two of message streams of various messages. At the end, I look for the 7BB SOC, and restart the cycle. In under 7 seconds I'm reading many more commands in more real time, the same message can come through ~10-20 times during that 7s block.

The Filters / Receive messages I'm experimenting with:
X and F are wildcard/don't care bytes

ATCF 5AF
ATCRA 5BX
This produces 58A, 5B3, 5A9

ATCF 62F
ATCRA 6XX
This produces 60D, 625

I then do a simple ATAR, ATCRA, ATMA to get a Buffer Full of codes. I do a few ATCM7FF, ATCF(MSG) requests for specific commands that I can't get in a mask/filter.

I still don't have the filters 100%, at this moment it is a lot of guesswork to get codes that align with interface needs. I'd really like to generate these masks/filters programmatically, but my understanding of how they are processed (Especially on the leaf) means for now I'm doing them by hand, in a linear array. I also want to be able to filter for a larger range of codes, while possibly excluding noise, and end the output before the buffer is full. I've attempted to add more bytes to ATFC, like ATFC180176(00), to attempt to filter for two or more messages, doesn't work like that. Telling the ELM to filter two or more message ranges at the same time would be golden. Maybe a complex mask?

At the moment, I've spent as much time on it as I can, and need to get feedback so I can refine the numbers. I'll be using this app daily, so will working on it in bursts. I'm willing to share source code, especially if there's anyone interested in digging into it, my end goal is to share this with others to improve their Leaf driving experience.
2012 Nissan Leaf SV - Purchased June 2015 with 16.2k miles.
Lost 1st bar 09/2016 at 37.7k miles, 84% SOH
01/01/2017 - 41k miles, 86% SOH, 226 GIDs

Projects:
Happy Leaf Bluetooth ELM app
Carwings Siri Intigration
Leaf Underglow/charging port lights

LeftieBiker
Posts: 6778
Joined: Wed May 22, 2013 3:17 am
Delivery Date: 31 May 2013
Location: Upstate New York, US

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Wed Mar 01, 2017 9:52 pm

Looks good. A couple of suggestions:

Replace "true" and "false" with "yes" and "no."

Charge your 12 volt battery! It's near dead.
2013 "Brilliant Silver" SV with Premium Package and no QC, and 2009 Vectrix VX-1 with 18 Leaf cells.

The most offensive, tasteless phrase in use here is "Pulled the trigger." I no longer respond to posts that use it.

bmartin
Posts: 16
Joined: Thu Dec 31, 2015 1:55 pm
Delivery Date: 20 Jun 2015
Leaf Number: 2012

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Wed Mar 01, 2017 10:54 pm

LeftieBiker wrote:Looks good. A couple of suggestions:

Replace "true" and "false" with "yes" and "no."

Charge your 12 volt battery! It's near dead.


Thanks! That is an easy change.

I would love to replace that Lead Acid toxic hazard with a nice lithium pack.

Image

I also added average speed to the graph, makes for some interesting visuals. (Need to change the color from that gray)
Image
Image
(Battery temp isn't really 80 degrees, this isn't parsing correctly)
2012 Nissan Leaf SV - Purchased June 2015 with 16.2k miles.
Lost 1st bar 09/2016 at 37.7k miles, 84% SOH
01/01/2017 - 41k miles, 86% SOH, 226 GIDs

Projects:
Happy Leaf Bluetooth ELM app
Carwings Siri Intigration
Leaf Underglow/charging port lights

tbear2001
Posts: 18
Joined: Fri Mar 03, 2017 6:56 am
Delivery Date: 04 Mar 2017
Leaf Number: 333614
Location: Montgomery, AL

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Tue Mar 21, 2017 9:40 am

This is awesome... I have a large 6" display phone that I'd like to try it on. I've been using leafspy and it's great, not the prettiest app though.
2015 Glacier White Leaf S QC - Certified Pre-Owned - 2017-03-04 - 20,272 mi.
2017-03-13: AHr=55.42 SOH=89% Hx=83.64% 20,756 mi 83 QCs 648 L1/L2s

claude274
Posts: 7
Joined: Wed Jan 21, 2015 7:27 pm
Delivery Date: 01 May 2015

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Tue Mar 21, 2017 2:49 pm

Had no charge amp/volts and would it be possible to put metrics? Great app! :D

dhanson865
Moderator
Posts: 1476
Joined: Wed May 25, 2011 7:12 am
Leaf Number: 16156
Location: Tennessee

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Tue Mar 21, 2017 3:50 pm

I'd strongly suggest not showing GIDs by default and only show them for old timers that want to enable them from a options setting somewhere.

All that I pay attention to is %SOC, ahr, SOH%, kWh remaining (and the resultant calc of miles remaining)

Max GIDs and comparing GIDs from one car to another is a minefield as they are variable, not a fixed unit of energy.
2012 Leaf tires 195/65/15 Dunlop Enasave 01 A/S, 15" Rims
wiki/index.php?title=Real_World_Battery_Capacity_Loss
(leaf range chart)
(efficiency 3.x KW vs 6.x KW)
please join Truedelta.com and input your repairs.

bmartin
Posts: 16
Joined: Thu Dec 31, 2015 1:55 pm
Delivery Date: 20 Jun 2015
Leaf Number: 2012

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Wed Mar 22, 2017 8:21 pm

claude274 wrote:Had no charge amp/volts and would it be possible to put metrics? Great app! :D


Metrics should work, Km is read from the car and changes units automatically. Charging Amps/Volts may not work on 6kw charging at this time.


dhanson865 wrote:I'd strongly suggest not showing GIDs by default and only show them for old timers that want to enable them from a options setting somewhere.

All that I pay attention to is %SOC, ahr, SOH%, kWh remaining (and the resultant calc of miles remaining)

Max GIDs and comparing GIDs from one car to another is a minefield as they are variable, not a fixed unit of energy.


I don't do any comparing GIDs to a "maximum value", but GIDs are actually the only way to calculate watts remaining (at least the OBD messages I can read). 1 GID = ~77.5Wh. I compare this with SOC to get SOC per GID, and fine tune watts left/watts used based on this.
2012 Nissan Leaf SV - Purchased June 2015 with 16.2k miles.
Lost 1st bar 09/2016 at 37.7k miles, 84% SOH
01/01/2017 - 41k miles, 86% SOH, 226 GIDs

Projects:
Happy Leaf Bluetooth ELM app
Carwings Siri Intigration
Leaf Underglow/charging port lights

LeftieBiker
Posts: 6778
Joined: Wed May 22, 2013 3:17 am
Delivery Date: 31 May 2013
Location: Upstate New York, US

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Wed Mar 22, 2017 9:19 pm

I suggest you have an "expert mode" that enables GIDs and the graph(s). That way you have a mode that's very easy to read at a glance, and a mode that provides all data needed by more experienced EV drivers.
2013 "Brilliant Silver" SV with Premium Package and no QC, and 2009 Vectrix VX-1 with 18 Leaf cells.

The most offensive, tasteless phrase in use here is "Pulled the trigger." I no longer respond to posts that use it.

bmartin
Posts: 16
Joined: Thu Dec 31, 2015 1:55 pm
Delivery Date: 20 Jun 2015
Leaf Number: 2012

Re: [W.I.P] Happy Leaf - ELM327 intuitive Nissan Leaf interface for Android Tablets

Mon Apr 03, 2017 6:21 pm

LeftieBiker wrote:I suggest you have an "expert mode" that enables GIDs and the graph(s). That way you have a mode that's very easy to read at a glance, and a mode that provides all data needed by more experienced EV drivers.


The interface will be fully customizable, the cards will have the ability to move, change size, and display any data the user wants. Adding new cards coming soon. :D
2012 Nissan Leaf SV - Purchased June 2015 with 16.2k miles.
Lost 1st bar 09/2016 at 37.7k miles, 84% SOH
01/01/2017 - 41k miles, 86% SOH, 226 GIDs

Projects:
Happy Leaf Bluetooth ELM app
Carwings Siri Intigration
Leaf Underglow/charging port lights

Return to “LEAF CANBus”