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.

MrAl

Well-Known Member
Most Helpful Member
Hello there,


As you probably know the Android operating system used in phones and tablets is becoming more and more popular. Some features are a little new yet though so it's sometimes unclear what the best way to do certain things is.

What i'd like to know is if anyone has successfully used the USB OTG (USB On The Go) connection on some tablets to convert it to a serial port using perhaps a serial to USB converter 'cable'.

Some tablets dont come with Bluetooth either, and some people that have tablets with Bluetooth would prefer to use an external Bluetooth adapter so that they can get more range with their tablet. Either way, it would be nice to be able to do this too.

Apparently it may be a driver issue or just somehow getting the tablet to recognize the external device.

So has anyone done this yet?
 
Hi,

Thanks for the link. That's interesting too, but all the projects require the Android device to already be Bluetooth capable.
What i need is something that allows the Android device to become Bluetooth capable (ie adds Bluetooth to a non Bluetooth Android device), and then go from there. Or else something that allows the Android device to communicate via RS232 from the micro USB port.
The first thought was to get a Bluetooth plug in for the USB port, but it would have to have software for the Android or else be capable of 'discovery' through the Ice Cream Sandwich operating system (supposedly doesnt need a driver that way). Im rather new to this operating system so im still in the dark with a lot of stuff.

What i do with my PC is i use my four channel volt meter to monitor certain processes such as charging of batteries of different types and voltages, but that means having the volt meter tied down to the PC computer plugged into the RS232 comm port. I'd like to be able to do the same with the Android device which is totally portable because it can run on batteries, and it's light weight so can be carried almost anywhere along with the lightweight four channel volt meter. The volt meter puts out RS232 but i can always modify that to put out other types of communication signals, but it would be simplest if it stayed RS232 or maybe SPI or something like that.
I dont want to have to buy a new Tablet just to get this functionality (Bluetooth) obviously, so im looking for a way to add Bluetooth or some other way to communicate with the Android device. If i cant find any other way that isnt too complex, im going to be stuck communicating via part of the touch screen with an electrode pad that simulates rapid touches, but that's limited to about 10Hz communication speed which is exceptionally SLOW even compared to the slowest common comm schemes. That boils down to sending 10 bits per second, which means it would take a min of about 5 seconds to send all four channels of information. Nasty.
 
I'll keep looking, meanwhile I found this: http://letsmakerobots.com/node/21901

I have an app that allows an Android Phone to talk to Windows and it tethers the phone to your Laptop so it uses the phone internet connection. That app is PDANET. You have be able to put the USB interface on the phone into Development mode and the put it back when you decide to access the Android's pics etc.

I've heard other systems have used the headphone jack of say the iPhone (iOS not Android) to connect to peripherals.

I think an SD card has an SPI or I2C interface associated with it. Any possibility of using that? I'm out on a limb.
 
Last edited:
You could have a look at the FTDI chip Android bridge ICs that allow interfacing to GPIO, UART, PWM, I2C, SPI. There's also some dev modules to play with immediately. See https://www.ftdichip.com/Android.htm

They are USB host ICs that connect to the Android device in 'Accessory Mode' (which can also be done using a PC). I guess you'd have to write an app to read the data from the serial port/voltmeters
 
I use one of these cables to program my electro mechanical calendar clock via it's serial port with my nexus 7 and the "Slick USB" app. The clock has a Max232 chip inside.

**broken link removed**
Nexus 7 setting 12" Electromechanical Calendar Clock by Brett Oliver, on Flickr

Full details here under the Calendar Clock Slave link on the main page.

The PIC code was written for me by a very kind member of this forum.

Hope this helps.

Edit not sure if all Android devices have the USB connector enabled. I think Samsung S2 has not but Samsung S3 has.
 
