Sending location data to the car

To be able to navigate autonomous I need, next to the odometry, some independent location data. I had an old Android phone laying around, that’s why I didn’t want to buy new sensors, but wanted to use the phones GPS and compass instead.

I wrote an app to start a background service that collects location and orientation data, and wanted to send the data to Ubuntu.

2016-05-16 17.24.01

Because serial communication works well with the Arduino, I wanted to use a serial connection for the smartphone too. Though I found some good recourses to setup a serial connection over usb ( , and ) I didn’t get it to work. Probably because my phone doesn’t support OTG which is needed to detect the incoming serial connection.


That’s why I first decided to setup a bluetooth connection. While doing some research I found out that it’s really simple to write to a virtual serial port when the device is already paired to a computer ( )

My app starts a background service and sends frequent locationupdates, with:

  • latitude
  • longitude
  • compass
  • accuracy (in meters)

Bluetooth serial port on the RPi 3

On the Raspberry Pi 3 bluetooth didn’t work under Ubuntu 15, so I installed to Ubuntu Mate 16.04 for the bluetooth drivers.

Pairing with the phone was no problem at all, getting a bluetooth serial port on the other hand took me a week. Apparently you need to start the deamon in compatibility mode.

To do this, edit: /etc/systemd/system/dbus-org.bluez.service

and test the port with:

Create a service unit to start the port automatic at startup (see link where I found the compatibility issue below for an example, note that for my installation the location rfcomm was not located in local but at /usr/bin/rfcomm watch hci0)

Next problem was that I only could open the /dev/rfcomm0 port as root (Error when not logged in as root: Device or resource busy). In the logfiles I found ModemManager was trying to connect the port. After uninstalling (sudo apt-get remove modemmanager) the rfcomm0 port was released.