geekhack

geekhack Projects => Making Stuff Together! => Topic started by: bcg on Wed, 07 May 2014, 21:46:33

Title: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: bcg on Wed, 07 May 2014, 21:46:33
I started messing with Adafruit's Bluefruit controller (http://geekhack.org/index.php?topic=50183.msg1130915#msg1130915) a while back, and found some success making a host implementation for it in hasu's TMK firmware.  I've been extremely busy over the past few months so this took a lot longer to create that I originally intended... but the awesome folks over at Adafruit were nice enough to post a tutorial that I wrote on how to do it:

https://learn.adafruit.com/convert-your-model-m-keyboard-to-bluetooth-with-bluefruit-ez-key-hid

In the process of completing the project I also ended up porting TMK to the Arduino platform... well maybe porting isn't the right word, more like slobbishly hacking together... so that you can sort of use TMK and load it onto an Arduino from right within the Arduino IDE with having to use Makefiles:

https://github.com/bgould/arduino_tmk_keyboard

I say sort of, because more of the features of TMK don't work yet, like USB  :p   I plan to double back on that part of the project later, at the very least I want to clean some things up in there so I can send hasu a pull request for some small stuff I added.  If there's interest in this approach I'll do more work to port more features of TMK into Arduino.

As far as the actual Model M project goes, I'm really happy with the way it came out... there are definitely some improvements I'd love to make but all in it is a success in my mind.  And if you're a success in your own mind, it doesn't matter what anyone else thinks, right???  Right?!?!?  ;)

Here's a video of my project, let me know what you guys think... also I put a lot of work into the tutorial so hopefully it has all of the details you might need to complete this yourself if you feel so inclined.  I'm considering putting together a GB for parts if enough people show interest.  Bluefruit is FCC certified so its definitely good to go if you're in the US but I'm not sure about legalities or certifications in other countries so do your own due diligence if you care to.

Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: CPTBadAss on Fri, 09 May 2014, 07:32:43
I'm definitely adding that video to the Geekhackers YouTube channel...once I figure out how to do it. That's awesome. It's blowing my mind you can type on your phone using the M.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: BlueBär on Fri, 09 May 2014, 07:54:45
It's added to the playlist now :thumb:
Very nice project!
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: sth on Fri, 09 May 2014, 07:55:29
cool!!! i am linking to this on my blog.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: didjamatic on Thu, 15 May 2014, 22:10:26
This is very impressive and the kind of thing that drove me to GH originally - vintage goodness and modifications to work with modern computer systems.

Well done!
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: berserkfan on Thu, 22 May 2014, 15:00:48
beg pardon, but is it really practical in a realistic setting?

I find that I get plenty of delays with pairing bluetooth devices. sometimes I don't use them for some time, or put computer on standby, and come back and find it takes 30seconds to 2 minutes to get recognized again. That's an unacceptably long delay for an essential like a keyboard, where you can't do anything until they recognize.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: bcg on Thu, 22 May 2014, 20:13:46
beg pardon, but is it really practical in a realistic setting?

I find that I get plenty of delays with pairing bluetooth devices. sometimes I don't use them for some time, or put computer on standby, and come back and find it takes 30seconds to 2 minutes to get recognized again. That's an unacceptably long delay for an essential like a keyboard, where you can't do anything until they recognize.

I guess maybe this project isn't for everybody... but FWIW I've not experienced any of the problems that you're describing.  The bluefruit module stores its pairing information and reconnects almost immediately after being turned on or after being disconnected.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: esko997 on Thu, 22 May 2014, 20:38:46
Very cool project mate, well done!
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: bcg on Thu, 22 May 2014, 20:52:37
Thanks guys for your great feedback  :thumb:
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: berserkfan on Thu, 22 May 2014, 20:57:20
beg pardon, but is it really practical in a realistic setting?

I find that I get plenty of delays with pairing bluetooth devices. sometimes I don't use them for some time, or put computer on standby, and come back and find it takes 30seconds to 2 minutes to get recognized again. That's an unacceptably long delay for an essential like a keyboard, where you can't do anything until they recognize.

I guess maybe this project isn't for everybody... but FWIW I've not experienced any of the problems that you're describing.  The bluefruit module stores its pairing information and reconnects almost immediately after being turned on or after being disconnected.

'almost immediately'?

Is it because you have a superior/ better quality device? How can I do the same for my bluetooth devices, which simply don't seem to function the same way.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: lightsout714 on Thu, 22 May 2014, 21:06:25
It's added to the playlist now :thumb:
Very nice project!

Can you guys link me to the youtube channel?

Is this what you mean?
https://www.youtube.com/channel/UCilWPjW1SHDT4_elCiu-zfw/feed
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Smasher816 on Thu, 22 May 2014, 21:25:10
It's added to the playlist now :thumb:
Very nice project!

Can you guys link me to the youtube channel?

Is this what you mean?
https://www.youtube.com/channel/UCilWPjW1SHDT4_elCiu-zfw/feed

Here you go. https://www.youtube.com/playlist?list=PLaHUwihOxP4BCZW6-KKyQs9FRISDlEFiH
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: lightsout714 on Thu, 22 May 2014, 21:40:01
It's added to the playlist now :thumb:
Very nice project!

Can you guys link me to the youtube channel?

Is this what you mean?
https://www.youtube.com/channel/UCilWPjW1SHDT4_elCiu-zfw/feed

Here you go. https://www.youtube.com/playlist?list=PLaHUwihOxP4BCZW6-KKyQs9FRISDlEFiH
Thank you!
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Tranquilite on Sun, 25 May 2014, 02:43:16
beg pardon, but is it really practical in a realistic setting?

