Cheap way to connect an Arduino to a Android Smartphone via bluetooth

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 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.

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

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

evilcubed:
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

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

evilcubed:
Ok thanks :slight_smile: 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

Hi teckel,

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

cheers

trendski:
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.
#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.

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".

Thanks for the input guys

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

cheers

trendski:
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

teckel:

trendski:
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

MichaelMeissner:

teckel:

trendski:
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

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

HazardsMind:
I didn't see that app when I was starting out :frowning: , is it new? That would have made things much easier for me.

I just noticed it today. I was looking at one of the other bluetooth apps, and it was listed as an app other people who had looked at the page I was one also looked at.