Problem to connect nerves to USB, Bluetooth in Raspberry Pi 4

Hi, Unfortunately, I have had bad experiences to connect my Raspberry Pi 4 to Bluetooth or USB, and I don’t know why even Nerves framework is handy and seems a good framework that has no lib can be easy configured.
I do not want to be rude and on the contrary I am very interested and also grateful, and I hoped I could even have a good understanding developing and help this team, I feared this answer :(. I’m wondering why there is so poor commitment for Bluetooth in open-source.


I want to create a software to connect OBD cable that gets my car data from ECU. So I have two options to connect to the car, first Bluetooth and second USB, But Bluetooth is more important for me.

Step one

At first, I found this post that suggested to use Harald library. I have read its documents and install in my Raspberry, but when I connect to my device and test its document codes, I have this error.

iex(1)> {:ok, pid} = Harald.start_link(id: :bt, adapter: Harald.Transport.UART)
{:ok, #PID<0.1223.0>}
** (EXIT from #PID<0.1220.0>) shell process exited with reason: an exception was raised:
    ** (UndefinedFunctionError) function Harald.Transport.UART.setup/1 is undefined (module Harald.Transport.UART is not available)
        Harald.Transport.UART.setup([transport_pid: #PID<0.1223.0>])
        (harald 0.3.0) lib/harald/hci/transport.ex:51: Harald.HCI.Transport.handle_continue/2
        (stdlib 3.17) gen_server.erl:695: :gen_server.try_dispatch/4
        (stdlib 3.17) gen_server.erl:437: :gen_server.loop/7
        (stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

I couldn’t find anything in its documents, if there is an extra library that I am force to install or not.

Step two

When I have completely disappointment, then I have tested blue_heron library which has no documents, and they just have put a sample code for Raspberry Pi 0 and I have tried to use even this lib said it is not compatible for the 4 version.
This plugin has 2 subprojects which should be installed like URT and I think USB, but these libs especially URT has conflict with main lib.

Last chance

Finally, I think I should use the C programming language libraries with the help of Nifs and create a wrapper. But I have no experience on C, and I do not know what libraries exist in there.

IF you have any suggestion, please help me to solve this problem.

Thank you

Neither Harald (the previous effort) or Blue Heron (the current effort) are super mature. That’s due to the limited number of developers working on the Nerves project and the fsct that many of them have no need for Bluetooth in their jobs and as such haven’t had a chance to build them out.

Blue Heron seems very promising but it still early. That’s why it isn’t very documented. It also is focused on BLE I believe, not necessarily all of Bluetooth. I don’t know the spec so can’t speks to what that means for you.

You could bring in the linux bluez bluetooth tools via Buildroot I believe and shell out to that to get things done. Have never tried it.

I’ll assume “poor commitment” is just a poor choice of words :slight_smile:

Implementing BLE is a big job, the entirety of Bluetooth even bigger. It gets done when it gets funded I imagine.


I am sorry for about it, I am not native English, so some text I can write maybe wrong. Hence, I have no choice. I don’t know, I can find a way like connect a car ECU to Raspberry Pi links as a sensor and take some data. I have no experience for about it.

1 Like

I have another question, what about USB? Do you have an experience? Because some OBD cable can connect with USB instead of Bluetooth.

Hi there.

Yes, unfortunately there’s no fully-baked Bluetooth library for Elixir yet. In regards to Blue Heron, the project is still very much a work in progress, and progress is slow, because no one is paid to work on it.

That said, Blue Heron can work on a Raspberry Pi 4, but it requires figuring out a few steps on your own, as not much attention has been paid to documentation. This is partly because it is simply not ready yet for widespread usage.

I am also not sure if Blue Heron can do what you want - as @lawik said, it is focused on BLE, which may not cover what you need. If you can link to an OBD Bluetooth adapter that you are considering, maybe I can give an informed answer of whether it can be possible with BLE.

There are tools in the Bluez family which can be used, depending on your use case. These are command line programs which can be invoked to interact with a Bluetooth chip. Probably easier than writing it in C, if it suits your needs.

I think USB might be easier. If the OBD USB adapter uses UART, you can use Circuits.UART, which is a mature project. I guess @ConnorRigby might now, I think he has done some stuff with OBD and Elixir.

There’s also a few other places to look at, like:

I hope that gives you some inspiration for moving forward :slight_smile:


You should be able to do anything the Pi can do over USB with Nerves but I don’t know enough to say how easy or hard it is. Does this have to do with the CAN bus stuff in cars? I think I’ve heard of people doing things with that but no examples top of mind.

Some people handle bluetooth via an Arduino with Bluetooth or similar which they connect to the Pi. There are already Bluetooth libraries for many of those devices I believe. And making that talk to the Pi is simpler.

Unfortunately with Bluetooth and Nerves you’ve run into a frustrating part where the solution wr all want isn’t ready to use and all the options are a bit messy. But it can certainly be done.

1 Like

this project should get you going for usb:

see thread here: Pi_dash - automotive (rally) dash written in Elixir and React that runs on Raspberry Pi - #2 by akoutmos

I’ve been meaning to get that project going over ble (cheap ELM327) with blue_heron - but haven’t had time…

Either way having an rpi0w for ble/nerves seems recommended at present…

A great trick is to use this special firmware on the rpi0w (Bluetooth with Nerves notes · GitHub) - which means you can plug it in to your main host and do the development on your main computer (mac in my case) and have rapid iterations etc. in figuring out the ble part…


Thank you all for your efforts.

I see this project, and it seems to be good for me. At first, I install circuits_uart on my Nerves project and after burning on it. I connect to my nerves and run this function:


iex(5)> Circuits.UART.enumerate
%{"ttyAMA0" => %{}, "ttyS0" => %{}}
iex(6)> Circuits.UART.enumerate
%{"ttyAMA0" => %{}, "ttyS0" => %{}}
iex(7)> {:ok, pid} = Circuits.UART.start_link
{:ok, #PID<0.1130.0>}
iex(8)> Circuits.UART.enumerate
%{"ttyAMA0" => %{}, "ttyS0" => %{}}

but it can not find anything, although I connected 3 different USB to my Raspberry Pi 4:

I have read its documents, but I couldn’t fix this.