I find that I get plenty of delays with pairing bluetooth devices. sometimes I don't use them for some time, or put computer on standby, and come back and find it takes 30seconds to 2 minutes to get recognized again. That's an unacceptably long delay for an essential like a keyboard, where you can't do anything until they recognize.

I guess maybe this project isn't for everybody... but FWIW I've not experienced any of the problems that you're describing.  The bluefruit module stores its pairing information and reconnects almost immediately after being turned on or after being disconnected.

'almost immediately'?

Is it because you have a superior/ better quality device? How can I do the same for my bluetooth devices, which simply don't seem to function the same way.

While I don't have an answer for getting better reconnect times for your particular bluetooth devices, I find that after a bluefruit ez-key has been paired, it can consistently go from a powered down state to being reconnected and sending keypresses in 3-5 seconds.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Nickelbawker on Fri, 05 September 2014, 21:10:30
Hey guys thinking about building one of these soon for a Poker II let me know any updates
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Smasher816 on Sat, 06 September 2014, 10:54:15
You can click notify at the bottom of the page and you will get an email anytime someone posts a reply.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Pulsefone on Mon, 24 August 2015, 10:32:06
Hi! Not sure if anyone's still watching this thread, but I tried implementing this project on an 84 key ssk model m, but I can't seem to get the PS2 Matrix to initialize without the arduino plugged into my computer and the serial monitor running. Is this something I can do through the arduino IDE, or am I looking at a more complex (to me) problem? Sorry for the amateur question. I'm not much of a coder. 
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: bcg on Mon, 24 August 2015, 10:59:11
IIRC, if you have the DEBUG option set, it will wait for the Serial Monitor to initialize before starting up the keyboard.

Try disabling DEBUG option in your config and upload the code... it may work then.  If you still have issues with it let me know and I will try to help you figure it out.
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Pulsefone on Mon, 24 August 2015, 12:46:16
I tried that originally, cause I figured that was the issue, but no dice. Even with debug commented out in config.h and in terminal_bluefruit_converter I can't seem to get the keyboard to work. It works fine, however, (with the exception of the shift keys, which are a little wonky and seem to be adding an extra keystroke, different for both, but this one seems to be the more pressing issue) when the serial monitor is turned on and debug is set to true. Really great tutorial, btw. Thanks a lot for your hard work on this. I'm excited to get it working, and I'm learning quite a bit about this platform. :)
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: rowdy on Mon, 24 August 2015, 17:07:49
Hi! Not sure if anyone's still watching this thread, but I tried implementing this project on an 84 key ssk model m, but I can't seem to get the PS2 Matrix to initialize without the arduino plugged into my computer and the serial monitor running. Is this something I can do through the arduino IDE, or am I looking at a more complex (to me) problem? Sorry for the amateur question. I'm not much of a coder. 

Welcome to Geekhack!

A valid question, and one that has bumped this thread to the top of "making stuff together".  If you can't get it working, you're welcome to (lightly) bump this thread, or even make a new thread of your own detailing (with pictures) what you have done, as I'm sure people would be interested to see :)
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Hypersphere on Mon, 24 August 2015, 17:19:30
Thanks for sharing this project! Nice work!
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Pulsefone on Wed, 26 August 2015, 13:56:30
IIRC, if you have the DEBUG option set, it will wait for the Serial Monitor to initialize before starting up the keyboard.

Try disabling DEBUG option in your config and upload the code... it may work then.  If you still have issues with it let me know and I will try to help you figure it out.

Even when I disable the option (by commenting out, and by setting the value to false) neither way seems to stop the keyboard from hanging. Is it possible I need to disable it elsewhere, as well? I'm not sure where to begin. I've been looking at the gluecode.h file, and I'm wondering if that is still running debug_enable, even though it's not being called for in the .ino file? I'm just spitballing, here, though, cause I am truly clueless. Any ideas you can offer would be greatly appreciated. I can play with it, I'm just not sure where I should start.
-Ed
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Pulsefone on Wed, 26 August 2015, 17:12:31
Got it working!! So flippin' excited.  :D I just added this little while statement to the runTask loop:
Code: [Select]
    // this the main hook into the tmk firmware that handles all the heavy lifting
    while (!Serial){
      KeyboardFirmware.runTask();
    }
and things are functioning normally. Thanks again, Ben, for this really awesome mod. I'll post some pics when I button the keyboard back up.

-Ed
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: rowdy on Wed, 26 August 2015, 21:35:19
Well done for resolving it, and thank you for posting the solution :)
Title: Re: I Bluetoothed a Model M with an Arduino and a Bluefruit
Post by: Phosphatide on Mon, 31 August 2015, 21:24:17
Forgive me for reviving this thread yet again, though I suppose I'm glad I won't be doing it after too long of a time since the last revival. I'm rather new to the world of electronics on a more hands-on tinkering level, so hopefully I can clearly describe my question and I can walk away enlightened instead of leaving us all a bit confused.

The keyboard I rescued from being recycled away is a 101-key "President Micro Systems" branded keyboard that uses a 5-pin DIN connector, which I believe (based on the research section of the Adafruit article) means this is an AT keyboard with scan code set 2. I understand that the Arduino sketch from your project utilizes scan code set 3, or at least that's what I got from reading the article and skimming through the code itself. If necessary, how would I be rewriting the sketch to accommodate scan code set 2? I've only just recently started proper research of what scan codes are, so I'm a tad confused on what it means for a keyboard to use one set over another.

I can at least say the keyboard works fine when I use a converter to use the keyboard with PS/2, if that helps in some way.

Sorry for the trouble if any!