12 Sep 2012, 22:34
Generic-user-small

Adrian Park (2 posts)

Hi,

Firstly, I bought the book with the hope that it would help me get an Arduino with BT module talking to an Android app built with Processing. It has succeeded where many other tutorials and approaches have failed! The rest of the Ketai library and book look fascinating and I look forward to digging into it further. So thanks and congrats on a great book.

But, I have a problem I hope you might be able to help with. I have everything set up and I am successfully sending data from the Arduino via Serial.write(). In the Processing/Android app, onBluetoothDataEvent() fires and I receive data. But, the data received only corresponds when I send a value between 0-127 from Arduino. In addition, if I send values in rapid succession, I seem to see multiple values in the byte array whereas, if I force a delay (currently 500ms) each packet of data sent triggers a distinct onBluetoothDataEvent().

So, I observe the significance of the number 127: I think its somehow related to the fact that data is being sent as distinct bytes? But, I’ll be honest, I am quickly stepping way beyond my realms of understanding as I try and understand what is going on “under the hood” here! Is there a better (more intuitive) way for me to send and receive the data from the Arduino? Can you give me some pointers or point me in the direction of what I need to know in order to better understand what is going on here (I would google if I only knew what I should be googling for)?

The Arduino setup is an Uno with BT module and ultimately what I’m trying to do is send the values of a potentiometer and two rotary encoders to the Android device.

Many thanks in advance.

15 Sep 2012, 00:14
Ds_2009_mpark_pragsmall

Daniel Sauter (46 posts)

Dear Adrian, will dive back into the Arduino world next week. I have the BT modem/module you are referring to, I think as well as the Uno. A model number/id for the BT module (Sparkfun/Arduino) would be helpful here. It’s a great and specific question. There are a couple of layers to debug, and I hope I can get to you with specifics next week. Thanks for your feedback, Daniel

17 Sep 2012, 14:29
Generic-user-small

Olaf Heddergott (11 posts)

Hi Adrian,

can you give a code sample for arduino and processing where you let communicate these apps? It would be very nice. I would use it to. But at the moment I think about the conversion of oscMessages on the arduino side.

I had hoped to find something like this in the book. so I bought it. But the bluetooth samples looks like to communicate between two mobile devices :-( Ok, at this time I have not read the complete book ;-)

I need simple bluetooth serial communcation like an serial device between mobile and arduino bt-shield. Can you give me a hint?

Thanks, Olaf

18 Sep 2012, 18:05
Generic-user-small

Adrian Park (2 posts)

Hi all,

I haven’t missed these messages but, with a Masters degree show opening in 2 days, I am using every last minute to complete my project. I will try to provide more details and code in the next few days if I can make some time, else next week.

22 Sep 2012, 11:36
Generic-user-small

Andreas Knaup (9 posts)

Does anyone have some example code for sending data from an android phone to arduino via bluetooth?

28 Sep 2012, 12:59
Generic-user-small

Olaf Heddergott (11 posts)

Hi Andreas,

I have written today a litte quick and dirty example, but in german. You can find it here: http://www.hegosoft.de/index.php?ebene1=10&ebene2=0&link=Arduino-Bluetooth_und_Android_Processing.html

I hope it helps.

Have all a nice weekend. Olaf

28 Sep 2012, 14:40
Generic-user-small

Andreas Knaup (9 posts)

Seems not to work with Android 2.2.2?

“Die Anwendung wurde unerwartet beendet, versuchen Sie es erneut.”

28 Sep 2012, 14:43
Generic-user-small

Andreas Knaup (9 posts)

