Go Down

Topic: Using android mobile to control arduino (Read 95 times) previous topic - next topic

kerimil

there is no need to change baud rate in the app as it automaticly uses the baud rate used by the bluetooth module

the module I got is set to 19200 by default and I was too lazy to change it... so check what's the default baud rate of your module and change arduino code accordingly

pitusso

Hi,
you can use also the cheap HC-05 / HC-06 / HC-07 bt module (about 5 usd on ebay  :smiley-mr-green:).

More info about this kind of module:
http://forum.arduino.cc/index.php?topic=104903.msg786726#msg786726
(ok, it's in italian language :) but there are a lot of pictures and code and i promise: i'll translate it in english  :smiley-roll-sweat:).

kerimil

UPDATE - I made a new app and a new video to show that you can use the phone as a GSM shield
enjoy

https://www.youtube.com/watch?v=_L_JyCndeKI

more details here -> http://www.instructables.com/id/Android-phone-used-as-a-GSM-shield-for-arduino/

cyclegadget


Nice upgrade to your previous work! I tried to get you file as a zip but, could not figure out how. I have the pieces and will try to make them work later.


Thanks for sharing your discovery!
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

kerimil

ohh sorry
For some unknown reason the link I provided on instructables to the source file showed contents of the ZIP archive itself. I've just fixed it

try this link -> https://drive.google.com/folderview?id=0B_PfPoEotOF8N2JwT3RSX011SjQ&usp=sharing

cyclegadget

Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

Jimdare

Hi Kerimil,

I'm trying to expand on your app that sends temperature data to android via bluetooth, by adding two more sensor values.  On the arduino side I send the values as so:

Code: [Select]

Serial.print(SoilTemp);
Serial.print(",");
Serial.print(AirTemp);
Serial.print(",");
Serial.print(Humidity);
Serial.print(",");
Serial.println();



Assume:

SoilTemp = 15.00
AirTemp = 22.00
Humidity = 63.00


I intend this to send the following via the serial output:

15.00,22.00,63.00,

I then receive this with the blocks below:
 


The problem is; when I run my app, it comes up with the error telling me that the list index object (2) is too big for the list.  I understand that this means the list hasn't been split properly.  Do you have any tips as to how to get this working?

Thanks very much for your time.

Kind Regards,
Jimdare

kerimil

jimdare
It took me a while to figure it out...
You get this error because of select list item block. It crashes when there isn't item #2. Apparently something gets through serial but it isn't what you expect it to be and list index #2 doesn't exist.

How I fixed it ? Just put all your select list index number X inside an if block - and set condition to (list length = number of items you should get in the list)

Jimdare

Thanks Kerimil, but this doesn't seem to fix it.  I have investigated further, and it seems like the list only ever consists of one item.  I wonder why mitAI is not splitting the string properly?  Perhaps I will try using a different delimeter. 

kerimil

hmm... I am just guessing here but have you tried setting the condition Bluetooth client bytes available to receive to number of bytes you expect to get through serial (probably including delimeter byte)??

MechArd

Hi, I have followed your tutorial. I have connected  android phone to my Bluetooth device (HC-06) and the TX light flashes on the Arduino when i press the led on button on my app. Although the led does not flash. Is there any way to check what byte the arduino is receiving?

kerimil

You're 100% sure that TX light is flashing ?? since you're sending stuff to the arduino board shouldn't the RX LED flash ?? I am away from my board ATM so I can't check whether RX or TX flashes when it receives but I think it should be RX not TX

Is the bluetooth module TX pin connected to RX pin on the arduino board ?? it should be. If it isn't correct that


If you want to check exactly what is being sent from the module to the board then use software serial to create another UART port on other pins and create a sketch that retrieves whatever is sent through that serial and passes it to hardware serial (and thought USB connection to the computer where it can be seen using a serial monitor)
The reason why you need to use software serial is because you can't have anything connected to hardware uart pins and use serial through USB connection.

Jimdare

Success!! I finally made the bloody thing work! Turns out it didn't like the first byte of the string I was sending, so I added an 'X' in front.  This made the string look like this:

X15.00,22.00,63.00,

The split by ',' block worked fine after this.  I still have issues with the length of the list, but I will just add an 'if list = 3' condition. 

Thanks kerimil.

Code: [Select]


Serial.print("X");
Serial.print(temperature);
Serial.print(",");
Serial.print(temp);
Serial.print(",");
Serial.print(humi);
Serial.print(",");
Serial.println();
delay (2000);

kerimil

Glad I could help even if I didn't  :smiley-slim:

Anyway here is my newest project that also interfaces arduino and android devices - nothing fancy really it just a wireless ignitor

http://www.youtube.com/watch?v=jFRN8juM_yU

more details here -> http://www.instructables.com/id/Wireless-cell-phone-igniter/

MechArd

I change the RX and TX connections and nothing flashes now. I have attached the Arduino code and the android app code.


Go Up