Last edited:
Could you use the tablet's wifi function? I can't get my Samsung Galaxy Tab 2 to talk to my PC via usb (alleged drivers wouldn't install properly under WinXP-SP3), but file transfer via wifi is straightforward.
 
Last edited:
Hello again,


I think the headphone on this device is output only, and it has a mic but it's internal so i'd have to take the thing apart to access the mic unless i went with an audio interface which would then make noise.

Im not sure if i can interface the SD card terminals but then i'd have to run without the SD card anyway which im not sure would be good as i usually use that too.

I looked at the FTDI chips and not sure how hard that would be to implement, and i realized that i have another requirement at the moment and that is to be able to use a BASIC interpreter with a simple program written in BASIC that would read the input however it comes in. Right now it does Bluetooth with no problem (if the device had a BT connection that is) so i thought that would be simplest. I'd even have to figure out how to do the RS232 now that i think about it, because this BASIC interpreter does not have ability to interface to any Comm ports. I didnt realize that at first.

I checked out "Slick USB" and that looks like a USB to serial device. Now im not sure i can use RS232 it might have to be Bluetooth. They also get 100 bucks for that thing.

Using the WiFi function is a great idea, except my external circuit would need a WiFi connection too. The Tablet has one, but the circuit would be a low end microcontroller like PIC12F or PIC16F.
I dont have any problem transferring files from Android to PC via WiFi, but that's not my intent here. My intent is as follows:

1. Some sort of interface from an electronic circuit to Android tablet, the electronic circuit is low end PIC based.
2. The interface should be readable from the BASIC interpreter program (it works with Bluetooth), but i dont think it can work directly with RS232 now.
3. I want to use a interpreter program language so i can change the program on the fly without having to go back to the PC to build a new .apk file. The BASIC interpreter i have is not too bad, but i'd consider using another type of interpreter language that works with the Android OS (Ice Cream Sandwich).
4. The idea is to be able to read the ports of various test equipment. The port of the particular test piece is not that important as i can always convert to the required Android type like Bluetooth. They typically send out data at 9600 baud or slower, but the speed isnt that important as long as it is not too excruciatingly slow (like 10bps is too slow but 100bps is probably ok).

Thanks for the ideas and suggestions.
 
Last edited:
Hi,

That second link looks pretty interesting. I'll have to look at that in more detail.

Im not sure a USB to serial adapter would work yet. I'll have to try one, but the language i am using right now does not support Comm ports ( RS232) so i'd have to try one of those other ones i guess.

Ethernet or WiFi to serial might have the same problem. I'd have to use one of the other languages and hope they work right seeing as how this stuff is all so new yet.

I think what would be nice is to get an external Bluetooth dongle to work that way i can use the language im using presently.

I happened to think of another idea too, which isnt that elegant but may be sufficient (although i would still prefer Bluetooth). That is to connect a standard keyboard to the Android device (which supports using an external USB keyboard) and use my microcontroller hardward/software to interface with the keyboard electronics. What this means is taking apart a standard (cheapie) USB keyboard and wiring in pins of the uC to transistors or analog switches and having the transistors or switches close the contact to one or more standard keys. For example, if i use the '1' key and the '0' key then the program would detect an ascii '1' and use it as a logical '1', and the '0' key would be detected as ascii '0' and be used as a logical '0'. With enough switches or transistors i could do the all the number keys 0 to 9, which would provide the ability to send three digits numbers (which is what i need, well maybe 4 digits) pretty fast. 50 words per minute is about 250 characters per minute which is close to 4 characters per second, so it would still be a little slow but might be sufficient. More elaborate switching (keys A to F also) would allow sending two digit Hex which would mean i could send two samples per second, not too bad for just a volt meter. But since i want to do four channels it still means 2 seconds to send all four channels, but interlaced it would appear quite fluid i think, like a regular volt meter.
Not the best idea in the world and not especially easy to implement either, but im getting desperate :)

If i have to buy another Tablet computer that has Bluetooth built in it's going to cost more than this Tablet which i got on sale believe it or not for about $60 USD. One with BT built in would be more than twice that, more like three times that, so any other solution has to be cheaper than about $120 to $180 USD.

