Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Android USB to Serial RS232 or Bluetooth

Status
Not open for further replies.
Hi MrAl, I found this thread from you link re our previous conversation. :)

Reading through it, I wondered if you could contact the maker of your BASIC interpreter, they might have a solution or a suggestion?

Other than that, if your tablet allows a USB keyboard that will likely be a HID interface, which can be done directly on a USB capable PIC, Microchip have app notes for doing HID emulation on their USB PICs.

Personally I think the easiest solution would be Dougy83's suggestion to buy one of the cheap USB->PS2 adapters (which are just HID emulators) and feed it with PS2 data which is very easy from any PIC. I have no idea what datarate you can get but it is very low effort and $ cost to try it and find out.

Or you can buy a $15 ttl->bluetooth module and trying sending some data?
 
Hi MrRB,


Yes it would probably work with a slightly more upper scale PIC (18F series i believe) directly to USB, but i would end up having to emulate the keyboard anyway unfortunately.
Yes the USB to PS2 is sounding better and better. Looks like it would be somewhat simple i'd just have to learn the protocol enough to get things going. I dont need much speed, say 100 baud or whatever the closest standard is to that if necessary. I think i can get that with a keyboard using the right key sequences.
I was afraid to buy a bluetooth adapter because i had read that only certain ones would work, but the ones suggested were not to be found on the web! That's the web for ya. And i didnt want to start piling up bluetooth adapters trying one here and one there. I tried one already from a friend and it didnt seem to do anything. One of the ones suggested on a web site was a "Transcend" bluetooth adapter and it is not to be found anywhere.
So you see where i am at with this now. I hit a few walls already so i was looking for those down and dirty solutions like modifying a keyboard :) Good point there is then i would have a keyboard for other entry requirements too. If i could find a real small keyboard that would actually be really nice. So far i've only found big ones, and i dont like the fold up keyboards.
Some phones have physical keyboards. They slide out from behind. Nice and small, that's what would be nice. Would have to have a USB interface.

Oh yeah, i started a thread on the RFO BASIC forums site. Thanks for the suggestion. No solutions yet but it's early yet and it's still a holiday.
 
Last edited:
Hi again,

MrRB makes a good point - the microcontroller can do all the USB stuff also. You can download a readymade hardware-only (USB interface emulated) ATMEGA8 firmware which allows 17 keys from https://www.obdev.at/products/vusb/hidkeys.html -- looks good to me. Just change main() to receive any RS232 from the UART and to send the appropriate keycode out the USB side.

Using the UART will lose a few of the available keys, but the remaining keys might be useful too -- or you could have an auxiliary PS/2 interface to allow you to connect an external keyboard if needed. This allows the ATMEGA circuit to function as a keyboard wedge as well.
 
Hi,

Yes that makes a lot of sense. Right now i am waiting for replies on the RFO Basic forum where hopefully someone has done this or something like this already. Im surprised to see so little on it on the web. As the PC grew years ago, people were wanting to do all sorts of stuff with it with the different interfaces. It's surprising that there still seems to be less interest when it comes to the Android platform. I have a feeling that's about to change though unless Windows Tablets are successful in dominating the market which for our sake i hope never happens.
 
Does yours have Bluetooth built in, and do you think you will need it soon or in the future?
It does have Bluetooth, but I've presently got no other Bluetooth gizmo to try it with and no immediate plans to get one. I see Samsung sell an adapter for my tablet to provide a USB host function, so I assume that without that I'm not able to use USB plug-ins such as a keyboard or USB/RS232 adapter. It also may explain why my tablet currently is recognised merely as a 'camera' by my PC via USB.
IIRC the lite/freebie versions of Basic available for the Windoze platform likewise don't have comms API capability, but I think the expensive version of MS Visual Basic does.
Even with Bluetooth, how would you access that with an external low-end PIC? Bluetooth-to-RS232 adapters are available but generally more expensive than USB-to-RS232 ones. I wonder if you could hack a Bluetooth headset? That looks like the cheapest Bluetooth-enabled gadget.
 
Hi alec,

well i didnt notice that the Bluetooth to RS232 adapters were expensive, so if that's the case then that's not a great idea either except then it would work with ALL of my test equipment which would be nice :)

I guess this is going to be an ongoing quest. As time goes on more and more people will want to do this. Also, i found this site:
www.phidgets.com
which seems to make interfaces for Android. Slight drawback there though is that it requires the use of their API which is for use with programming environments like Eclipse. Didnt really want to have to use that.
 
Hi MrRB,

Oh yes, looks interesting. I hate ordering from those kinds of suppliers though as sometimes they take a month to deliver. Looks like an interesting solution though. I hope i can do something like that eventually.

