Connect Android to Teensy3 using bluetooth app

Connect android to teensy via Bluetooth – make your own free app. This post covers the setting up of a very simple app to send a text string to a Teensy and then have this printed to the Arduino IDE serial terminal. This will allow you to check that everything is working, before you take the next step and use the string for something useful.

Heres a short video

I recently moved over from an iphone to the Android OS. I did this for many reasons, but primarily I was extremely dissatisfied with the locked down nature of the standard iphone/apple experience. I wanted control over the phone as an interface with my microelectronics projects. Android allows us to do that without all the nonsense of licences and deployment issues that apple forces us to go through. So, hello fun and playground, goodbye to spending so much time on sorting out stuff to make it happen.

this simple app connects your teensy to android via bluetooth
this simple app connects your teensy to android via bluetooth

You can build your own Android App using the MIT App Inventor, its free and has lots of support on the site: http://appinventor.mit.edu/explore/
A great site for those not wanting to get into app code as it uses a really simple GUI.

There are some examples already on the site and video tutorials. Took me less than an hour from start to deployed app working on phone. There are also lots of nice people out there on the web that are happy to share their code for apps in MIT App Inventor, and as you can see, I have used a big chunk of someone elses code as the starting point for my own app. My starting point was Random Nerd – http://randomnerdtutorials.com/android-app-that-sends-a-message-to-your-arduino/

Teensy will receive the data via bluetooth. For this you can use a cheap bluetooth module like the HC-07, less than £10, and hook it up to the Rx Tx pins assigned to one of the hardware serial ports of Teensy. Rx1 and Tx1 are pins 0 and 1 on Teensy3.

The Teensy code for receiving the data coming in and sending it to the serial terminal to read, is as simple as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 
String receivedText = "";
 
void setup() {
  Serial1.begin(9600); //rx1 and tx1 = pins 0 and 1 on Teensy 3
  delay(200);
}
 
void loop() {
   if (Serial.available()) Serial1.write(Serial.read());
  while(Serial1.available() > 0) { // While there is more to be read, keep reading.
    receivedText += (char)Serial1.read();
    delay(10);  
  }
  if(receivedText != "") Serial.println(receivedText);
  receivedText = "";
}

You can get the simple app from this link: HERE