Raspberry Pi + Android via Bluetooth

A place to talk about all things mobile
Post Reply
User avatar
Legit Extremist
Legit Extremist
Posts: 344
Joined: Sun Jul 12, 2009 3:00 am
Location: Victoria, BC, Canada

Raspberry Pi + Android via Bluetooth

Post by lordvic » Thu Oct 03, 2013 6:27 pm

Since we got some smart fellow in the LR community is pretty friggin big, I was hoping somebody can give me a hand. I don't know exactly where to post this topic, but I'm just stabbing at the dark. (Mods, I give you FULL permission to move/copy this to wherever it is suitable, or where the problem can be resolved)

Background info:
I'm a 3rd year electronics and computer engineering student. We have a project term going on, and we've decided to create a WiFi / Bluetooth localization tracking system for a household environment. We are using the RSSI (Received Signal Strength Indication) sent by the target device over WiFi / BT. So we have several Raspberry Pi's located around the house, and a device that is with you that has a wireless connection (smartphone, tablet, smartwatch, laptop, etc) that will broadcast / send a signal...every 1/2 second. The Pi's will pick up the signal and will determine where you are located in the house via signal strength - these values will be compared to a table of values. With the limited time we have, we are using this with only a smart lights system (Philips Hue).

Example: Your iPhone broadcasts a WiFi signal. Pi#1 picks up -20dBm signal. Pi#2 picks up -30dBm. Pi#3 -55dBm. Pi#4 -70dBm. Looking at a table of values, you should be in the kitchen. Send signal to Philips Hue system to turn on lights in kitchen.

So...you walk out of the kitchen and into your room...raspberry Pi's pick up your signal --> your location in the house. Turn off lights in kitchen, turn on bedroom lights. And so on.

The problem:
WiFi seems to be working okay, so we are on to BT testing stage. I was able to have my the BT on my group member's iPhone and my iPod working paired with the single testing Pi unit (we have 5 on hand but only have one configured for testing purposes). It can continuously give the signal strength.

It is unable to pair with Android devices that we (the project group) has on hand. That is...a Samsung Galaxy S3 and a Galaxy Nexus phone. It will refuse BT pairing.

1) installed necessary bluetooth stack / files. "sudo apt-get install --no-install-recommends bluetooth"
2) Scan for available devices; the MAC address. "hcitool scan"
3) Connect to android device. "sudo rfcomm connect 0 [MAC Address] 10 >dev/null &"
4) ** Message pops up on phone asking to pair with raspberry pi. Apply.
5)** Message appears on Pi terminal (Windows version of command prompt) saying "Can't connect RFCOMM socket: Connection Refused
6) Run "hcitool rssi [MAC adress]". Message shows "Not connected."

*** scenarios
a) It will say "Connected" on Apple device, and message will say connected on Pi. If type "hcitool rssi [MAC adress]", it will say something like "Connected. RSSI return value: -7." If device is at point-blank of Pi, value is 0. As I move further away, I will get a values of -5, -7, -12...all the way to -30 / -31 before I am too far away and connection is lost.

b ) On the Galaxy S3, it shows it is paired with the Pi on the phone itself, but the raspberry pi displays connection error message (as above).

c) Nexus phone does not see Pi at BT config screen. When we enter terminal code to connect to Nexus phone, message asking to pair appears on the smartphone. Click Apply. Error message prints out saying unable to connect appears on Raspberry Pi.

I am thinking the protocols used on the Android devices are different, and it won't work, but Apple devices do. RFCOMM is serial to BT....I don't think the Android smartphones are HID to BT (or whatever). If any of you from the LR community has got their Android-based devices working with the Pi over bluetooth, help would be greatly appreciated. (I'll have to try if it works with my ASUS TF300T Android tablet later)
Cooler Master HAF 932 // Phenom II 1090T @ 4.1GHz (not 110% stable) // ASUS Crosshair V Formula 990FX // Thermaltake Frio CPU Cooler // Sapphire Dual-X HD 7970 @ 1150/1500 // 8GB (2X4GB) G.Skill RipJaws + 8GB (2X4GB) G.Skill RipJawsX @1600 8-9-8-21-1T // Corsair TX850 // Corsair ForceGT 120GB SSD // Kingston V200+ 120GB SSD // WD Caviar Black 1TB // LiteON DVD-RW // Windows 7 Ult. 64-bit

Post Reply