Despite being an iOS user myself it did take me quite a while to get this version of the app out. That’s because I develop mostly Android Apps so the development for Android was an easy task. For the iOS version I had to look into… well mainly everything.
What you’ll need
If you just want the app, here you can find it at https://apps.apple.com/app/id1559468042 It’s free and all you need is an OBDII dongle with Bluetooth 4.0 support and a proper elm327 chipset. Bluetooth 4.0 (or higher) because that is required for BLE or Bluetooth Low Energy and iOS doesn’t allow much else. Proper elm327 chipset because there are many fakes copies around that simply don’t work.
UPDATE: I’ve confirmed in the past that the extremely cheap transparent blue ones don’t work. Also the black ones with orange and blue stickers are no good. The black ones with an on/off switch are hit and miss. I had one that did work. But then on the Energica the 12V power is switched so you would need to relocate the push button to activate the dongle again. Also others have reported they got that one but it didn’t support the full stack. So I removed the link since then.
The only dongle that remains that does work is the cruise control one. From what I know it’s only available from Amazon in Europe (DE and IT website). If you find other working ones please let me know. I might have to delve back in the Bluetooth info received directly from the bike just to see if the battery is somewhere hidden after all.
That dongle you plug into the OBDII port underneath the left plastic tank cover. That cover can be removed with 5 hex bolts revealing the coolant reservoir and this OBD connector. You can leave it there if you want, that is how I use mine. Every time you power the bike on (or it gets power from charging) the dongle will be live. Just remember that when your bike is in for service they’ll use that port so they’ll take the dongle out. Make sure to check if you leave ;-).
Note that for the Android version this step is optional because there I also have the BLE connection implemented that the bike has built in. Downside of that connection is that not all information is available, it only contains the fields that are on your display already that they want you to see. The OBDII data has way more info, including the battery min and max temperature readouts.
iOS BLE connection programming
I made some follow up posts on EMF on the process I made. I’ve also documented everything at the bitbucket project website. If you go through you’ll notice it wasn’t just looking at how to connect to OBD using BLE that kept me busy.
In a perfect world this implementation would’ve been done using an existing, maintained and tested library. That is always the first thing to do when creating something, check if it doesn’t already exist. That way I found 2 libraries for iOS for connecting to elm327 chipset OBDII dongles.
The first one you can find at https://github.com/mickeyl/LTSupportAutomotive and seemed quite big and extensive. I really just needed to push a few AT commands and parse the results. All the standard OBD2 PID logic and diagnostics isn’t even needed for this project. Plus the library isn’t written in swift. Not a big issue but a lighter option that I can read and adapt if needed would be welcome.
The second option I found at https://github.com/Wisors/OBD2Connect looked promising being way smaller and written in swift. So I started branching code to use that one, only to discover it was written to only support WiFi connections. In an attempt to overcome the Bluetooth limitations on iOS some of these dongles were equipped with WiFi instead. Although that technically worked it is far from ideal since BLE is created to minimize power usage on both ends of the connection. On your bike the power draw from using WiFi can probably be ignored but not on your phone.
So instead I worked it out from scratch, that is part of why it took a bit longer than expected. And also why the current version is still limited in functionality. You can make a connection and manual request an update of the latest data. That’s it for now.
The benefit of this elm327 chipset is that it’s so well documented and easy to use. All you get is a BLE device that you can control using UART commands. Those are text based commands and responses. And the tricky part of parsing this Energica specific info was already mostly covered in the Android version.
I’m now ready to gradually grow this app as I push small incremental updates. Not because I think that is the best way of developing (I do) but because I have limited time for this. As an iOS user I’ll be using this app a lot and find bugs while doing so.
For features I now first want to have these updates executed automatically in the background. That way you don’t have to pick up your phone to see the latest value. Similar to how this is already working for Android. I believe that for the current iOS version the BLE connection should stay as long as the app isn’t killed. But the values aren’t updated yet.
Next I’ll look into having the same https://ev-monitor.com integration I’ve added for Android. This will always be optional. If you don’t provide any details the data remains on your phone. I don’t even see anything in logs or analytics (there are no analytics, again no time for that). The benefit of this integration is that you can have the app running in the background and then afterwards check on that website what de that was. Plus the awesome graphs of course.
And once all that is working I might look into having a map a GPS tracking set up for iOS also. Similar to how the OBDII data is pushed this then can push data to the cloud. This way you can watch back routes you’ve traveled. For me it would be a lot easier to have that tracked with the same phone I use for navigation on my handlebars.