Android communication with Spinneret
Bean
Posts: 8,129
I'm teaching myself android programming. And I'll let you know, it's not easy.
My initial goal is to write a program to read the accelerometer and transmit the data to the spinneret. And later to the Parallax WiFi module (hint hint).
I'm wondering if anyone has any other ideas for simple (easy) android apps ?
Bean
My initial goal is to write a program to read the accelerometer and transmit the data to the spinneret. And later to the Parallax WiFi module (hint hint).
I'm wondering if anyone has any other ideas for simple (easy) android apps ?
Bean
Comments
If you like to use my application, I will have the code for the system posted here in the forums by the middle of next week and will be happy to work with you if you use my application.
That sounds cool, but it's quite a bit beyond my skills at the moment.
Right now I'm pretty much taking working code I find and tweaking it.
P.S. If anyone wants to get started in android programming cheap, I got the Archos 28 for about $80. There is no camera or SD, but I can use if for development without having to root it or anything.
Bean
This is my first android app, so it may not even work. But it works on my archos 28 tablet. The zip file contains a .apk file.
You will need to have android 2.2 or higher.
PLEASE let me know if you try this. And let me know if it works or not.
You should get a screen showing the accelerometer readings X, Y and Z. It will send this data to my spinneret (so you will need to have internet access) my spinneret is connected to my PC to log the data. I'll leave my spinneret running for the rest of today.
Thanks
Bean
-Tor
I stopped and restarted the application. It still says 'IO Exception'.
It also runs only in landscape mode, presumably that's intentional.
Stopping it now.
-Tor
Thanks for trying it. It did log your data at my computer (Yahoo!!!).
What happened was the spinneret was still connected, I guess the screen-saver stopped the program, but not the same way as if you exit it. I'll have to look at how to fix that.
My next step it allow you to enter your own IP address of your own spinneret.
Thanks again. I have reset the spinneret if you want to try it again.
P.S. Yes I made it stay in landscape because there would be a delay as it changed between landscape and portrait modes.
Bean
I gave it a go it worked well with my G2. I was trying to get (x=0 y=0 and z=100) couldn't get z to 100 you need very steady hands. Works very well It said it was connected the whole time it was on.
Ron
I'm modifying it so that it shows the values, then has an input line and button to allow you to transmit the values to a spinneret.
Once I'm sure it works well I'll release it for everyone to use.
It will be REALLY useful when the Parallax WiFi comes out. Hint...Hint...
I also modified the spinneret code so it drop the connection if there is no activity for 10 seconds.
Bean
What does "root it" mean? See the root directory or command line access?
Here you go.
Ron
The zip file includes the android 2.2 program that reads the accelerometer and lets you send the data to any Spinneret that is setup to receive Telnet (Port 23) data.
It also includes a "Telnet to Serial" program for the Spinneret (be sure to change the IP address, Gateway, etc).
You can try to send data to my spinneret by specifying "pebasic.com" as the domain.
Let me know if you try it.
Bean
Any chance of seeing your Android code?
Don
Could you try to send it again. I didn't have PST running.
I'll really have to clean up the code before I'd show it to anyone. It's really a mess because I don't know what I'm doing.
Bean
What are you using to program the android in? is there a program you recommend?
Java development kit (JDK)
Android Software Development Kit (Android SDK)
Eclipse
Bean
Here is the code, it is probably not "proper" by android standards. In fact if anyone is familiar with android programming, I'd love to hear what I've done incorrectly.
Bean
Please DON'T send data to pebasic.com.
Bean
Looks pretty cool for what you have done with the phone app. The free tools that you found gives me the idea to start programming my own Android phone app for my monitoring system. Do you have the links for the free tools that you are using?
I pasted in some of my notes that may help you. I will add more later)
General Info - Android Programming:
http://developer.android.com
You can setup either MS Windows, Linux or Mac to developed for Android. I have it setup on Linux and MS Windows 7.0. If you don't already have these applications (1 to 4) installed start at number 1, they are in sequence . It includes the required (for the Eclipse IDE) Java Runtime Environment (JRE) required to run the Eclipse IDE.
=====================================================================================
1. Java JDK(software developers Kit). Install this first and confirm that it's working
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Tips:
MS Windows (tested on Win 7.0, make the required changes for other versions) Go to Start "All Programs" , "Accessories", "Command Prompt" . At the command prompt type: javac -version . If the JDK is installed and working correctly it should report the current version.
Debian- derived Linux: Use the terminal program. If you have the wrong version try this command : sudo update-alternatives --config java
Mac: Use the terminal program
=====================================================================================
2. Eclipse IDE. Written in Java and requires on the JRE to operate. For Android It's used to write java code, test, debug etc.
http://www.eclipse.org/downloads/
Tips: Linux: Copy Eclipse to your home folder manually, do not use a package manager to install it or you may end up with a much older version.
=====================================================================================
3. Android SDK(software development kit)
http://developer.android.com/sdk/index.html
Tips: Add the folders tools and platform-tools to your path
Linux: Extract and Install the Android SKD to your home folder. Add the folders tools and platform-tools to the path environment variable. Use .profile command from a term program (I use Ubuntu)
Mac: Extract and Install the Android SKD to your home folder. Add the folders tools and platform-tools to the path environment variable. Use .profile command from a term program (I use Ubuntu)
=====================================================================================
4. ADT plug-in
Choose classic or Java developer package(EE is what I use, you could use standard)
Great work Terry! I'm looking forward into delving into this as well.
OBC