Creating BluetoothArduino-debug-unaligned.apk and signing it with a debug key… Running zip align on final apk… Socket Type: SecureBEGIN mAcceptThreadThread[Thread-10,5,main] AcceptThreadSecure FATAL EXCEPTION: Animation Thread java.lang.NoSuchMethodError: ketai.ui.KetaiList.setAlpha at ketai.ui.KetaiList.init(KetaiList.java:82) at ketai.ui.KetaiList.(KetaiList.java:33) at processing.test.bluetootharduino.BluetoothArduino.draw(BluetoothArduino.java:71) at processing.core.PApplet.handleDraw(PApplet.java:1880) at processing.core.PGraphicsAndroid2D.requestDraw(PGraphicsAndroid2D.java:165) at processing.core.PApplet.run(PApplet.java:1748) at java.lang.Thread.run(Thread.java:1102)

28 Sep 2012, 18:38
Generic-user-small

Olaf Heddergott (11 posts)

I used processing 2.0b3. install ketai library 0.7 to the users directory. Also you must install in the Android SDK Manager the 2.3.3 package ( I have installed the 4.0 and 4.1 packages to). I don’t know where I can switch the android version that processing is used. On my PC processing is using version 2.3.3.

Open Processing, switch to android mode, and open a simple example from the list. If you can compile this, test a ketai sample. If this builds fine, open the ketai bluetoothcursors sample, copy my code and overwrite the sample. go to save as and give a uniqe name. Then go to run on device and build the debug version.

I hope this helps best reguards Olaf

29 Sep 2012, 07:18
Generic-user-small

Andreas Knaup (9 posts)

I will try this.

You can change the Android Version:

Go to -> Sketch-> Show Sketch folder

Once you have saved a file there shoud be a file called AndroidManifest.xml

change the “10” in

uses-sdk android:minSdkVersion=”10”

to your Android API Level. For Exampe “7” is 2.2.2 .

29 Sep 2012, 08:30
Generic-user-small

Andreas Knaup (9 posts)

I can compile the Bluetooth Cursor example and its running on my phone.

When i override the code with your code the app crashes on startup:

Running zip align on final apk… Found onBluetoothDataEvent method. Socket Type: SecureBEGIN mAcceptThreadThread[Thread-10,5,main] AcceptThreadSecure FATAL EXCEPTION: Animation Thread java.lang.NoSuchMethodError: ketai.ui.KetaiList.setAlpha at ketai.ui.KetaiList.init(KetaiList.java:82) at ketai.ui.KetaiList.(KetaiList.java:33) at processing.test.bluetoothcursors.BluetoothCursors.draw(BluetoothCursors.java:71) at processing.core.PApplet.handleDraw(PApplet.java:1880) at processing.core.PGraphicsAndroid2D.requestDraw(PGraphicsAndroid2D.java:165) at processing.core.PApplet.run(PApplet.java:1748) at java.lang.Thread.run(Thread.java:1102)

29 Sep 2012, 15:40
Generic-user-small

Olaf Heddergott (11 posts)

Hi Andreas,

I have tested on an other pc that had never be an android sdk or processing installed.

Download: processing-2.0b3-windows32.zip Android_SDK installer_r20.0.3-windows.exe Ketai_v7.zip

Unzip processing start Android SDK-Installer start Android SDK Manager Select: Android 2.3.3 SDK Platform and Google API, and Android SDK Platform Tools (on top) start Processing, close it unzip the ketai Lib to user dir documents, processing libraries start processing, select android mode, click YES I have installed Android SDK and select the installed path (c:\Program Files (x86)\Android\android-sdk)

paste my processing code in a NEW sketch save it, for example to “BT_DEMO” go to “Sketch” - “Run on device” now it builds the code in temporary folder.

OUTPUT:

No library found for android.content No library found for android.os Android SDK Tools Revision 20.0.3 Installed at C:\Program Files (x86)\Android\android-sdk Project Type: Application Project Target: Android 2.3.3 API level: 10 Library dependencies: No Libraries


