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.
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 ( http://www.allaboutcircuits.com/projects/communicate-with-your-arduino-through-android/ , https://felhr85.net/2014/11/11/usbserial-a-serial-port-driver-library-for-android-v2-0/ and https://github.com/mik3y/usb-serial-for-android ) 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 ( http://stackoverflow.com/questions/6565144/android-bluetooth-com-port )
My app starts a background service and sends frequent locationupdates, with:
- 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
ExecStartPost=/usr/bin/sdptool add SP
and test the port with:
sudo rfcomm watch hci0
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.