Android Bluetooth joystick

Firstly thanks Kas this is a great app/sketch.

I too couldnt get it to work but after some playing around i got this to work with these settings:

// Arduino RX to TX BlueTooth module // Arduino TX to RX BlueTooth module // make sure your BT board is set @9600 bps //Set Serial Monitor rate to 9600 bps

Thanks Kas for the protocol information

@Maudey Thanks for the feedback I edited reply #182 based on your comments Please post an App screenshot, together with your screen size and resolution This will help me optimizing App display layout

What BT brand are you using ?? Most boards default to 9600bps, which is a bit slow I strongly suggest to boost your board @57600bps

@tolisn63 Did you try the on board mini router ?? I hardwired connection between IP camera and router and still have to observe any noticiable lag 8)

Hi Kas

The mini router did not come in yet. I'm waiting to see how it goes.

Hi kas

Thank's for your help! Now it works fine for me :) I really appreciate this app/sketch :D

Hi I have a small problem. I didnt get receive any of datafields.

Hi kas Thanks for your help! Now it works fine for me :) I really appreciate this app/sketch :D

Thanks hulkpeppe for this positive feedback

@n3kx

Hi I have a small problem. I didn't get receive any of datafields.

I bit more information would definitely help ...

I use your basic sketch and your app, but under datafields in android is only xxxx

I use your basic sketch and your app, but under datafields in android is only xxxx

Not a lot of additional info's ;)

Carefully review those 9 questions and answer YES/NO

[u]Android side/u: 1) go to Option/About and confirm that installed version is V4.0 (or higher) 2) can you move the joystick and display position at bottom left 3) are you connected ("connected to: XXX", green text)

[u]Arduino side:[/u] 4) are you using AndroTest V1.3.ino (or higher) 5) are Bluetooth TX connected to D2 and RX connected to D3 6) is your Bluetooth card already configured @57600 bps (most are 9600bps by default) 7) is your Bluetooth card LED solid red or green (blinking = not connected) 8 ) is your Serial monitor configured @57600 bps

[u]Finally:[/u] 9) your serial monitor should anycase display: AndroTest V1.3 - @kas2014 demo for V4.X (6 button version) does it ??

  • any additional information ??

Hi Kas, I think your “Joystick bt commander” is brilliant – just what I want for some projects I am looking at. However, I am having intermittent problems connecting from Android to Arduino via HC-05 module and very rarely get data from Arduino to Android. Is there a correct boot up sequence between Arduino and Anroid or doesn’t it matter? When I changed the baud rate in AT commands I used AT+UART=57600,0,0 – is that correct? Also I think I may have a mismatch of Wiring diagram/ino code/Android app. Can you email me details of where I can get the latest drawings/codes etc. Again – brilliant application Many thanks Bob

YES I have 4.0 version YES I see changing position on bottom left YES I am conncted

YES I using ArduinoTest V1.3.ino YES I have Connected Bluetooth in right way YES I have solid led YES Is my serial monitor configured @57200 bps

YES My serial monitor display that information

Hi Bob1943

I think your “Joystick bt commander” is brilliant

Thanks 8)

I am having intermittent problems connecting from Android to Arduino via HC-05 module and very rarely get data from Arduino to Android

Can you be more specific, I would expect the App to always work or always fail... :roll_eyes: :roll_eyes:

Is there a correct boot up sequence between Arduino and Anroid or doesn’t it matter?

No, doesn't matter

When I changed the baud rate in AT commands I used AT+UART=57600,0,0 – is that correct?

Yes, make sure you have entered the Command mode I just prepared a sketch for my new HC-05 board. Will display - device name - firmware version - serial parameters

// Iteaduino BT board configurator - BASIC version

// Utility will display actual Baud rate

// TX BT board pin to Arduino D2
// RX BT board pin to Arduino D3
// 5V BT board pin to Arduino 5V
// GND BT board pin to Arduino GND

// set Serial Monitor @57600bps

#include "SoftwareSerial.h"

SoftwareSerial mySerial(2, 3);          // BlueTooth module TX RX
char response[30];                      // responses from module
int rv = 0;                             // return value