API<=15: Adding annotations.jar to the classpath. Merging AndroidManifest files into one. Manifest merger disabled. Using project manifest only. No AIDL files to compile. No RenderScript files to compile. Generating resource IDs… Generating BuildConfig class. Converting compiled files and external libraries into C:\Users\test\AppData\Local\Temp\android6261524193790599850sketch\bin\classes.dex… Creating full resource package… Current build type is different than previous build: forced apkbuilder run. Creating BT_Demo-debug-unaligned.apk and signing it with a debug key… Running zip align on final apk… Shutting down any existing adb server…

Now go to C:\Users\test\AppData\Local\Temp\android6261524193790599850sketch\bin and ther are the debug apk. Thats it.

I have tested for many days, switching the used android version to 15. But no luck. It looks like the processing use always 2.3.3.

Hint: use the 32bit version on 64bit Windows to!!! I have tested on two machines with windows 7 64 bit.

It’s my mistake, overwrite the code from the bluetoothcursors example dont work. Maybe when you delete the “UI” it could be compile. But I always used Version 2.3.3.

good luck Olaf

29 Sep 2012, 16:40
Generic-user-small

Andreas Knaup (9 posts)

I have the 32 Bit Version. I have Android 2.2.2 on my phone, maybe thats the problem.

You can change the android version in the AndroidManifest.xml.

29 Sep 2012, 17:01
Generic-user-small

Olaf Heddergott (11 posts)

I have changed the version in Manifest file, but with no luck.

On my phones are android 4.0.4. and the created apps are running.

29 Sep 2012, 17:39
Generic-user-small

Andreas Knaup (9 posts)

So i have to buy a new phone :-(

16 Oct 2012, 11:44
Ds_2009_mpark_pragsmall

Daniel Sauter (46 posts)

Everyone,

here’s what https://vimeo.com/51517040

and how http://ketaiProject.com/adk/ADK_Arduino_BT.zip http://ketaiproject.com/adk/BT_Android_ADK.png

The Bluetooth portion is explained in the P2P chapter. Help us spread the word so we can keep doing what we do.

All Best, Daniel

01 Nov 2012, 09:05
Generic-user-small

Francois Baret (2 posts)

And, Daniel Sauter, what about some applications with the Arduino Mega ADK board! I mean without BT just having I/O going in and out from the board to the Android tablet, is it part of your future plans? Cheers!

08 Nov 2012, 17:33
Ds_2009_mpark_pragsmall

Daniel Sauter (46 posts)

Dear Francois,

Android ADK cannot be developed with the Processing IDE because the activity lifecycle methods are not (yet) available to use within Processing. Therefore the wireless Bluetooth route, wireless is more attractive for many folks.

Android ADK using Processing core must be done via Eclipset, which goes beyond the scope of this book and would be the subject of another.

There are no plans to include Arduino and Android ADK in the book. I’m thinking of writing an article about it next year ;), so stay tuned via @KetaiLibrary or @Daniel_Sauter.

Best, Daniel

22 Jan 2013, 13:02
Generic-user-small

prof buchi (1 post)

Hello everybody,

I tried the ADK_Arduino_BT project and it works fine when I press the buttons linked to the arduino and I see the change of state on my Android phone. But…there’s always a “but”, it doesn’t work in the other way : when I drag the mouse on the screen, nothing happens on the LEDs and no data seem to be send. I use a sparkfun bluesmirf gold as BT, an Archos G9 android tablet (android 4.0.4), ketai v8 Can you help me ? Thank you

29 Apr 2013, 15:28
Generic-user-small

Akash Sadashivapeth (1 post)

Hello,

I was having the same problem, here is how i sorted it out:

The code olaf posted crashed every time i tried to run it on my android, and the problem seemed to be dealing with permissions.

Hence to solve the issue i went over to the android tab in processing and sketch permissions, tick all the permissions dealing with bluetooth.

Hopefully the code should run smoothly for you all.

Thank you all for the help.

14 May 2013, 11:17
Generic-user-small

Olaf Heddergott (11 posts)

Hi,

I wrote on my page (in german) “…don’t forget to set the sketch permissions for internet and bluetooth…”

this works for me.

Olaf

  You must be logged in to comment