Pages: [1] 2   Go Down
Author Topic: Cheap way to connect an Arduino to a Android Smartphone via bluetooth  (Read 3039 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have a budget of about 60-70ish dollars. i want to make a project where the Arduino takes the info from the sensors connected into the arduino, but i want to send that information to an android smartphone. The project also needs to be small, and i dont need that many pins in the arduino. what do you think is the best arduino and best way to do this?
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2945
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used a JY-MCU Bluetooth slave module to get my robot to work with an Android tablet. However you can also use Wifi, to do the same. Look at the Bluetooth chat program.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

will it work with the arduino pro mini? or arduino lilypads? is there any setup required or is it plug and play type thing?
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2945
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It should just be plug and play, mine was, aside from the pairing.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Toledo, OH
Offline Offline
Sr. Member
****
Karma: 19
Posts: 457
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i have a budget of about 60-70ish dollars. i want to make a project where the Arduino takes the info from the sensors connected into the arduino, but i want to send that information to an android smartphone. The project also needs to be small, and i dont need that many pins in the arduino. what do you think is the best arduino and best way to do this?

I paid $8 for a bluetooth connection to my Android phone.

http://rctimer.com/index.php?gOo=goods_details.dwt&goodsid=764&productname=

Works perfectly.

Tim
Logged

Arduino Uno - Teensy 2.0 - Teensy 3.0 - Raspberry Pi Model B w/512MB RAM
My libraries: NewPing library - LCDBitmap library - toneAC library - NewTone library

Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok thanks smiley sho you know if our works with the Arduino pro mini? Because that's the board I want to use
Logged

Toledo, OH
Offline Offline
Sr. Member
****
Karma: 19
Posts: 457
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok thanks smiley sho you know if our works with the Arduino pro mini? Because that's the board I want to use

It will work with any Arduino.

Tim
Logged

Arduino Uno - Teensy 2.0 - Teensy 3.0 - Raspberry Pi Model B w/512MB RAM
My libraries: NewPing library - LCDBitmap library - toneAC library - NewTone library

Durham UK
Offline Offline
Full Member
***
Karma: 1
Posts: 167
aka Craig Turner
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi teckel,

do you have any code examples of how to get this working with arduino and android?

cheers
Logged

Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 50
Posts: 1767
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi teckel,

do you have any code examples of how to get this working with arduino and android?

cheers
Most of the bluetooth modules that you can buy have 4-6 pins (Rx, Tx, Power, Ground, and optionally Key, State).  You hook Rx up to a port that does serial input, Tx up to a port that does serial output, Power and Ground to their respective rails, and State up to a LED if you want an indication of the connection.  On your pro mini, you might connect Rx to pin 0, Tx to pin 1, and use the hardware serial port using the Serial function.  You could use other pins with the software serial port emulation.  On my Teensy 3.0, I'm using pins 7 & 8, which on that chip is the 3rd hardware serial port.

Here is some quick and dirty code that I was using to test my HC-05 bluetooth serial device on my Teensy 3.0.  I have 4 LEDs hooked up to pins 13, 12, 11, and 10.  I use a single character command:
  • 'a' .. 'd' turns off the respective LED;
  • 'A' .. 'D' turns on the respective LED;
  • '*' turns on all of the LEDs;
  • '0' turns off all of the LEDs;
  • '.' and ',' introduce delays.

Code:

#include <stddef.h>

const int leds[] = { 13, 12, 11, 10 };

#define NUM_LEDS (sizeof (leds) / sizeof (leds[0]))

void
setup (void)
{
  size_t i;

  Serial3.begin (9600);
  Serial3.print ("Start\r\n");
  Serial3.flush ();

  for (i = 0; i < NUM_LEDS; i++)
    {
      pinMode (leds[i], OUTPUT);
      digitalWrite (leds[i], LOW);
    }
}

static int number = 0;

void
loop (void)
{
  if (Serial3.available ())
    {
      char ch = Serial3.read ();
      if (ch >= 'a' && ch < 'a' + NUM_LEDS)
digitalWrite (leds[ ch-'a' ], LOW);

      else if (ch >= 'A' && ch < 'A' + NUM_LEDS)
digitalWrite (leds[ ch-'A' ], HIGH);

      else if (ch == '.')
delay (1000);

      else if (ch == ',')
delay (250);

      else if (ch == '0')
{
 for (size_t i = 0; i < NUM_LEDS; i++)
   digitalWrite (leds[i], LOW);
}

      else if (ch == '*')
{
 for (size_t i = 0; i < NUM_LEDS; i++)
   digitalWrite (leds[i], HIGH);
}

      number++;
      Serial3.print ("Bluetooth number: ");
      Serial3.print (number);
      Serial3.print (", read: ");
      Serial3.write (ch);
      Serial3.print ("\r\n");
    }
}

I happen to use the "Connection Terminal"  app on the phone that provides a simple serial terminal interface: https://play.google.com/store/apps/details?id=app.bluetooth&hl=en.

I also tested the BTInterface trial app as mentioned in this thread: http://arduino.cc/forum/index.php/topic,145241.0.html.

One thing to watch out for is whether the device you buy can operate at the voltage  your pro mini runs at (5v or 3.3v).

I bought my unit from a US seller on ebay (nyplatform) for $11US, and the app on the phone was free.  There are various other bluetooth apps on the phone.
« Last Edit: February 04, 2013, 08:34:18 am by MichaelMeissner » Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2945
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A simple code you can try is already provided to you in the Android examples, BlueToothChat. That is the same program I used to get started with, until I was able to break it down to what I needed, to make my own test app.

Get that code, pair the BT module and use a simple arduino code to toggle an LED on and off with "H" and "L".
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Durham UK
Offline Offline
Full Member
***
Karma: 1
Posts: 167
aka Craig Turner
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the input guys

I'll get myself one of those devices and play with it.

cheers
Logged

Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

Toledo, OH
Offline Offline
Sr. Member
****
Karma: 19
Posts: 457
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi teckel,

do you have any code examples of how to get this working with arduino and android?

cheers

It seems others have taken care of this for you.  They're right, you just treat it like a standard serial connection.  You need to be running some sort of app on the other end (like a terminal emulator on an Android).  You could then expand that to a mobile app.  I've only done Android apps, but I'm sure you could do the same with the iPhone/iPad.

Tim
Logged

Arduino Uno - Teensy 2.0 - Teensy 3.0 - Raspberry Pi Model B w/512MB RAM
My libraries: NewPing library - LCDBitmap library - toneAC library - NewTone library

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 50
Posts: 1767
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi teckel,

do you have any code examples of how to get this working with arduino and android?

cheers

It seems others have taken care of this for you.  They're right, you just treat it like a standard serial connection.  You need to be running some sort of app on the other end (like a terminal emulator on an Android).  You could then expand that to a mobile app.  I've only done Android apps, but I'm sure you could do the same with the iPhone/iPad.

Tim
From what I've read, iphone apps are a little bit more tricky, since the iphone bluetooth will only connect to bluetooth devices blessed by Apple, and in order to be blessed by Apple, the developer needs to pay a hefty fee to be licensed as an Apple developer.

In terms of Android apps, I just download the Bluetooth Controller App, which gives you 9 buttons that you can label, and these buttons will send a particular text message to your device.  For my usage, that is sufficient, since I just want a simple replacement for an IR remote control, and it is a lot simpler than a chat program that you enter in text, and hit a send key.  https://play.google.com/store/apps/details?id=apps.BT&hl=en
Logged

Toledo, OH
Offline Offline
Sr. Member
****
Karma: 19
Posts: 457
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi teckel,

do you have any code examples of how to get this working with arduino and android?

cheers

It seems others have taken care of this for you.  They're right, you just treat it like a standard serial connection.  You need to be running some sort of app on the other end (like a terminal emulator on an Android).  You could then expand that to a mobile app.  I've only done Android apps, but I'm sure you could do the same with the iPhone/iPad.

Tim
From what I've read, iphone apps are a little bit more tricky, since the iphone bluetooth will only connect to bluetooth devices blessed by Apple, and in order to be blessed by Apple, the developer needs to pay a hefty fee to be licensed as an Apple developer.

In terms of Android apps, I just download the Bluetooth Controller App, which gives you 9 buttons that you can label, and these buttons will send a particular text message to your device.  For my usage, that is sufficient, since I just want a simple replacement for an IR remote control, and it is a lot simpler than a chat program that you enter in text, and hit a send key.  https://play.google.com/store/apps/details?id=apps.BT&hl=en

Nice little app for simple testing.  Thanks, it will help.

Tim
Logged

Arduino Uno - Teensy 2.0 - Teensy 3.0 - Raspberry Pi Model B w/512MB RAM
My libraries: NewPing library - LCDBitmap library - toneAC library - NewTone library

Queens, New York
Offline Offline
Faraday Member
**
Karma: 67
Posts: 2945
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 I didn't see that app when I was starting out smiley-sad , is it new? That would have made things much easier for me.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Pages: [1] 2   Go Up
Jump to: