Android android - Linking a mobile phone and Propeller.
heater
Posts: 3,370
Launching a new little project: Android android
The basic idea of "Android android" is that an Android based mobile phone is a wonderful thing for any red blooded hacker to tinker with. Software wise anyway, it's a bit lacking in hardware interfaces. It can provide GPS, a compass, an internet connection an accelerometer, a graphic output, audio in and out etc. Oh yeah and allow the Prop to make phone calls and send SMS.
The Propeller is a wonderful thing for interfacing compute power to the real world of gadgets, robots or just plain old LEDs and buttons.
This naturally leads to the idea of how to use them together.
Looks like at the moment the best bet is getting the Androids USB port to work in host mode and talking to the Prop through USB serial. It's not clear that that is possible with all Android phones, we shall see.
What do we need?
1) A means of getting the Android phone to use it's USB port in host mode.
I hope there are some USB gurus out there who can advise about USB On The Go and all that.
2) A means of programming the Prop from the Android phone.
This will require some Android app on the phone. A bit of a trick because Google has designed the whole OS with a view to all apps being written in Java. It is possible to run native code though probably wrapped up in a Java app using Java Native Interface. I'm not at all familiar with any of that yet.
3) A means of communicating with the Prop when it's running. Again an Android app will be required. Perhaps that could just be Java. This is very application specific but at least we have to demonstrate how to do it.
4) Of course some code on the Prop end to do whatever. Again application specific.
Starting with 1) I have some hopes this is a reasonable thing to do. Searching around for "Android", "USB", "host" etc one will find examples of guys who have achieved this with varois phones.
For example here for a Motorola Droid phone www.tombom.co.uk/blog/?p=124
Which leads to the attached schematic for convincing an Android phone to go to host mode on start up. Anyone know if that schematic is a good idea or not?
As usual with my project announcements this a bit premature. I don't even own an Android phone yet. I hope a Samsung Galaxy S is arriving for me on Monday. I will immediately set about trying to get it to generate blue smoke with a circuit as per the attachment.
I suspect very soon the world will be full of Android tablets and such. Leon here has such a thing. It would be nice to be able to get them hooked to the physical world.
By way of inspiration check out this phone robot www.instructables.com/id/Android-G1-Serial-To-Arduino/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Post Edited (heater) : 7/16/2010 4:17:33 PM GMT
The basic idea of "Android android" is that an Android based mobile phone is a wonderful thing for any red blooded hacker to tinker with. Software wise anyway, it's a bit lacking in hardware interfaces. It can provide GPS, a compass, an internet connection an accelerometer, a graphic output, audio in and out etc. Oh yeah and allow the Prop to make phone calls and send SMS.
The Propeller is a wonderful thing for interfacing compute power to the real world of gadgets, robots or just plain old LEDs and buttons.
This naturally leads to the idea of how to use them together.
Looks like at the moment the best bet is getting the Androids USB port to work in host mode and talking to the Prop through USB serial. It's not clear that that is possible with all Android phones, we shall see.
What do we need?
1) A means of getting the Android phone to use it's USB port in host mode.
I hope there are some USB gurus out there who can advise about USB On The Go and all that.
2) A means of programming the Prop from the Android phone.
This will require some Android app on the phone. A bit of a trick because Google has designed the whole OS with a view to all apps being written in Java. It is possible to run native code though probably wrapped up in a Java app using Java Native Interface. I'm not at all familiar with any of that yet.
3) A means of communicating with the Prop when it's running. Again an Android app will be required. Perhaps that could just be Java. This is very application specific but at least we have to demonstrate how to do it.
4) Of course some code on the Prop end to do whatever. Again application specific.
Starting with 1) I have some hopes this is a reasonable thing to do. Searching around for "Android", "USB", "host" etc one will find examples of guys who have achieved this with varois phones.
For example here for a Motorola Droid phone www.tombom.co.uk/blog/?p=124
Which leads to the attached schematic for convincing an Android phone to go to host mode on start up. Anyone know if that schematic is a good idea or not?
As usual with my project announcements this a bit premature. I don't even own an Android phone yet. I hope a Samsung Galaxy S is arriving for me on Monday. I will immediately set about trying to get it to generate blue smoke with a circuit as per the attachment.
I suspect very soon the world will be full of Android tablets and such. Leon here has such a thing. It would be nice to be able to get them hooked to the physical world.
By way of inspiration check out this phone robot www.instructables.com/id/Android-G1-Serial-To-Arduino/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Post Edited (heater) : 7/16/2010 4:17:33 PM GMT
Comments
2. Sometimes companies will sell an item at cost or cost +10% as a means to get people "in the door". Good idea to make the lowest cost Prop bluetooth module and sell it for a bare minimum price?
3. How do you write "apps" for this cellphone? Is this open source?
But I found this link to the Android SDK (Software Development Kit). Is this what is needed to write apps for·an Android·cell phone? (This seems to be free.)
http://developer.android.com/sdk/index.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon Heller
Amateur radio callsign: G1HSM
Post Edited (Leon) : 7/16/2010 4:26:18 PM GMT
Yes the phone has bluetooth. I guess most Android phones will have. And links from phone to micro-controller using bluetooth have been made like the one for the AVR based "HowDoIKnow" board in the link in my opening post.
I will probably give the bluetooth solution a try. After all we can make use of the phone application and know how from the HowDoIKnow guys who have done this already.
However a bluetooth modem module for the Prop is damn expensive. Like 65 dollars for this one from Sparkfun www.sparkfun.com/commerce/product_info.php?products_id=582
It seems a crazy lot of money when I just want to link to a 6 dollar micro and I know full well that 5 cents of twisted pair cable is all I really need.
I'm totally new to the Android platform as well. It is open source. It has Linux at it's core. The beauty of the Android idea is that unlike a iPhone every thing is totally open. You can put what ever apps you like on it, reflash the OS if you like. Totally screw it up to your hearts content. Plus there are many manufactures adopting it for their phones. Motorola, Samsung, HTC etc etc. Not just a single source like Apple.
Yep, you have found the right SDK. I have not even dared to download it yet. I know it will immediately suck away all my time. Sometimes the boss likes to see me[noparse]:)[/noparse]
P.S. Who invented this USB nonsense anyway? And why did they not think to allow using the USB cable as a normal asynchronous serial line so that we could all use the port.
"Universal". Hardly, perhaps if you have the OS that can handle it, and have the right drivers. Every micro-controller dev system I've seen has required it's own drivers be installed to work.
"Serial". Well OK.
"Bus". No. A "bus" in the old world implied the possibility of multiple nodes being attached. USB is only a point-to-point link.
But I digress.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cmapspublic3.ihmc.us:80/servlet/SBReadResourceServlet?rid=1181572927203_421963583_5511&partName=htmltext
Hello Rest Of The World
Hello Debris
Install a propeller and blow them away
Excellent!
I have been wanting an excuse to get an Android phone (+ tablet), this sounds like a great excuse to me...
off-topic: Initially I wanted an iPhone, but Apple's SDK restrictions are making me boycott iPhone/iTouch/iPad
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
Las - Large model assembler Largos - upcoming nano operating system
So you be learning some Java? JNI is just an interface to a C library.
In the case of Propeller JVM JNI is an interface to Spin functions.
BradC's USB toys thread is here:
http://forums.parallax.com/showthread.php?p=675656
The only trouble I ever had was going through a USB hub which didn't work.
Good luck with your 'Droid.
Cheers,
--Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM
Dell's launch of the Streak in the USA is imminent, I would think. With that you get both a phone (including 3G) and pocket-sized tablet (and Wi-Fi, GPS and a compass). 7" and 10" versions will be out in due course. It's nice to be first with something here in the UK, for a change. You don't have to put a rubber bumper round it, to prevent loss of signal, either.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon Heller
Amateur radio callsign: G1HSM
Nearly broke down and got a Nokia N900 a while back. Finding out that it is incorrectly wired internally to let the USB port be used in host mode I dropped the idea.
With rumours that host mode is possible on some Android phones, plus the fact that Android is very open and multi-sourced, plus the fact there are over 30000 apps for Android already many of them free, plus the fact there are apps to get you a command line shell on the phone, plus the fact that the Samsung Galaxy S is so God damn beautiful, I finally cracked.
If that phone turns out to be USB host mode resistant and I can't even connect a normal USB keyboard to the thing I'm going to be mightily ****** off.
You might want to hold off on phone selection until we have sorted this out a bit.
Never bothered to look at Steve Jobs' "MyPhone", if he wants it so locked down he may as well keep it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
There are all sorts of X10 switches and so forth with which you can control electrical things in your home.
So cell phone -> bluetooth -> Prop/Stamp -> X10
=Turn anything on/off in your home via the cell phone!
X10 stuff...
http://www.smarthome.com/_/X10_Compatible/_/23X/land.aspx
By a strange coincidence, I was over at dell.uk a couple of days ago looking at it. Looks like an excellent product.
heater,
Good idea. I'll hold of on the phone for now - I might pick up one of the dirt-cheap 7" ebay android tablets to play with before getting something like the streak for "real" use.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com
My products: Morpheus / Mem+ / PropCade / FlexMem / VMCOG / Propteus / Proteus / SerPlug
and 6.250MHz Crystals to run Propellers at 100MHz & 5.0" OEM TFT VGA LCD modules
Las - Large model assembler Largos - upcoming nano operating system
Round about 1996 I had a stint of trying to get to grips with Java seeing as it was new and shiny and might prove useful. Never did get the point of this JVM idea (But that's a debate for another potentially infinitely long thread elsewhere[noparse]:)[/noparse]). Up shot was I never did use Java, being an embedded systems kind of chap, and the best thing I learned about it was JNI. Thank God, there's a way out of here[noparse]:)[/noparse] Now I have to remind myself how to do all of that again.
BradC's USB toys may well have a part in all this. For downloading code from phone to Prop we will need the normal USB/serial adapter.
Leon: Those soon to come big tablets from Dell look great. It might be the first time Dell has ever created something that I find desirable. Amazing what you can do when you get away from MicroSoft[noparse]:)[/noparse]
Bill190: X10 interface? I believe someone here has done that. And a great application idea. First we have to get the phone-prop link of the chain working.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
I'm very pleased with the Dell laptop I bought a few months ago. The price was very good and it works very well. I even like the Win7 x64 OS that came with it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon Heller
Amateur radio callsign: G1HSM
If you can write C++, Java is a cakewalk. My own observations whether you agree with them or not is up to you are that relatively speaking C++ is weird and limiting (virtual methods for class polymorphism, no way to "statically" specify strings within in class, ... others). In some ways, Java is more like C than C++ [noparse]:)[/noparse] I do see the power in multiple inheritance which is not in Java, but Java Interface and abstract classes handle that nicely. Of course C++ beats the heck out of Java for speed and as you point out can be used in tiny embedded systems fairly easy.
Cheers,
--Steve
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Pages: Propeller JVM
There are also two objects in the OBEX for propeller:
http://obex.parallax.com/objects/465/
http://obex.parallax.com/objects/461/
I was also looking at a web browser solution for my iPhone by this company:
http://www.iobridge.com/
Jim
Unless your root your 'droid (which isn't for the faint of heart and has a high probability of bricking your device if you screw it up, which is easy to do) you are stuck with Java. You *can* drop into C using JNI calls but you only want to do that when absolutely necessary. The reason is that JNI calls are somewhere in the neighborhood of 100x more expensive than direct java calls. You definitely don't want to be making a JNI call inside a tight loop.
You also don't want to use any libraries that are not part of the NDK (Native Development Kit). The only libraries that I'm certain they support in NDK is OpenGL and libm. Any other library calls you make will be at your own risk since if that library doesn't exist on another phone then your app will break for those phones. It's okay if you just want to tinker, you can pull your libs off your phone and link against those, but that is also suspect since any OTA (over the air) update that occurs could overwrite those libraries with different entry points and signatures. Your app will probably crash, and very spectacularly at that.
If you use Java you face none of the problems above, only when dropping to native do you have those issues. But then again, what's the fun of writing Java when I can roll up my sleeves and write some C (and presumably assembler if I were so inclined).
http://developer.android.com/sdk/installing.html
...that I first need to install the Java JDK which is here...
http://java.sun.com/javase/downloads/index.jsp
So I installed the JDK, then tried to install the Android SDK, but it failed with an internet connection, but mentioned going to settings and forcing a download...
So I exited out of that screen, then saw "Settings" on the left, then clicked on that, then checked the http box. Then clicked on the button on the lower right (forget what button that was), then that downloaded what it needed to, then I was able to install from there...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My website www.quigleyelectronics.com/
Are you using Eclipse? There are some nice addons that Eclipse provides that make developing for android much easier. If you want to do native development (i.e. C) then your environment gets a little more complex, but it's just a matter of making Eclipse know about the external dependency. Otherwise everything else is packaged up nice and you don't have to worry about creating debug keys or setting up your folder and classpath structure correctly. Eclipse takes care of it all for you.
Anyway there are several different downloads here...
http://www.eclipse.org/downloads
One is...
Eclipse IDE for Java EE Developers, 206 MB
And another is...
Pulsar for Mobile Developers, 122 MB
The first looks like it has everything, but the second looks like it would be best for cell phones.
Which should I get? (More choices on the link above.)
Or would I download one and then the other as well?
·
grab the Eclipse IDE for Java Developers at http://www.eclipse.org/downloads/
and you should be good to go
Don't get the EE version, just the standard JDK version is what you want.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Leon Heller
Amateur radio callsign: G1HSM
No problem. Getting the android stuff installed isn't too intuitive.
Just go to Help -> Install New Software...
Enter the url for the sdk (too lazy to look it up but can be found very quickly), click Add
It should come up with two things to install. Choose both.
Once it's installed you can use the manager by going to Window -> Android SDK and AVD Manager
Inside the manager you can download the api's you want and update your SDK
# tools/android update sdk
After a very long time it seems to have downloaded everything and is now showing me the "SDK and AVD Manager"
Hmm... Interesting...
# tools/android
Gets me a mobile phone up in a window.
# cd tools/
# ./adb shell
Gets me a command line shell to said phone.
Looks like I need to install that Eclipse nightmare...
# apt-get install eclipse
# eclipse
Wow. I have a new IDE up. I gave up on Eclipse some years back as it took forever to figure out how to install/run it and then when it was up it was mind numbingly slow, what with it being Java on my slow old PC. Let's hope this goes more easily now.
No idea what I should do next and I'm out today so progress will be delayed.
soshimo: It's great to have someone on board who knows something about mobile phone / Android development. This is going to be a whole new world for me. I'll be replying to your P.M. later today.
Looks like Java will be the the thing, at least initially, after all we only want to talk to a serial port, how hard can it be?
soshimo: Any idea about using Android USB port as a USB host and driving a USB serial adapter through it?
Adam Wiesler:
Fitting a Prop out with bluetooth or WIFI or Ethernet or such and running a web server on it which can control the Prop over the net may well be a way to go for some applications.
But it does not cut it for me. Any one of those networking modules for a Prop is thousands of times more expensive that the 5 cent piece of twisted pair of wire that can connect a computer (The phone) and a device (The Prop). It's also thousands of times more complicated than just pumping data/commands up and down a serial cable.
Also, this Prop to Phone link has to work reliably and speedily, I want to see a Boe Bot or Scribbler where the brains of the thing are in the phone and the Propeller is the nervous system.
Soon theses phones will be so cheap (and older models become disposable) you can just build the phone into your gadget permanently.
Also the phone IS the link to the internet for the Prop and it's hardware gadgets why should I need another one just to communicate a few inches or feet?
I want my USB link.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Post Edited (heater) : 7/17/2010 8:30:23 AM GMT
Java SDK
Android SDK
Eclipse IDE
...and around 1.7 gigabytes of space for these and many hours of downloading later...
Next·I found the following·"Hello World" starter page. I am doing everything on that and it is working as it should. The only thing was screens were hidden and I needed to exit out of stuff in Eclipse to see what they say should be there. And I minimize things, they disappear, and I can't get them·to reappear! (Learning curve at beginning...)
Anyway here is the hello world starter page...
http://developer.android.com/resources/tutorials/hello-world.html
I think that's it for me until my Android phone arrives.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
Great job guys! I can't tell you how full the android boards are of people who can't get passed this point. Now that the administration junk is over you can concentrate on being creative (well, after learning the API and getting your head around the way applications talk internally and to each other). Just remember, almost everything in Java is an interface so you will be dealing with interfaces quite a bit. Java is also big on IoC and DI (inversion of control and dependency injection) so expect lots of functions where you pass in objects (specified as interfaces most likely) that expose dependencies. Rather than having those dependencies aggregated within the object they are supplied through constructors, fields, and parameters - which is where the dependency injection comes from. If you haven't already you might want to brush up on your Martin Fowler, et. all. Good luck and happy droiding! [noparse]:)[/noparse]
What on earth is this guy talking about?
I hope there is a way to explain all that that a humble assembler, C, C++, ADA, ALGOL, PL/M, Python, PHP, Lua, BASIC, Coral 66, Pascal, Spin, ... programmer can understand.
Is there such a thing a "Java For Programmers" book? [noparse]:)[/noparse]
Preferably an on line tutorial.
I was simultaneously trying to get into the Arduino mind set where it turns out that "sketches" are actually what normal people would call "programs" or "applications" and that "wiring" is actually C++ !
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
hackaday.com/2010/07/12/android-development-101-%E2%80%93-a-tutorial-series/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX - The home of the Hybrid Development System and PropGFX Lite