The other news is that i received a somewhat smaller keyboard yesterday just in case i decide to go with a simple uC to Keyboard solution. Simplest would be to interface to two keys, the 1 and the 0 keys, and send binary to the program that way. That would require two small transistors (SMD maybe) or something like that. To get faster transfer i could go with more key interfaces, but there is probably a matrix in can interface to inside the keyboard so maybe i can get all the keys with fewer transistors.
Nice little keyboard though for 10 USD, not as small as i would like but smaller than most. Quite cool looking too.
 

Attachments

  • Blue_USB_Keyboard-02b.jpg
    Blue_USB_Keyboard-02b.jpg
    174 KB · Views: 197
Last edited:
I'm curious to see the inside of the keyboard. For cost saving they probably used a key matrix directly to microcontroller pins, and the micro would have USB capability built in and provide the HID interface itself, directly to USB cable.

If it's a time thing, your local PC store will very likely have those PS2->USB converter plugs in stock, for a few bucks each. PS2 is very easy to interface!
 
Hi again,


alec:
Oh yes that looks very cool. That would work pretty well i think. What isnt good however is that they probably supply an API which is accessible via the full Android development package which means it would not be usable in BASIC. So i'd have to do a full dev on this.

MrRB:
Im sure you are right about it being a single chip with i/o pins being used to scan the keyboard matrix. That's what makes me think interfacing to the keyboard itself wouldnt be that hard. A few i/o pins with an analog switch :)
When i get around to taking this apart i'll post some pics.
Yeah we have a computer shop about 2 miles from here so i could check that out too.
 
I reinforced your request on the RFO forum and had a reply that Basic! support for USB is now on the to-do list. Hopefully we'll get a language extension before too long.
I've finally managed to install a WinXP USB driver that works; my PC and Android tablet can now chat to each other via USB.
 
Hi alec,

Oh that's great. I havent tried that with mine yet as i was using wireless to send files back and forth. From what i understand so far (which isnt much yet) that cable helps when developing apps for the Android, for debugging. I might look into this a little more.
 
I'm finding it convenient to use the USB connection for app development in RFO-Basic. Keeps the tablet battery charged. Write app code in Notepad (or similar) then use Explorer's 'copy to folder' to update the .bas file on the tablet (even, surprisingly, when the tablet is in sleep mode).
 
Hi alec,

Oh ok, that's probably the most sane way to do it :)

I also recently tried a USB hub + keyboard + mouse. It worked pretty well, but the first keyboard i tried (Logitech) did not work with the hub. It worked with the Android device, but not with the hub. But the second keyboard worked ok so i could type right into the RFO editor with the regular keyboard which worked out nicely. Funny though, the keyboard is about 2 times larger than the Tablet so it was strange typing into this little screen with a big keyboard :)
Oh yeah, im not sure if you found this yet but, with a regular keyboard into the Android with the RFO editor, the editing commands work similar to Windows. Like paste, copy, select, etc. I didnt get that using the virtual Android keyboard. That helps to copy and paste text as i used that feature a lot in Windows. In fact i am lost without that really so it helps a lot to have that available. I also found that double clicking on a word selects that word and gives me two flying cursors, which i can then drag to select more text. Helps a lot.

I'd be interested to hear if you get to use Bluetooth with the RFO Basic at any point. I'd like to see how it handles input and output.
 
I also recently tried a USB hub + keyboard + mouse.
I've yet to try that. Need to get a USB on-the-go host adapter (=hub?).
 
It occurs to me that other ways to get data into the tablet might be via its sensors (mic, light sensor, magnetic field sensor etc), depending which sensors you have available and the update speed of the sensors (documentation seems thin on the ground re update speed).
For example, RFO-Basic supports recording audio to a file (albeit a .3gp format, whatever that is), and byte-reading from a file, so perhaps send a modulated tone into the mic?
 
Hi alec,

I considered the sensors, but unfortunately the g sensor is too hard to interface as this would require physically vibrating the whole tablet, barring opening up the case and rigging the chip itself unless it is part of another chip.

I considered audio injection, via the microphone. The mic is built into the tablet too and unfortunately this one has no audio INPUT jack, just an audio OUT jack for headphones. So i'd have to use a small speaker and mount it right under the mic (which would work) but then i'd have to hear the noise of the data transmission which would sound like a telephone modem :)

You're right though, if i had other sensors i could use one, or even an audio input jack. Too bad for me :)
 
My tab doesn't have an audio input jack either. Does your tablet have a type 2 (magnetic field) or type 3 (orientation) sensor?
 
Hi alec,

Mine has 3 axis 6 direction g force sensor (acceleration) and type 3 orientation sensor. No GPS either. Sensor resolutions are not super great but do ok i guess. The orientation sensor lets me know which way the Tablet is being held, either portrait view or landscape view.
I made a little accelerometer using BASIC just for the fun of it :) It's done in 'console' mode but i suppose we could make a nice one in graphics mode. I did it mostly before i knew how to use the graphics commands in BASIC, and mostly just to learn how to access the sensors.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top