void setup()  {
  Serial.begin(57600);
  mySerial.begin(38400);                  //  config mode bps
  mySerial.setTimeout(500); 
  delay(300);
  Serial.print("\n\nIteaduino BT board configurator ");
  Serial.print("\nSearching ...");        
  mySerial.write("at\r\n");               // BT card bug ???
  delay(20);
  mySerial.readBytes(response, 15);
  mySerial.write("at\r\n");               // "AT" will respond with "OK" if it is working
  delay(20);
  response[0] = 0;
  rv = mySerial.readBytes(response, 15);
  response[rv] = 0;
  if (strncmp(response, "OK", 2)==0)    Serial.println("\n\nBluetooth Module found");
  else  {
    Serial.println("\nERROR: Bluetooth Module not responding!");
    Serial.println("Make sure there are no active bluetooth connection and try again");
    while(1);
  }
  
  delay(100);
  mySerial.write("at+name?\r\n");               // Check device name
  while(mySerial.available() == 0);
  rv = mySerial.readBytes(response, 30);
  response[rv] = 0;
  if (strncmp(response, "+NAME:", 6)==0)  {
    Serial.print("Name: ");
    Serial.println(response);
  }  else  {  
    Serial.println("Error checking name");
    while(1);
  }

  delay(100);
  mySerial.write("at+version?\r\n");           // Check firmware version
  while(mySerial.available() == 0);
  response[0] = 0;
  rv = mySerial.readBytes(response, 30);
  response[rv] = 0;
  Serial.print("Version: ");
  Serial.println(response);

  delay(100);
  mySerial.write("at+uart?\r\n");           // Check serial parameters
  while(mySerial.available() == 0);
  response[0] = 0;
  rv = mySerial.readBytes(response, 30);
  response[rv] = 0;
  Serial.print("Serial: ");
  Serial.println(response);
}

void loop() { }

Please confirm your BT board baud rate

Also I think I may have a mismatch of Wiring diagram/ino code/Android app. Can you email me details of where I can get the latest drawings/codes etc.

Bluetooth TX connected to D2 and RX connected to D3 Joystick bluetooth Commander V4.0 is here AndroTest V1.3.ino is there

Please answer the 9 questions as per above

@n3kx

Base on your responses, problem is the BT card to Arduino board serial connection Is your BT card HC-05 or HC-06 ?? let me have a link to your specific model You may reverse TX and RX cables just to make sure, this will not harm anything Did you actuallly check you BT card baud rate ?? they usually default to 9600bps Have succesfully used this card for other projects ??

Can you see the scrolling Joystick values in the Serial Monitor ??

My model is HC-05 and it work @9600bps. I use your older version and it works, even on version 4.0 it works Arduino receive joystick data as button data no problem. But datafields doesnt change there are always showing XXXX.

I have this type of Bluetooth: http://www.ebay.com/itm/Wireless-Serial-6-Pin-Bluetooth-RF-Transceiver-Module-HC-05-RS232-Master-Slave-D-/400709013564?pt=LH_DefaultDomain_2&hash=item5d4c1e503c

Hi, thanks for your rapid response. Your assistance in helping is excellent. Hope I have answered your questions so I can get a response from Arduino UNO back to Android

I used the AT Command setup at this URL http://arduinofy.blogspot.co.uk/2013/10/tutorial-programming-hc-05-at-mode-with.html

when completed AT+UART? Returned: 57600,0,0

Your sketch headed: // Iteaduino BT board configurator - BASIC version Returned the following error message:

Iteaduino BT board configurator Searching ... ERROR: Bluetooth Module not responding! Make sure there are no active bluetooth connection and try again I couldn’t find anything paired with the HC-05 The red BT LED flashed on/off about every half second

Your sketch headed: AndroTest V1.3 - @kas2014\ndemo for V4.X (6 button version) Only Connections: .Arduino pin#2 to TX BlueTooth module . Arduino pin#3 to RX BlueTooth module ..Arduino 3.3v to 3.3 BlueTooth module ..Arduino GND to GND NOTE: Key and 5v not connected

Paired and connected with Android (v4.0.4) OK. Still only xxx showing bottom left. Interesting point is that button B5 stays locked the same as other buttons until pressed again to release. (I did notice at one time it did act like a push button – maybe that was when data got fed back). Just a thought I think the connection problems may be down to me as that problem appears to have gone away. My only problem now (apart from error in BT board configurator mentioned above) is the failure to get a signal from Arduino to Adoid.

