aspose file tools*
The moose likes Android and the fly likes Controlling a serial device from an Android app using USB connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Controlling a serial device from an Android app using USB connection" Watch "Controlling a serial device from an Android app using USB connection" New topic
Author

Controlling a serial device from an Android app using USB connection

Jorge Suarez
Greenhorn

Joined: Feb 03, 2011
Posts: 3
Hello!

Actually I'm not an Adroid developer myself, but I just got this crazy project in my mind that would motivate me to become one: I want to communicate in a serial way to an electronic device (designed by myself) from an android app, in order to issue commands to it.

My main goal here is to keep it cheap, so my first thougt is to connect the device via the USB port of an Android phone, but I understand Android has some limitations about using this port from the app level.

Can anyone give an advice about it?
Any experiences?
If it's not possible at all, what other mechanism would you advice?
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
Interesting idea.

There are some devices that seem to work as USB host devices (namely tablets); maybe you can access them in the way needed for this. But it is probably easier to use Bluetooth. When connecting via Bluetooth you (can) create a serial connection, too.

Then there are some experimental / esoteric ways of communication via the headphone jack. Just send the right "sounds" that are interpreted by your device. I think I saw some IR adapter for the headphone jack to use an iPhone as TV remote.
Jorge Suarez
Greenhorn

Joined: Feb 03, 2011
Posts: 3
I am trying to avoid wireless connections like bluetooth to save some costs. But it seems like the best option so far.

One more question: If I want to plug via USB, is it totaly required that my device acts as a USB host?
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
One of the devices has to be host. I don't know if there are phones out there that provide this; I don't think so. So you would have to design your device to be a host. Still the Android device has to interact correctly. I am not sure if you can access the USB like you would do with a simple serial connection. Even with desktop Java this is tedious. I guess how the Android device acts as USB slave (e.g. mass storage device, modem) is more of a basic level, i.e. part of the firmware. But maybe there is someone around who has deeper experience with this.

But Bluetooth is just made for this. Costs about 10$ if your own device already is USB capable. That is for home brewed devices. If you want to built them in the thousands this may be to expensive, but then you would certainly use another hardware design with a communication chip that includes Bluetooth.

The one annoying thing with Bluetooth is that you have to watch for two batteries as you can't power the connected device like you could with USB.
Pratik Goswami
Ranch Hand

Joined: Mar 02, 2009
Posts: 136

Hi all,

There are several possibilities and better scope to develop such devices, which can interface directly with device.
Several magnetic stripe readers are available for Android & iOS

1. IDTech
2. Square

I have personally worked on UniMag & iMag (made for iOS) and they have introduced same for Android.

Thanks & Regards
Pratik Goswami


iOS * Android Developer
Jorge Suarez
Greenhorn

Joined: Feb 03, 2011
Posts: 3
Thanks a lot for your input. I guess now that bluetooth is the best way to go.

It actually opened my mind to a richer set of communication features I can implement on my homebrew device, and not just pure one-way command sending.

Best Regards!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Controlling a serial device from an Android app using USB connection