And hey thanks for looking all that stuff up. I am sure there are other people out there trying to do something similar (at least with the Bluetooth) and i cant imagine hobbyists not wanting to do this eventually too as the prices of Tablets come down. We can make an entire test bench with one Tablet and some external devices, and have it all be portable too meaning we can take it anywhere to make measurements. With the right software, do some complex analysis right there on the spot. The future of test equipment :)
 
Last edited:
If the keyboard route would work, then you could make it a bit neater by using a USB-PS/2 converter (**broken link removed**) for $1 and send the keys using synchronous serial through that device. It would mean you don't need to put 8/16 switches on a bulky keyboard PCB and you can send any key code.
 
Hi,

Nice idea, but doesnt the keyboard do some sort of handshaking with the host? When i plug the keyboard in the Android knows it was plugged in, detecting it somehow. I'd have to emulate that so i'd have to find out what handshaking it does.
 
Hi again,


Looks very interesting, thanks for posting. I'll have to think about how deep i want to get into this, but this looks like the simplest solution yet, or at least simple and *possible* where some of the other methods might not work too well.

The protocol doesnt look too difficult to implement, almost as simple as RS232. And since the program can repeatedly read the keyboard i dont see how this could not work. Slight problem is i'd have to implement my own software keyboard as the built in software keyboard does not come up if there is a physical keyboard attached, but i dont mind that too much.

Another idea was to use just the keyboard chip rather than the whole keyboard.
 
Last edited:
this BASIC interpreter does not have ability to interface to any Comm ports.
Would that be RFO-Basic?
 
Hi alec,

YES! Ha ha. It's pretty nice i guess. But if you have better suggestions i'll check them out.

BTW, Happy New Year.
 
I've only recently bought my tablet and installed RFO-Basic. Haven't had a chance to write an app with it yet. No better suggestion :(. As I'm not a C/Java programmer I'll have to be content with RFO I guess. Happy New Year to you, too.
 
Hi again,

Oh ok, well you'll probably find you pick it up pretty fast as there is a somewhat decent pdf manual and quite a few example programs that come with the download.

I was quite surprised by what it (BASIC) can do, full graphics, touch screen interface, file i/o, everything i need, except for a comm interface. Since Android developed so long after DOS and Windows i guess they didnt think anyone would ever want to use an old interface like RS232, but there is still a lot of test equipment that uses it. I have four meters that use it myself. Some of them are way too expensive to just through away just because they are RS232.
I find the BASIC allows simple creation of buttons and other graphics objects unlike the original MSDOS where there were only console graphics. You can draw just about anything you like using the full screen capability, and detect touches anywhere on the screen or just in a certain rectangular area. Not too bad for a simple language like BASIC.
I've created an app or two with that huge Java/Android/Eclipse download, but that's not really what i need anyway as i cant turn to a PC every time i want to modify the program, so i need a program language that is resident in Android, so that's what led me to that BASIC. I found another BASIC but they charge for it, and i could not find the download page anyway, just a site where they talk about how great it is :)
I've now seen another Tablet that has Bluetooth built in that is of reasonable cost, but i've also read that people who already have that still want to install an external Bluetooth adapter somehow someway so that they can get a longer range wireless connection. Apparently the built in Bluetooth is limited to a shorter distance than the adapters. Ive seen some adapters 20 meters which is pretty good for my purposes. Max i should ever need would be like 50 feet as long as it is a good connection.

I tried a Bluetooth adapter a friend had for their phone, but unfortunately im not even sure what to do after i plug it into the Tablet. The Tablet does respond by flashing the screen, but i dont see anything new in the settings screens after that and i think i am supposed to after plug in. I think that is when the Android recognizes the device. Still mostly in the dark with this thing though :)

So it's nice to hear that you have a Tablet too, and with RFO Basic also, so maybe we can compare notes about the language and about the Tablets. Does yours have Bluetooth built in, and do you think you will need it soon or in the future?
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top