Answers to 9 question in reply #197 1..Version v4.0.4 2. Yes 3. Yes 4. Yes 5. Yes 6. Yes 7. NO – Initially Red LED flashes continuously but when connected it flashes twice every couple of seconds (not solid red as in question) 8. Yes 9. Yes

Observations: I am not experienced with serial coms., but understand there are parity and stop bits. When I changed the BT module to 57600 baud I sent AT+UART=57600,0,0 and the AT command AT+UART? returned: 57600,0,0 Is that OK?

BT Red LED flashes rapldly before pairing. Then when paired changes to on/off flash every 2 seconds then but when connected it flashes twice every couple of seconds.

UNO TX LED flashes about every 2 seconds and whenever a button is pressed. When the joystick is moved it constantly flickers, then after about 10 seconds of continuous joystick movement the TX LED locks on. Opening the serial monitor window seems to return it back to normal. UNO RX LED only ever flashes when uploading code

Hope some of this makes sense – thanks again for your help Bob

@ n3kx

even on version 4.0 it works Arduino receive joystick data as button data no problem. But datafields doesnt change there are always showing XXXX

Interesting Android to Arduino communication is OK Arduino to Android communication is not wired correctly

I have this type of Bluetooth: ...

The link is broken, please double check and let me know

Which Arduino board do you use ?? Can you post a photo of you setup ?? Did you modify the actual demo sketch ??

My model is HC-05 and it work @9600bps

Although this is not the cause of your problem, 9600bps is too slow for the data stream and generates transmission errors

I strongly urge everybody to set speed @57600bps

Depending on your specific model, I can post a tool for this adjustment

@ n3kx

I just downgraded my HC-05 board to 9600bps and could reproduce your situation ]:) ]:) ]:)

Please modify demo sketch as follow: in void loop() line #3 change "delay(5);" to "delay(2);" in void loop() last line remove "delay(5);"

Did you make any change in Option for advanced users ?? Let me know your current settings for - Refresh interval - Time out count

Today I bought HC-06 and it work @9600 pbs. So can you post code how to change it to whatever it need . I try change delay but same results.

Today I bought HC-06 and it work @9600 pbs. So can you post code how to change it to whatever it need . I try change delay but same results.

Glad it works with HC-06 Please scroll up to reply #15 and download the HC-06 config tool

I own HC-05 and HC-06 cards and they both work flawlessly @57600bps

Did you make any change in "Option for advanced users" ?? Let me know your current settings for - Refresh interval - Time out count

Please reply

@Bob1943

Still only xxx showing bottom left

Are you referring to the joystick position field at bottom left of android device screen ?? :astonished: This should indicate joystick position at App start up, even before any connection It should read (-100,-100) for South West position and (100,100) for North East position

Interesting point is that button B5 stays locked the same as other buttons until pressed again to release. (I did notice at one time it did act like a push button – maybe that was when data got fed back).

This is normal behavior when not connected

My only problem now (apart from error in BT board configurator mentioned above) is the failure to get a signal from Arduino to Android.

  • You can follow joystick position and buttons state on you Serial Monitor
  • Datafields don't update, B5 is not in "push" mode Correct ??

Answers to 9 question in reply #197 1..Version v4.0.4

I was talking about App version, should be V4.0 OK ??

the AT command AT+UART? returned: 57600,0,0 Is that OK?

Yes According to documentation Param2 = stop bit: 0->1 bit 1->2 bits Param3 = parity bit: 0->None 1->Odd parity 2->Even parity Arduino serial is 8N1 (1 stop bit, no parity)

UNO TX LED flashes about every 2 seconds and whenever a button is pressed. When the joystick is moved it constantly flickers,

This reflects the data flowing from Arduino to Serial Monitor

then after about 10 seconds of continuous joystick movement the TX LED locks on. Opening the serial monitor window seems to return it back to normal.

Strange :relaxed: :relaxed:

Did you change any setting in Advanced options ?? Try "reset Option" to restore initial parameters EDIT: also set Refresh interval @100ms, Timeout count @every 10 intervals

Finally let me have a link to your specific BT board