Pairing my Bluetooth Keyboard/touchpad


28 posts   Page 1 of 2   1, 2
by Fenlig » Tue May 29, 2012 4:47 am
Hey Guys,

So I bought one of these specifically for my Raspberry Pi:
http://www.riimini.com/category/rii-min ... -rt-mwk02/

But I'm having issues pairing it to my Pi. I am newish to Linux and would really appreciate some help.

This is as far as I get:
Code: Select all
skay@raspberry:/$ lsusb
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp/
Bus 001 Device 005: ID 413c:2106 Dell Computer Corp. Dell QuietKey Keyboard
Bus 001 Device 004: ID -a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
......
Posts: 13
Joined: Tue May 29, 2012 4:38 am
by Fenlig » Tue May 29, 2012 7:37 am
Okay so im getting further but still stuck...
Code: Select all
skay@raspberry:~$ hcitool scan
Scanning ...
        DC:2C:26:E6:15:59       bluetooth iPazzPort
skay@raspberry:~$ rfcomm connect hci0 DC:2C:26:E6:15:59
Can't connect RFCOMM socket: Connection refused
skay@raspberry:~$
Posts: 13
Joined: Tue May 29, 2012 4:38 am
by AndrewS » Tue May 29, 2012 10:59 am
I don't have any bluetooth hardware myself, but maybe the "connection refused" means you need to run the command as root with sudo? i.e. sudo rfcomm connect hci0 DC:2C:26:E6:15:59
User avatar
Posts: 2789
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by godFather89 » Tue May 29, 2012 11:24 am
rfcomm is serial over bluetooth. Keyboard and mouse are HID devices over bluetooth.
Try this steps http://idebian.wordpress.com/2008/07/06/manage-hid-bluetooth-devices-in-linux/.
Posts: 150
Joined: Fri May 18, 2012 9:40 am
Location: Timisoara, RO
by Fenlig » Tue May 29, 2012 4:40 pm
Fair enough that makes sense but I canno install Bluez-gnome as its not in the repository i think.

Code: Select all
skay@raspberry:~/dbus-1.5.12$ sudo apt-get install bluez-gnome
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package bluez-gnome is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'bluez-gnome' has no installation candidate
skay@raspberry:~/dbus-1.5.12$
Posts: 13
Joined: Tue May 29, 2012 4:38 am
by danieln » Wed May 30, 2012 1:27 pm
Hi,

I also bought the Rii mini (RT-MWK02+). There are actually a few different models which all go by the same name. The main difference is afaik a bluetooth or a 2,4 ghz(?) connection. So when you're going to buy one, be careful which one you'll order.

I got it to work. Here's what I had to do (I basically followed the instruction from http://wiki.debian.org/BluetoothUser):
Code: Select all
apt-get install bluetooth bluez-utils blueman
startx

After installation went through and you get into the gui, it's quite easy to pair the Rii with the Pi.
After rebooting the Rii starts working right away. If not, just turn the Rii off and on again.
Posts: 3
Joined: Wed May 30, 2012 1:20 pm
by neilpercy » Thu May 31, 2012 9:26 am
danieln wrote:Hi,

I got it to work. Here's what I had to do (I basically followed the instruction from http://wiki.debian.org/BluetoothUser):
Code: Select all
apt-get install bluetooth bluez-utils blueman
startx

After installation went through and you get into the GUI, it's quite easy to pair the Rii with the Pi.
After rebooting the Rii starts working right away. If not, just turn the Rii off and on again.


Hi Daniel, thanks for the information above, go me going in the right direction and almost works but crashes/locks up the pi/xwindow on pairing???

I had to also use
Code: Select all
sudo apt-get update
as the bluez blueman update showed a few lines of error 404:not found which the update cured.

I am using an xenta bluetooth keyboard and mouse combo HERE with a Cambridge Silicon chip usb dongle.

I can get the device to show in Blueman Manager, it will then get a key symbol once paired and crashes, reboot and make device an 'input device' it crashes, reboot 'refresh services' does bring up some coloured icons but another crash!

