My new android app - bridge between car(obd2) and home assistant

Hi everyone,
I’ve developed a small android app (link below), capable of collect data from cars (using bluetooth obd2 adapter), sending information throught mqtt and home assistant. Actually is pretty experimental, I still have to add features (like start on boot). Please try it and tell me what to improve and which data would you like to have.

Thanks,
Marco Ribero

11 Likes

Very cool.
I don’t know the technology, how does obd2 connect to an mqtt server?
Personally I have a local server in my LAN I guess is needed a cloud mqtt, but again how does a Bluetooth device in the car connect to it, through phone?

You need a working net connection in your vehicle. The easiest way is a “hard wired”(always connected to 12V) old android phone with BT.

I will test it, too. :slight_smile:

Connection between car and android device: I use an ELM327 adapter (https://www.amazon.it/gp/product/B010GLM7A8/ref=oh_aui_search_asin_title?ie=UTF8&psc=1), which is directly connected to OBD2 port of my car (search on internet about where is located on your car). After that, I connect my phone with the adapter through bluetooth connection.

Connection between android device and your Home Assistant: this is done connecting your phone to same MQTT broker used by Home Assistant. Usually your android device will be outside of your local network (because you’re outside house). You have mainly three approaches:

  • expose your private MQTT bridge on internet, forcing usage of secure username/password
  • configure a VPN connection between your LAN and your device. It could be unreliable, according to power save politics.
  • (I use this) Connect your android app to a public MQTT broker, like cloudmqtt.com. You also need to configure a bridge between your private MQTT server and cloudmqtt, in order to forward messages received on public broker to your private home-hosted broker.

Old “sacrificable” phone could be a good approach :grinning:

My initial idea (but I still have to optimize power consumption) was to use my personal phone, measuring only when I’m inside car (otherwise car is turned off). But it depends: in my case, I have a personal car. In other scenario, cars are shared

No offence, but there is already a component like this: https://www.home-assistant.io/components/sensor.torque/

why it would be an offense? :wink:

My app is just an alternative:

  • it’s free
  • you don’t need to expose anything about HA instance on internet (using vpn or cloudmqtt)
  • for my, it’s an experiment

Feel free to write about which features would you like to have with torque component

4 Likes

Any feedback/suggestion about this app?

Thank you,
Marco

This seems pretty cool, would be nice to be able to have DTCs pulled automatically and sent as an actionable item to HA… e.g. program connects, checks for active trouble codes and fires an event with the code. That could be sent over via telegram to get the code without having to really take any action.

The Torque plugin that someone above linked has functionality like GPSLogger where it can submit data to HA via REST. That functionality here would make this much more useful because I don’t feel like taking the steps to expose my MQTT server (so far my plan has to keep it local-only).

I’m agree, and you have two alternatives with my app:

  • vpn between android device and your home network (in android you can select which apps have to be connected with VPN)
  • use also a public mqtt as a channel between you device and your private MQTT (e.g. cloudmqtt.com, and look about mqtt bridge)

Yep, I’m looking about Diagnostic Trouble Codes. Any proposal about how to forward them to HA? I mean, an approach would be to send them via mqtt as sensor, but I don’t think that this is the best approach.

Thank you for your inputs,
Marco

Being able to transmit data via the HA API would be under the feature request category. I know there are other ways but it seems like the most direct and I can use a long-lived token for access without having to secure my MQTT server and change all of my devices which use it to add usernames and passwords.

MQTT sensor actually seems like the best bet to me. Have it be a primary state of “Clear” or “Codes Present” (or something similar) and if codes are present they could be contained in attributes in an array. I’m used to interfacing with HA via node-red so this would be a nice way to be able to parse the codes to do things like look up their descriptions automatically and send that along to Telegram.

1 Like

Ye, I have to put it in ToDo list. It seems also more flexible

Ye, I was thinking about a dictionary (inside a MQTT message), with key=[error code] and value=[optionally description of error code]

If I had an android device on my local network within bluetooth range of my driveway, could this be used to report any logged problem codes as I am arriving/departing? (assuming the vehicle is in range long enough to scan for codes).
I guess it could also be used as a crude (home/not_home) device tracker for vehicles, by using the last reported vehicle speed value when the bluetooth connection is lost?

Hi,

first this is a great idea!

I don’t know what are your “plans” but there’s another great app called “Ariela” by @Ionut who has already a built in solution to send mqtt messages to HA.

Why don’t you join your forces?

1 Like

Hi,

Good job!
It would be nice if this app could work on older phones. So I could use my old Android 4.1.2 phone.
It would be nice to have also some test button to check mqtt connection in ‘settings’ menu.

Br

Thank you for your feedbacks, and sorry for my delay

Actually it would be not work well. From next release, app would send data also when bluetooth device (=OBD adapter) is detected, in addition to regular time interval.

I have to think about this idea(trade off with battery like), but it’s interesting… In addition, in some scenario car is not_home when not detected(phone is always at home)…but in other scenario (like my initial idea), phone is with car driver.

Thank you, it seems a good app. Well, my app is more like a “sensor” (and I’m not a front-end guy), but it’s good to know better the ecosystem

1 Like

Ye, I have to look about this (I mean, which “min” version I have to support). For sure, it would be not in next release.

Good point, thank you

New release 1.2:

  • added trouble codes (in a separate MQTT message, both as a list of codes and a map {code=>description} )
  • added a log in main interface
  • now it queries OBD adapter immediately after an established bluetooth connection, without waiting interval

This sounds interesting, I will be trying it out when I can. I think a “start in background at boot” option might be useful!