OK i know there are much threads about this topic. But most of em are like 2 years old. Because of that and the fact of new developments from googles side like ADK and stuff, im starting this question again.
All i want to know is, whether it is possible to establish a USB connection to an USB-Device now or not. Like to open a stream to receive the data from a sensor. Think about a device which can be the USB-Host and sends data permanently. All i wanna do is to grab that data.
Im using a smartphone with Android 2.3.6.
Are there any APIs now for this version? Or i have to go a way which includes a modification for the linux kernel or the usage of arduino or a similar interface? Because i would like to avoid that.
Most usb stuff starts coming into play with 3.0 > but I believe its back ported to 2.3 (not sure on it) but basically yes it is possible now. If you can get your device to be a usb host device you shouldn't have a problem, I use an acer iconia a500, running ics, I have a picaxe connected to an ftdi chip feeding me sensor data, once you have the basics sorted out its easy, if you go through my questions and find the usb related ones you should get a lot of information, ill link you if you want to the questions?
In short its entirely possible with the newer versions of Android, however back porting that functionality might cost you the same in time as it would in money to buy a new tablet or phone.
Heres everything I've talked about with usb on here... this stuff should save you a few hours I think https://stackoverflow.com/search?q=user:1174869+[usb]
Related
I'm stuck at home with a rather bad webcam. I was considering upgrading, but then it struck me: phones these days have really good cameras embedded in them. So why not use it as a webcam?
However, as I was researching this further I was really disappointed with the available apps for this. As far as I was able to find, we have Android apps that work roughly as follows:
Present phone camera as a network attached camera. Then you can use local software to use that feed as a webcam. See e.g., IP Webcam. This may be sufficient, but it's a complicated setup, and network latency makes this far from ideal.
The Android app sends the camera feed to an custom host application that in turn creates a virtual web camera. See e.g., DroidCam. This mostly solves the latency problem, but it is still rather complicated, and requiring us to install a specific third party application is troublesome in regard to user privacy. Especially since the applications are closed source.
So, I took the engineering approach and tried to see if it was even possible to improve the situation. As far as I was able to find, Android supports being used as a custom USB accessory. And looking over the USB video class documentation, it strikes me that it should be possible to create an Android app that presents the phone as a generic UVC webcam, such that we do not have to resort to tricks such as the ones above.
Ideally, I would have liked Android to add another USB device option ("Use USB connection as webcam") in addition to debug mode, file-transfer, etc. This seems quite unlikely to happen in the short term however.
So, my question is this: Does an application that does the above already exist? My searching thus far haven't yielded any results, but I might be missing something as googling for this turned out a bit harder than I expected.
Alternatively, am I wrong in my assumption above, such that there is some fundamental issue why an Android application cannot be made to work in that way?
There does not seem to be any complete app yet as of 2020-10, but the parts are mostly there:
https://github.com/tejado/android-usb-gadget has code to switch the Android device into gadget mode (but no UVC yet)
https://git.ideasonboard.org/uvc-gadget.git feeds v4l2 into the uvc gadget output
Sources:
http://www.davidhunt.ie/raspberry-pi-zero-with-pi-camera-as-usb-webcam/
https://www.raspberrypi.org/forums/viewtopic.php?t=148361
https://www.reddit.com/r/androiddev/comments/iabc2o/can_i_use_my_android_as_wired_camera_ie_as_a/g1nrijl/
It appears Google has started to take notice on this issue and are currently working on a "DeviceAsWebcam" service, which is exactly the solution to this problem, as seen in the Android review below:
https://android-review.googlesource.com/c/platform/system/sepolicy/+/2410788
Naturally though, this is a Android 14 feature, so it will like take a while before this is usable on a lot of devices. Hopefully, someone is able to backport this feature to older versions of Android.
If android / the version of Android that comes on your target phone provides / permits use of the USB gadget driver, then libguvc,
https://developer.ridgerun.com/wiki/index.php?title=USB_Video_Class_Gadget_Library_-_libguvc
can be used to "make an application appear as a USB webcam".
Potentially relevant to get you started would be https://stackoverflow.com/search?q=Android+USB+gadget (other SO references to the use of the USB gadget driver on Android).
How do you effectively develop, debug, and test an android app that is based on Bluetooth.
I have been googling and searing stack overflow for the answer to this question and I am not getting a clear answer.
I understand that the emulators do not support Bluetooth. I also know of various guides explaining the functions, classes, and such, and I know people have mentioned that setting up a Bluetooth emulator is possible with Virtualbox. I even came across some old projects like BT-Sim that seemed like a way to create fake BT signals (though if my android emulator doesn't support BT, it doesn't help too much)
But no solid guide on how to get this going. It just likes a few scattered puzzle peaces that need to be stitched together. It makes me wonder how app developers reliably make BT enabled apps?
Are there any guides that dissect how to do this process? I imagine the steps to accomplish are:
Create a custom emulator on Virtualbox that can simulate Bluetooth?
Get the AVD Manager to talk to this emulator so my compiled Android code will work with it
Run a Bluetooth simulator to send BT signals over a port in your computer
(I don't really know how to do either of those 3 though!)
My overall goal is as follows:
Create an app that will collect data from a Bluetooth transmitter
But first, create a simulator on my computer that can talk to my android emulator as if it were the real thing
I'll be honest, I do find it odd that the Google folks don't allow Bluetooth emulation on their AVD. I understand not allowing real telephone calls, but I don't see how Bluetooth can be abused like that.
Anyway, any help in setting up Bluetooth would be greatly appreciated and hopefully help many others out there!
NOTE: I am using the standard Eclipse + Android SDK setup with AVD to do my Android development. Planning to use API 10. However, if I need to use a different set up, I am fine. As long as it comes with a step by step guide! That would be very nice.
Old question, but it's still unanswered. If you have a physical device, that seems easiest way to go. If, like me, you don't have a device it's still possible to develop with bluetooth and android.
Download an android x86 iso, load it into virtualbox with bridged network setting and install it.
Plug in your bluetooth dongle and select the device from the 'usb' menu, alternatively you can set a device filter in the vm's settings page.
Now just use adb and connect to it, you can find the ip by going to console (alt+f1) and typing netcfg or ifconfig eth0. You may also need to type adbd on the android console - I do, but I don't see many people mention it so seems it's not always needed.
It still works with eclipse, and is much faster than the emulator. Even when I'm not doing bluetooth dev I use the vm rather than the emulator.
I am looking for a way of displaying an analog video stream on an android phone. On a pc/mac/etc you can achieve this using a cheap usb analog-digital converter such as a grabby: http://www.terratec.net/en/products/Grabby_82248.html, and then view on VLC, for example.
Would such a thing work (in theory) on android if the proper drivers were available? (ie. are there any hardware issues which make this impossible?)
Does anyone know if such a device with android drivers is available?
Ultimately I want to make an app which interfaces with the grabby (or similar device) and allows the user to view video on the android and capture and send short clips.
First of all the Android device needs to support USB Host. This limits your userbase significantly.
Then there is the problem with power. Some USB Host devices will be incompatible simply because an Android phone will not be able to push enough power through to port to get it running properly.
I'm not sure about the drivers, but I'm 99% sure it won't work "out of the box".
You should certainly take a look at THIS project. It is pretty similar to what you are trying to do. Maybe you should consider getting in touch with that person.
EDIT:
Based on what it took to get that DVB-T dongle running in the project i mentioned above the chances of creating an app that everyone will be able to simply download and use are EXTREMELY slim. Getting that dongle running required using a modified kernel and special scripts. Of course I could be wrong. You can continue the research yourself or wait for someone with more experience than me to reply.
I'm starting a project where I'm going to try to write a program for Android that will control and/or send/receive input to/from an Arduino gadget. Like, make an LED light blink, as the simplest example. I can either get a Bluetooth shield for the Arduino board and go the Bluetooth route, as per the example Androino! Control an Arduino from your Android device using a cheap Bluetooth module.
Or I can buy a USB host shield for the Arduino board and have the phone talk to the Arduino device via a USB connection, as per the example Adventures in Android ADK Development: Hardware.
Which implementation option is easier and more foolproof both from hardware setup (soldering? compatibility issues?) and programming perspectives (additional Python scripting required? 'listening' on Android for a Bluetooth device vs. a USB device and sending data back and forth?) I've been doing Android development for a couple of months, but I have NO experience with Arduino.
I don't mean this to be a lazy question - I'm able to do the research, but I'm inexperienced and am trying to choose my implementation right away so I can order the right hardware stuff in time for a deadline. I have to make sure I choose an implementation I can actually DO.
EDIT: Might it be easier still to use an ethernet shield on the Arduino board and have the Arduino gadget talk to the Android phone via TCP/IP? I don't know why this didn't occur to me from the beginning. But there seems to be far less in term of tutorials on this kind of implementation, for reasons I'm unsure of.
I am currently working on a project that interfaces an Arduino and an Android phone via bluetooth. And from my experience so far all I can say is STAY AWAY!
All the articles online about cheap bluetooth modules working perfectly are highly misleading to say the least. It might be easy and perfect if you buy an $80 shield, but not if you're on a budget. I bought a $30 shield and it only seems to work on one of the seven Android devices I have tried to use. Furthermore, it seems completely unresponsive to the standard bluetooth connection methodology and requires a host of workaround/hackish method calls that are all highly unsafe and unstable.
On the other hand a USB connection is far more reliable, better supported and of course has the inherent advantage of speed and since it is well supported does not suffer from all the pitfalls bluetooth connectivity does. It is just as easy to setup from a hardware perspective (no work required if you get a decent shield), reasonably priced compared to bluetooth shields and in my experience generally easier to code.
If you are on a budget and can do with a hardwired connection I highly recommend USB over bluetooth.
I don't know the details of either. But I would say if the phone is going to stay with the board then use USB. For lower latency and in general, I find a hardwired connection to be better for all applications.
I have no experience in Arduino and some decent experience in Android and I decided to get the usb connection to work from the phone to arduino to light up the led.
I used a Nexus One and an Arduino Mega ADK and I got the usb connection working in around 5 hours of tinkering and I was absolutely excited to get the led to light up when I clicked a button. But then I decided to go to the next level because bluetooth sounded way too cool to pass up.
Anyways around 30 hours later I FINALLY got it working and I can say it was COMPLETELY worth it. There was a TON I needed to learn, but once I got it working I can say it was not all in vain.
I bought the Bluetooth Itead V2.2 shield ($25 for me) then connected it to my arduino and used my Nexus One with Amarino to send a signal to my chip and turn off and on the led.
http://iteadstudio.com/store/index.php?main_page=product_info&products_id=468
From my experience it was definitely difficult, but the learning curve is what makes these projects so fun. So I would say GO FOR IT!
Good luck in your future works!
I am looking for a solution to do USB host programming on Android using the new USB features.
Does anyone have experience with this already? Does it really work? Are there any particular limitations? What would be the best place to start?
I checked http://developer.android.com/guide/topics/usb/host.html, but ideally need a working example.
I would regret the investment in a new Android phone/tablet just to do the development and then find out that certain USB functions do not work.
What I am particularly interested in is if there is experience doing serial communication over a FTDI chip using Android USB host programming.
In particular I would like to know if anybody has used the library from slickdevlabs to do this - is it worth it or can one just pick up any example code (like bluetooth) and go from there?
Many thanks
I know it's been coincidentally a year exactly since you asked this question, but I am currently using the slickdev library to talk to FTDI devices. There is an issue however.
Somewhere along the line, I lose a few bytes of data, as well as picking up in my data the header bytes. So I am losing like 3 bytes of data, but gaining 4 bytes of header data. The header data is 0x0162, basically saying it's sending 62 bytes of data.
I'm still hoping to use the slickdev library, but unless I can get around that issue, I'm going to have to write something from scratch, under the pretense that writing from scratch will allow me the control I need in order to change settings not allowed control over with slick.