If I try to use the bluetooth keyboard to login to the pi the first keystrokes send the pi crazy, thousands of lines of text and code blocks flash by and eventually it locks up and crashes!! :(

I'm going to try some of the options in the wiki you link to but it looks like my device is no good for the pi/linux??

Any suggestions greatfully appreciated,

cheers

neil
Posts: 10
Joined: Mon May 28, 2012 11:37 am
by neilpercy » Thu May 31, 2012 8:47 pm
I have finally got somewhere :)

following the instructions here I finally got my keyboard&mouse combo working - hooray!

short lived joy :(
/hooray! mode end

I followed all the instructions, including - sudo update-rc.d keyboard defaults - but this is for Ubuntu! On reboot I get a constantly scrolling error referring to the keyboard file I created. Doh :o

I have now found pages referring the the error message I got
- insserv: warning: script 'keyboard' missing LSB tags and overrides -
here and I am attempting to understand what is required, but my Linux experience is limited, and now confused by Ubuntu, Debian and the rest....

if anyone has any pointers regarding "missing LSB tags and overrides" I'd be most grateful.


many thanks

neil
Posts: 10
Joined: Mon May 28, 2012 11:37 am
by Andre-W » Sat Jun 02, 2012 5:41 am
I had the same issue yesterday. You need to declare the dependencies for the script for LSB.

I've just copied the declaration from the bluetooth init script and changed the required-start dependency to bluetooth for making sure that the script just starts if bluetooth is started.

Just add the following lines to your /etc/init.d/keyboard below #!/bin/sh:

### BEGIN INIT INFO
# Provides: keyboard
# Required-Start: bluetooth
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Connect to bluetooth keyboard
### END INIT INFO

Best regards,

Andre
Posts: 24
Joined: Fri Jun 01, 2012 1:56 pm
by neilpercy » Fri Jun 08, 2012 10:34 pm
Many thanks Andre, exactly what I was looking for :)

I haven't got round to trying it yet, been 'playing' with Openelec and RaspBMC for the last couple of days.

Doesn't time fly when you're having: fun / issues / experimenting / banging your head against a brick wall / re-imaging your SD card.................


thanks


neil
--------------------------------------------------------------------------------
Posts: 10
Joined: Mon May 28, 2012 11:37 am
by adi518 » Thu Jun 28, 2012 9:55 pm
Sorry for bumping but I have a question regarding this keyboard.

It's available on ebay through various chinese sellers and I figured, like previously mentioned, that it comes in a 2.4ghz wireless version and a bluetooth version. So the guy here, made it work but still is it better to just get the 2.4ghz version and enjoy plug and play? You don't need scripts and mess around with that one, or do you?

Thanks. :)
Posts: 27
Joined: Fri Jun 22, 2012 6:58 pm
by neilpercy » Fri Jun 29, 2012 8:40 am
go for the 2.4Ghz wifi option - should be much easier!

