No, this article is not inspired by the recent launch of fallout 4. Actually, i have been thinking of building this for 6 months, and now that i had the materials, and 25hs of work later, is finally done :D. I’ll give provide as much as detail as i can (including source code) but be aware that this is not a step by step tutorial, but if you want to build something similar, you will have everything you need right here.



Why?

Well, is has more personal reason than anything else. like a year ago, i brought a smartwatch, a zgpax s8, why this model in particular, is also a cellphone, and i wanted to simplify the setup that i carry with me, as i don’t text a lot, i don’t use instagram, i mostly use the cellphone to call, some whatsapp messages and check frequently the email and answer urgent stuff. Unfortunately, i discovered that the screen was so small that couldn’t do a thing, not even a call. And i haven’t found a stylus enough small to be a replacement. For that reason, i started to crank a flexible keyboard that i could take with me, in my other arm. It would not only look cool, but also, it would be really useful for me, as i really miss the physical keyboards that the phones used to have.

Bill Materials

So, let’s go straight to what we need:

1) Bluetooth module for arduino that support HID protocol (in my case i used this one: https://www.sparkfun.com/products/retired/10938 but has been recently retired, is supposed that the silver version, also has HID protocol, but check with sparkfun support first )

2) 2x Membrane keypad of 4x4 / 16 keys

3)Arduino Nano, Teensy or Bareduino (whatever works, you gonna need at least 17 PWN and one RX/TX), in my case, i used a chinese copy of the arduino nano and worked perfectly

4) A li-po 3.7V battery (in my case, i used a cellphone battery of a nokia 1100 of 1100mah)

5)a lipo battery charger (something like this: http://www.aliexpress.com/item/TP4056-1A-Lipo-Battery-Charging-Board-Charger-Module-lithium-battery-DIY-Mini-USB-Port-Free-shipping/1991101915.html )

6) RGB common anode Led

7) small switch on/off key

8) cables, instant glue and soldering iron to build everything !

9) some kind of holder for all the electronics. in my case, i used an old remote control protector, see below for details.

Some notes:

A) you need to 2 keypads to emulate the phone keyboard. at least in english, you need a minimum of 32 keys, in 3 sets of keyboards, so you need 2 keypads

B) you can power up an arduino from a 3.7V battery directly to the VIN, whiteout the need of changing the voltage regualator or anything else.

Let’s build it !

If you have some, even minimal experience in arduino and/or IoT you must realize that this is a very simple project, so i’m only going to highlight the important parts:

Cut the keypads to occupy the minimum possible space

The keypads has extra, unused space on the sides, so if we cut them with scissors, we will be able to save a lot of space. BEWARE, it doesn’t mean that you must cut on the limit lines that the keypad shows!!!

If you cut on those lines, you can broke it ! The way to do this, is to peel off the protection of the adhesive to see the keypad inside’s follow the boundaries of the button traces.

Put the keypads in series

Like this is going in the arm, between the wrist and the elbow, the keypads are going to be placed together. this means that the position of the rows, and the number of the rows in the final keyboard, will be the same (4) and the only thing that changes, are the columns (8). So, when you connect the rows, bridge the cable with the rows of the second keypad. In total you will use 12 PWN inputs (4 for rows, 8 for columns) and not 16 like it usually does. Neat trick right? :)

Configure the Bluetooth module

All Bluetooth modules uses serial connection to communicate with the arduino. But before doing anything, you must configure it. Each module has different settings, so i’m gonna describe the ones that must be used with the sparkfun HID module. To interface with the module, you need a serial to usb adapter, or an arduino. Something important if you are gonna use the Arduino, is that you need an Arduino Mega or UNO, why SoftwareSerial doesn’t work with the module (even if sparkfun say that it work, it doesn’t, not even works with 9600 baud rate). So you need 2 Serial ports at least, to communicate with it (one for the PC, another for the BT module). This code can be used to use the arduino as a bridge. All connected, now open the serial monitor and write:

$$$

and click “Send”

The bluetooth mode should answer with CMD and the led on it should go on/off really fast. That means you are in Configuration mode. The first thing, just for security you must do, is to change the baud rate to 9600. Be sure to select the option “Newline” in the arduino console, before sending the commands.

SU,9600



Then reboot the modem:

R,1

