Posts Tagged ‘XBMC’

Arduino + Ethernet Shield

Arduino + Ethernet Shield

Some context

So, as I was here today with some residual traces of flu and a cold, I watched a certain (undisclosed) quantity of episodes of TBBT (yeah, yeah, I know, just a couple years later than all the others), and all of a sudden I thought of a very nerdy way of solving a little problem I had here (an idea somewhat similar to this one, at least from a certain point of view).

The problem was the following: I have an Asus Eeebox (one of the first models) that is being used with XBMC as a HTPC, of course without a mouse or a keyboard; I have a little infrared remote for navigating through the menus and stuff. Now, the problem comes when one wants to write something, for example in the search box of the Youtube plugin: neither the smartphone remote controller for XBMC nor the Web page supported those interfaces (at least in pre-11 version of the application), so the only way (besides connecting a keyboard, which I don’t want to use because I don’t want to leave it there hanging around) was to navigate between each key of a virtual keyboard that pops up when going into any search field, using navigation keys or a little surface of the remote control that simulates a mouse. Neither a good solution, would you agree.

A few months back I played with the possibility of changing the firmware of the USB part of the Arduino Uno models, and as I had an Ethernet Shield lying there, along with the Uno already with the resistor in place for placing it in DFU mode, and I had the idea that I could use the Arduino as a remote keyboard… ready for the journey?

The journey

So, the first thing has been to search if someone already modified the LUFA project for allowing an Arduino board to be recognized as a generic keyboard… and (of course) it turned out someone already did it. I downloaded the code from that Web page, installed it and tried the examples: they just work™.

Next move: I put together some code for allowing the Arduino to act as a Web server, showing just a single page with a little form with a text line; each string insterted there is then sent back from the browser to the server, which gets the parameter and sends it through the serial port, using the protocol developed for the keyboard firmware linked above. With this, if the Arduino is connected to a local network and to a computer (through USB), it receives characters from the Web and sends them to the computer as they were typed into a (USB) keyboard. The only difficulty here was that the current binary version of the Arduino IDE seems not to work at all with DHCP, I don’t know for what reason (maybe some voodoo compatibility with my avr compiler), but the git version works just fine (for me, at least).

And, dulcis in fundo: using the Web page was fine, but of course I want to send commands from my Android smartphone, so I wrote some other code packed in a tiny Android application showing basically the same form and directly sending POST requests to the Web server. The entire application does not perform very accurate controls over inputs, it’s a little project in the end and it is supposedly used in a local network (your house’s), where no one should want to crash your Arduino…

Final thoughts

Next week I will get a little enclosure for the Arduino pictured at the beginning of this post; the sketch does not support all possible keybaord symbols, just letters, numbers and a couple of useful punctuation marks, because I think I will just use it for doing searches where I should not need strange things. I also want to add: screw the Eclipse update system, it never works.

As a side note, the Eeebox does not shut down the USB ports when shutted down, so the Arduino remains on and connected even if the computer is not running.

I also took the opportunity to put together some little projects I had on Github in one single repository instead of n repositories: it seems to make more sense.

Read Full Post »