still not got bluetooth keyboard combo working :(
Posts: 10
Joined: Mon May 28, 2012 11:37 am
by neilpercy » Thu Jul 05, 2012 4:19 pm
Hi Andre,

I'm still having no luck with my bluetooth keyboard, although I'm now trying to use it with RaspBMC, which is Debian based.

see here for my lack of progress and stuck requiring LSB tags etc again, even though I have them (I think??)

cheers

neil
Posts: 10
Joined: Mon May 28, 2012 11:37 am
by meltwater » Thu Jul 19, 2012 9:53 am
Hi guys.

First off, it is really starting to bother me about how difficult it seems to setup and configure things on the raspberry pi at the moment.

I know there are various guides for various things being written etc but often we end up with snippets of information scattered around which tend to confuse things...it ends up as being pot luck if you hit on the right combination of instructions to if something ends up working or not.

Please assume that people are working from a clean image, and put in the steps you would do from that clean image in order to get something working (I know it may not be correct for someone else - as often different hardware comes into play) but at least with a full set of instructions they can try it and work out yes or no it works for them too.

Right..on topic here. Bluetooth keyboard.
Like the posters above, I'd tried various parts of the links and anything else I thought was suitable via google but kept getting errors at various points in commandline and in xwindows. The closest I was getting was in xwindows via the bluetooth icon - following installing blueman (I guess) - not pairing / paring but not connecting to the input service / connecting to the input service when not paired etc etc). Then suddenly, on my last try before thinking, I'd best try it on my windows laptop instead just to see if it works at all, it paired and connected... why...well I am not sure, perhaps because I installed "bluez-compat"

Fortunately I cloned my SD card before doing any of it, so I am going to confirm the steps and then I'll come back and post them to see if it works for everyone else. Sound good?
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by meltwater » Thu Jul 19, 2012 10:30 am
This running the Debian Squeeze Image (not totally clean or standard - but hopefully close enough).

I doubt this'll work in terminal without xwindows being started first, but it is better than nothing...

sudo apt-get ​install bluetooth bluez-utils blueman bluez-compat

No idea if needed, but lets reboot anyway - it'll give any new bluetooth stuff to be started etc.

sudo reboot

​We may as well see if we have the bluetooth dongle detected and if we can see any devices (ensure they are on and discoverable before doing it).

hcitool dev

Nope, I didn't see anything. Putting the dongle and plugging back in and doing it again, it seems to detect it and gives me the address. Good!

hcitool scan

The scan reports the name and address of my BT keyboard. Excellent!

Lets see if xwindows will play now:

startx

Right, first new things we should notice when it finishes loading (when the cpu activity drops), is we have a little Bluetooth icon sitting next to the clock. Excellent, this means the bluetooth manager util has installed ok and also (if no red X) it is connected to the bluetooth dongle ok.

Right-click on the icon and select: Devices...

1. Ensure your device is set to be discovered and press search.

2. Press the icon to scan for devices...hopefully you'll see your device appear in the list (with a keyboard type icon next to it), if not rescan and ensure you have put it into discovery mode.

3. Select it and press the + icon to add it (or right-click on it and "Add Device").

4. Then select it again and pres the key icon to pair it (or right-click on it and "Pair").

5. Enter a passkey (picking an easy one first time - tick the box to view it so you can be sure you are going to type the right key). When you press next, type the key immediately on the BT keyboard and press enter. "Hopefully" it'll now pair.

6. If it still isn't responding, try right-clicking and connecting to "Input Service". Now if that fails, or if your pairing fails, remove it (right-click Remove) and go through the steps again (I've had it connect to the Input Service with being paired with doesn't work).

7. Finally, you may notice that when the keyboard goes to sleep, you'll get a notification come up asking for you to accept it again (so ensure you still have a normal mouse handy to select the "always allow" option). It can take a while each time to reconnect after it goes to sleep.

Oh...just rebooted and it is working directly at login (direct on terminal)! SWEET.

Hardware info:
BT Adapter - a generic BT adaptor from pound shop - Livewire H-28236 - looks like a usb plug with black semi-circle on
BT Keyboard - KeySonic BT Keyboard and Trackpad - ACK-340BT - Bluetooth ID BTKB-71DB

Chances are, it'll put a bit of load on the USB so as always try it first with good power and perhaps using a powered hub.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by magnosantos » Thu Aug 02, 2012 5:33 pm
And how to do it on Command Line?

I ask this, because i don't have X available.
Posts: 1
Joined: Sat Feb 25, 2012 3:57 pm
by faceless » Fri Aug 03, 2012 9:37 pm
I have the same keyboard and have got this going without using the bluez-compat package using the Debian Wheezy-based Raspbian. Here's how:

First, press and hold bluetooth button on device until it flashes, then:

Code: Select all
# aptitude install bluetooth
# hcitool dev
Devices:
   hci0   00:15:83:0C:BF:XX
# hcitool scan
Scanning ...
        DC:2C:26:D8:A5:XX   Macro Keyboard
# bluez-simple-agent hci0 DC:2C:26:D8:A5:XX
RequestPinCode (/org/bluez/1851/hci0/dev_DC_2C_26_D8_A5_4F)
Enter PIN Code: 0000

... now type same pin code (you can see I chose 0000 above) on the keyboard and hit enter. Then to connect the keyboard:
Code: Select all
# bluez-test-input connect DC:2C:26:D8:A5:4F


bluez-simple-agent should only need to be done once to pair the keyboard, and the pairing will last between reboots. It's the approach you'd use to pair any bluetooth device (I wrote more about it here to pair a bluetooth serial device). Once it's paired bluez-test-input connect will connect the keyboard and bluez-test-input disconnect will disconnect it. If you want to forget any pairing, it's bluez-simple-agent hci0 DC:2C:26:D8:A5:XX remove.

Of course this isn't specific to the Raspberry Pi - It should also work on other Debian or Ubuntu systems with BlueZ 4.0.

As for how to get it to work on reboot, try adding bluez-test-input connect to /etc/init.d/rc.local. That will work, although no doubt there's a more "official" way to do it.
Posts: 4
Joined: Tue May 22, 2012 11:19 am
by meltwater » Fri Aug 03, 2012 10:34 pm
That is superb!
Thanks for posting it, very helpful.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by faceless » Sat Aug 04, 2012 9:29 pm
I should add I haven't quite figured out how to get it to auto-pair if I turn the keyboard off: in theory the keyboard will attempt reconnection and if I've done bluez-test-device trusted NNN before the connect, it should (I believe) allow reconnection from the device. In practice this isn't happening and if I power-cycle the keyboard I have to restart the connection from the computer.

I don't have the instructions for the keyboard so I'm flying blind a bit on this one, maybe there's a trick to getting the keyboard to reconnect...
Posts: 4
Joined: Tue May 22, 2012 11:19 am
by meltwater » Mon Aug 06, 2012 1:58 pm
faceless wrote:I should add I haven't quite figured out how to get it to auto-pair if I turn the keyboard off: in theory the keyboard will attempt reconnection and if I've done bluez-test-device trusted NNN before the connect, it should (I believe) allow reconnection from the device. In practice this isn't happening and if I power-cycle the keyboard I have to restart the connection from the computer.

I don't have the instructions for the keyboard so I'm flying blind a bit on this one, maybe there's a trick to getting the keyboard to reconnect...

Mine seems to reconnect (at least for the gui method - once setup works fine in commandline) when power turned off, my keyboard has a separate pairing key so the pairing is remembered. Sometimes it takes a little tapping to get it to connect or if the Rpi has been rebooted, I sometimes need to reinsert the dongle.
I'll give your commandline method a go, next time i have clean install to try it on.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by kmidderigh » Wed Aug 08, 2012 4:46 pm
I've been following the information in this topic and its been very useful when trying to get my bluetooth motorola keyboard and mouse working......however and heres the but i'm starting to get worn down by the randomness of my Rpi (computer kit shouldnt behave like this :cry: )

The bluetooth adapter i have (Tesco nano one) is always listed on the lsusb list but about 50% of the time after reboot/startup the hcitool dev command does not find it (I'm using a 4 port powered usb hub and sometimes moving it to a different port helps).

If it is found I cant connect to the keyboard/mouse from the command line - I keep getting authorisation failed response. When I launch startx the blueman package loads ok and I have managed to locate my mouse and keyboard once however could only get the mouse to pair - and then the whole Rpi froze.

no matter what i try (combinations of mouse and bluetooth adapter in different usb hub/native Rpi usb slots) when I do get the adapter to behave it ALWAYS kills my wired mouse which then prevents me completing the blueman connections....its getting to hair tearing stage - anyone have any ideas whats causing this random behaviour/ mouse killing ?
Posts: 10
Joined: Thu May 10, 2012 5:32 pm
by meltwater » Wed Aug 08, 2012 5:06 pm
Here is something you can test...

Connect up your powered hub (with it powered with it's own supply), now without putting power on your Raspberry Pi, do the LEDs light?

If the answer is yes, then your hub is trying to power the raspberry pi through the USB port...which means the 140mA polyfuse will be tripped (this can take hours to days to return to normal - depending on how sensitive your devices are). If you have this, then you may need to cut the +5v wire inside your USB hub, on the cable which connects to the Rpi (or you can put a diode on it)! It sounds scary, but all it will do is to stop power flowing back into the RPi (the hub won't work as a normal hub without external power - if this is a problem, put a switch on the wire instead).

Fingers crossed that is your problem and the above should fix it. Or I've guessed wrong!
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam
User avatar
Posts: 993
Joined: Tue Oct 18, 2011 11:38 am
by kmidderigh » Wed Aug 08, 2012 6:32 pm
the LED lights do light under the situation you describe (with Belkin 4 port powered mobile hub - for others ref).

Not sure i can get into the hub that easily as theres no screws...looks like a cable cut is the way to go....just got to identify the correct one...i'm sure google can help me with this.

Will test this out tomorrow and report on progress.

Thanks for the tip
Posts: 10
Joined: Thu May 10, 2012 5:32 pm
by dominicclifton » Thu Aug 23, 2012 11:22 pm
my Belkin F8T009 would not pair with the RT-MWK02. I switched to using an MSI dongle instead.

When i used the belkin dongle bluez-simple-agent would report timeout errors after typing in the pin and pressing enter. As follows:

Code: Select all
root@raspberrypi:~# bluez-simple-agent hci0 DC:2C:26:AF:B2:9E
RequestPinCode (/org/bluez/1383/hci0/dev_DC_2C_26_AF_B2_9E)
Enter PIN Code: 1234
Release
Creating device failed: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.


working MSI dongle reports:
Code: Select all
root@raspberrypi:~# hciconfig -a
hci0:   Type: BR/EDR  Bus: USB
   BD Address: 00:11:67:AF:F0:8B  ACL MTU: 1021:8  SCO MTU: 48:10
   UP RUNNING PSCAN
   RX bytes:2698 acl:56 sco:0 events:70 errors:0
   TX bytes:748 acl:16 sco:0 commands:44 errors:0
   Features: 0xff 0xfe 0x8d 0x3e 0x88 0x19 0x00 0x00
   Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
   Link policy: RSWITCH HOLD SNIFF
   Link mode: SLAVE ACCEPT
   Name: 'raspberrypi-0'
   Class: 0x420100
   Service Classes: Networking, Telephony
   Device Class: Computer, Uncategorized
   HCI Version: 2.0 (0x3)  Revision: 0x2c6
   LMP Version: 2.0 (0x3)  Subversion: 0x2c6
   Manufacturer: Integrated System Solution Corp. (57)


non-working Belkin dongle reports:

Code: Select all
root@raspberrypi:~# hciconfig -a
hci0:   Type: BR/EDR  Bus: USB
   BD Address: 00:0A:3A:62:F3:9C  ACL MTU: 377:10  SCO MTU: 64:8
   UP RUNNING PSCAN
   RX bytes:987 acl:0 sco:0 events:23 errors:0
   TX bytes:358 acl:0 sco:0 commands:23 errors:0
   Features: 0xff 0xfe 0x0d 0x38 0x08 0x08 0x00 0x00
   Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
   Link policy:
   Link mode: SLAVE ACCEPT
   Name: 'raspberrypi-0'
   Class: 0x420100
   Service Classes: Networking, Telephony
   Device Class: Computer, Uncategorized
   HCI Version: 1.2 (0x2)  Revision: 0x0
   LMP Version: 1.2 (0x2)  Subversion: 0x309
   Manufacturer: Broadcom Corporation (15)


I installed:

Code: Select all
python-gobject                        3.2.2-1                    Python 2.x bindings for GObject - transitional package
python-gobject-2                      2.28.6-10                  deprecated static Python bindings for the GObject library
bluez                                 4.99-2                     Bluetooth tools and daemons
bluez-compat                          4.99-2                     BlueZ 3.x compatibility binaries
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by ctheroux » Fri Sep 14, 2012 1:41 am
I have written on by blog a procedure on how to make bluetooth keyboards and mice work. I have been able to make many devices work. You do not need to start X to do the pairing. Hope it might help some of you. The url is http://www.ctheroux.com/2012/08/a-step-by-step-guide-to-setup-a-bluetooth-keyboard-and-mouse-on-the-raspberry-pi/
Posts: 4
Joined: Fri Aug 10, 2012 1:07 am