Then you are gonna need to change the arduino code to connect to the modem with the 9600 baud rate (by factory, is set to 115K)

Here is a list of basic commands:

D = Basic settings

E = Advanced Settings

O = Other Settings

SN,<name> = Device name

SP,12345678 = Security pin code

S~,6 = Activate HID profile

SF,1 = Back to factory settings

SM,6 = reconnect automatically to last paired device

SA,<0-4> = security protocol, by default is 1, recommended is 4

You can see details of all of this in the spreadsheet of the module, here:

https://cdn.sparkfun.com/assets/1/e/e/5/d/5217b297757b7fd3748b4567.pdf



After all of that is done, you can start wiring everything !

Translating input from keypad to the BT module

Really, the BT modules does all the hard job, whatever you send, if it has the HID profile active, it will be recognized by the phone. You just need to take care of special keys, that are not text’s and have a control of what keymap are you using. To manage the membrane keypad, i used Keypad Library. This lib maps 1 char list to the input of the membrane keypad. You just need to specify the map of values, the row, columns pins and the amount of columns and rows too. But, like i described before, you need to emulate 3 sets of keys, like in the cellphone, so the maps of keys to pass to the library, are just index of arrays of the real keys maps. You can see the code for this here.

Manipulating special characters and keys

Key’s like backspace, or enter key, must be handled in a unique way. To be in the safe side, is better to not use Serial.print() to send this kind of keys, but to use Serial.write() with the hex code of the input. The funny thing, is that the original spreadsheet of the BT module, had the wrong hex code for inputs like backspace, or enter, and i have been able to find the correct ones thanks to this article of adafruit. The advantage of the code structure you can see in the github repo, is that you can do custom keys (like the switch key, that is never sent to the BT module, is used internally) or map the keyboard as you wish, even with special keys that virtual keyboards usually doesn’t has (like direction arrows in my case).

Beware of what you use to enclose everything

As i said, you gonna need something to fix the cable’s, arduino, module, etc.. In my case, i used an old remote controller protector, that had a cushion, is almost water proof (at last to some small rain). But even if it proof to be useful, it was a really pain to fit everything and glue everything in a correct position, plus, like it had some cushion and the cables went below, some keys are hard to press and not really comfortable to use. Ideally, if you can design and 3D print a case with a flexible material like Nylon, it would be a lot better.

Leave at hand, the RX and TX connection if you use an arduino nano !!

One of the advantages of arduino, is that you can update the software as much as you want, with improvements or tweaks. The problem, is if you need to do it, RX and TX pins must remain disconnected, to be able to upload the sketch. You will have it wired to the BT module, so be sure to have it at hand, in a accessible location, so you can disconnect them to upload a sketch update !

Building the top cover

Another of the tasks that was a challenge in this project, was to build the top cover for it. I was planning to put inside the plastic cover that i already had, but in a silly mistake, i melted the power switch, and in the task of replace it, i melted the plastic cover too. This forced me to build a design that would cover all the arm case. Like the keys where so small, i couldn’t print it as a sticker (in vinil), so it was printed in laser, in auto-adhesive paper. is not durable, and if they rain get’s it, all will be screw up, but at least is changeable, and cheap to print too. Was the best i could do, to also align it to the keypads (that by the way, are a bit twisted). All that was done in terms of the body and the top cover are not the best solutions, but at least they work and the result was acceptable.

Conclusion





So, finishing it, we glued some elastic sheets so it could be funded in the arm, and is ready to go !. It got a bit bigger that i tough in the beginning (in terms of thickness and width) but i think it ended up acceptable. A lot of thing could be improved in the case/body if i would have better materials and time, to improve the look and usability, but my current phone is dying and i need to switch it asap. Still, is very light, and i don’t mind to carry thing with me all time (even, i still think is pretty cool). The battery is hanging ok, lasts the same as the phone. And the good thing, is that the pairing happens in less than 5 seconds with a device that has paired before, so it awesome to turn it on and as soon i look at the smart watch screen, the keyboard is already paired (and if it took a bit longer, is fault of the smart watch really, and not of the keyboard). The pressing feel good enough to be used, the right keyboard is a bit more clumsy, and probably with a semi-rigid case would be a lot better. In the long term, i will surely do a second version of it, wil a lot of this improvements i described before :)



That’s everything for now kid’s !, i hope you liked it and let’s keep building amazing stuff :D