The ForceTronics blog provides tutorials on creating fun and unique electronic projects. The goal of each project will be to create a foundation or jumping off point for amateur, hobbyist, and professional engineers to build on and innovate. Please use the comments section for questions and go to forcetronics.com for information on forcetronics consulting services.
In this video we will build an Android App to communicate with the low cost HC-06 Bluetooth module. The HC-06 is connected to Arduino Uno and the Android App we build turns on and off an LED connected to the Arduino. Below the video you will find the Arduino code and a link to download the Android App code (MIT Inventor 2 was used to build the Android App). Enjoy!
Link to download App Inventor 2 code (.aia file): https://dl.dropboxusercontent.com/u/26591541/AndroidBTExample.aia Arduino Code: /* This sketch is part of a tutorial for connecting to and communicating with an HC-06 or an RN-42 bluetooth module using a custom Android App. The bluetooth modules are connected to an Arduino and the Arduino is connected to an LED. The Android app is used to wirelessly turn on and off the LED using bluetooth. This code is in the public domain. */ // Pin 7 has a LED connected to it int led = 7; // the setup routine runs once when you press reset: void setup() { Serial.begin(9600); // initialize the digital pin as an output and set it low initially pinMode(led, OUTPUT); digitalWrite(led, LOW); } // the loop routine runs over and over again forever: void loop() { delay(30); String t; //create an empty string to store messages from Android while(Serial.available()) { //keep reading bytes while they are still more in the buffer t += (char)Serial.read(); //read byte, convert to char, and append it to string } if(t.length()) { //if string is not empty do the following if(t == "on") { //if the string is equal to "on" then turn LED on digitalWrite(led, HIGH); //Set digital pin to high to turn LED on Serial.write("LED is on"); //Tell the Android app that the LED was turned on } else if (t == "off") { digitalWrite(led, LOW); Serial.write("LED is off"); } // turn the LED off by making the voltage LOW } }
This is part 2 of the Smart Thermostat project. In part 2 we add the following features to our thermostat design:
Bluetooth control so the thermostat can be controlled remotely so you can control the temperature of your home from the comfort of your couch or bed
Mount the project so it is in a much more usable and aesthetically pleasing form then the prototype form it we saw in part 1
A power save mode to cut down on the utility costs
In part three we will create the Android app and add a power supply to run it off of the 24 VAC signal coming from the HVAC system. To download the Arduino code follow the GitHub link below. Please share your comments!
In this video we look at how to get started with the HC-06 Bluetooth transceiver module. The HC-06 is a great low cost way to add wireless communication to any project. Since the HC-06 uses a serial line to communicate it is easy to pair it with an Arduino.