Simple Bluetooth Lamp Controller Using Android and Arduino

Making a simple system to controll a lamp or some other appliance in your house.

Feb 21, 2017

104655 views

21 respects

Components and supplies

1

Android device

1

HC-06 Bluetooth Module

1

Resistor 1k ohm

1

Arduino UNO

1

Relay (generic)

1

Resistor 560 ohm

Apps and platforms

1

Arduino IDE

1

Android Studio

Project description

Downloadable files

Breadboard - Arduino + Bluetooth + Relay

Breadboard - Arduino + Bluetooth + Relay

Comments

Only logged in users can leave comments

Anonymous user

2 years ago

Hi. I'm new to all this "Arduino-android" stuff. So I ask to answer in a wery simple way. I did everything step by step. The app keeps crashing on startup. Where could my mistake be? And what about the "Toolbar"? Is it necessary here?

Anonymous user

2 years ago

In AndroidManifest.xml look for <activity android:name=".Bluetooth"> and change the part in quotations to the name of your main activity. If you write the first bit, it will autocomplete for you. The Toolbar part can also be removed safely.

Anonymous user

2 years ago

Very nice and interesting project. I'm new to Android Studio and Java and wonder if it is possible to get an out of the box zip file ready to compile without errors ? I have spent hours trying to compile and edit the sources but I'm stuck in error messages. I'm using Android Studio v 3.5.3. Ok to upgrade if needed. OS is Windows 7,64 bit. Or are there any tricks aI don't know about ?

Anonymous user

2 years ago

hello I want to create a widget for this app. No one guides me?

Serge144

2 years ago

if you want to create a widget (to have some button in your home menu) you'll have to check other tutorials! 😃

Anonymous user

2 years ago

*Its 2021 June 01st,, There were lots of errors on this github code, (after gradle updates,software versions and stuff). Somehow I managed to fix this whole code again. Now working properly *All Credit goes to Serge144 for making this very helpful code. *It took me hours trying to fix the errors. Therefore if anyone wants the source code just email me or something, *Just trying to Save someone's Time!! Cheers thareen.edirisuriya@gmail.com

Anonymous user

2 years ago

Thanks for the simple, straightforward and up to date explanation. While there's a lot of other Bluetooth connection examples, many include complications such listing and selecting the item to connect to, pick a complicated example like a chat service, and very few explain it step by step, many don't even give an example of the finished article so you know what you're learning to do! Now my phone is talking to my HC-05, and I'm very pleased. :)

Anonymous user

2 years ago

I was thinking of controlling my PC, but I have another relay. The relay switch I have is a DIP DIL (VR05R241A). Trying to find the solution on Arduino Forums, but I think I'll have to experiment a while before figuring out "how to". I did however find out that by using the relay, and a code for blinking lights, I could get it to switch on/off. BUT.. I need it to switch on just for like a 1ms, and then switch off..

Anonymous user

2 years ago

Hi, if you’re interested to learn how to control your Arduino projects using an Android device then there’s a course in Udemy that is currently on sale. This course will teach you how to create an Android app using Android Studio that can control your Arduino board using bluetooth connection. Code template is included. Once you can control the Arduino board, you can also control whatever appliances connected to your board. This is the link: https://www.udemy.com/course/basic-android-programming-for-arduino-makers/?referralCode=18FB9070598F11832F48

Anonymous user

2 years ago

can give app link

Anonymous user

2 years ago

Hey man awesome project! Im a Java beginner using ecclipse, I notice there's no Main method in your code. I'm guessing that that has something to do with the fact that its running on Android? Sorry for the noob question

Anonymous user

2 years ago

gan serge tolong di bantu,di saat saya sudah instal APK nya trus di saat d buka di klik Relaynya lalu aplikasi warning something went wrong?apakah saya yang salahnya dimna?

Anonymous user

2 years ago

How can I create a widget in android studio that turns LED on and off?

Serge144

2 years ago

if you want to create a widget (to have some button in your home menu) you'll have to check other tutorials! :)

Anonymous user

2 years ago

Why is there no source code on the github's site? How can I download it?

Anonymous user

2 years ago

Hello, I could not control a LED with a mobile phone. Gives this message on mobile : "something went wrong" I need an Android application that automatically connects to the Bluetooth module when the phone is approaching the module. please guide me.

Anonymous user

2 years ago

Thank you very much. I found the Mac address. But how can I open source code with the Android Studio ? The source code does not contain the gradle and does not display the codes correctly.

Anonymous user

2 years ago

Thank you very much. Finally, I implemented this project. And it worked very well.

Serge144

2 years ago

Hello, see my reply for Ahmadreza Kashefi comment (below), Cheers

Serge144

2 years ago

Ok here's my recommendation then. Create your own project from scratch with a basic activity and then try to recreate what i did in my code by either following the post or the code. It's only 2 java classes

Serge144

2 years ago

I'm glad it worked out!

Serge144

2 years ago

I'm sorry, i found that when pasting a URL to these editors it may also catch some characters from the text right next to it. You may now click on the fixed repository URL in the post. Here it is too: https://github.com/serge144/ArduinoConnectorBT

Serge144

2 years ago

This message shows because the app didn't connect to the ESP bluetooth module. Now there may be some reasons for this: 1) You're using the wrong MAC: As i've explained in the post, you need to use the MAC of your ESP bluetooth module not the one in my code. To find your MAC, you turn ON your bluetooth module, then, you go to your smartphone or PC, and use the bluetooth to see the listing of available bluetooth devices, if the ESP appears in that list then you may find your MAC. 2) The app was already on: Let me explain: the app attempts to connect to the bluetooth module when it starts! So let's say you turn ON the ESP, and only then you go back to your already running app, this won't work because the attempt to connect was already made when the ESP was off! So what must be done is: turn ON the Arduino/ESP and THEN run a fresh instance of the app. Hope i have helped somehow, Cheers

Anonymous user

2 years ago

Hi, could you please check app? I tried and it gave me error.Thank you for your project,I couldn't find anywhere else auto bluetooth connection.

Anonymous user

2 years ago

same here.

mrsaizo

3 years ago

I was thinking of controlling my PC, but I have another relay. The relay switch I have is a DIP DIL (VR05R241A). Trying to find the solution on Arduino Forums, but I think I'll have to experiment a while before figuring out "how to". I did however find out that by using the relay, and a code for blinking lights, I could get it to switch on/off. BUT.. I need it to switch on just for like a 1ms, and then switch off..

Anonymous user

3 years ago

Hi, if you’re interested to learn how to control your Arduino projects using an Android device then there’s a course in Udemy that is currently on sale. This course will teach you how to create an Android app using Android Studio that can control your Arduino board using bluetooth connection. Code template is included. Once you can control the Arduino board, you can also control whatever appliances connected to your board. This is the link: https://www.udemy.com/course/basic-android-programming-for-arduino-makers/?referralCode=18FB9070598F11832F48

Anonymous user

2 years ago

can give app link

Anonymous user

3 years ago

*Its 2021 June 01st,, There were lots of errors on this github code, (after gradle updates,software versions and stuff). Somehow I managed to fix this whole code again. Now working properly *All Credit goes to Serge144 for making this very helpful code. *It took me hours trying to fix the errors. Therefore if anyone wants the source code just email me or something, *Just trying to Save someone's Time!! Cheers thareen.edirisuriya@gmail.com

Anonymous user

3 years ago

gan serge tolong di bantu,di saat saya sudah instal APK nya trus di saat d buka di klik Relaynya lalu aplikasi warning something went wrong?apakah saya yang salahnya dimna?

jasonadams864

4 years ago

Hey man awesome project! Im a Java beginner using ecclipse, I notice there's no Main method in your code. I'm guessing that that has something to do with the fact that its running on Android? Sorry for the noob question

Anonymous user

4 years ago

Do you have the android code in kotlin?

Anonymous user

4 years ago

Very nice and interesting project. I'm new to Android Studio and Java and wonder if it is possible to get an out of the box zip file ready to compile without errors ? I have spent hours trying to compile and edit the sources but I'm stuck in error messages. I'm using Android Studio v 3.5.3. Ok to upgrade if needed. OS is Windows 7,64 bit. Or are there any tricks aI don't know about ?

Anonymous user

5 years ago

Hi. I'm new to all this "Arduino-android" stuff. So I ask to answer in a wery simple way. I did everything step by step. The app keeps crashing on startup. Where could my mistake be? And what about the "Toolbar"? Is it necessary here?

Anonymous user

2 years ago

In AndroidManifest.xml look for <activity android:name=".Bluetooth"> and change the part in quotations to the name of your main activity. If you write the first bit, it will autocomplete for you. The Toolbar part can also be removed safely.

rxraine

5 years ago

Thanks for the simple, straightforward and up to date explanation. While there's a lot of other Bluetooth connection examples, many include complications such listing and selecting the item to connect to, pick a complicated example like a chat service, and very few explain it step by step, many don't even give an example of the finished article so you know what you're learning to do! Now my phone is talking to my HC-05, and I'm very pleased. :)

Anonymous user

6 years ago

hello I want to create a widget for this app. No one guides me?

Serge144

2 years ago

if you want to create a widget (to have some button in your home menu) you'll have to check other tutorials! 😃

Anonymous user

6 years ago

How can I create a widget in android studio that turns LED on and off?

Serge144

2 years ago

if you want to create a widget (to have some button in your home menu) you'll have to check other tutorials! :)

Anonymous user

6 years ago

Why is there no source code on the github's site? How can I download it?

Anonymous user

2 years ago

Hello, I could not control a LED with a mobile phone. Gives this message on mobile : "something went wrong" I need an Android application that automatically connects to the Bluetooth module when the phone is approaching the module. please guide me.

Anonymous user

2 years ago

Thank you very much. Finally, I implemented this project. And it worked very well.

Anonymous user

2 years ago

Thank you very much. I found the Mac address. But how can I open source code with the Android Studio ? The source code does not contain the gradle and does not display the codes correctly.

Serge144

2 years ago

This message shows because the app didn't connect to the ESP bluetooth module. Now there may be some reasons for this: 1) You're using the wrong MAC: As i've explained in the post, you need to use the MAC of your ESP bluetooth module not the one in my code. To find your MAC, you turn ON your bluetooth module, then, you go to your smartphone or PC, and use the bluetooth to see the listing of available bluetooth devices, if the ESP appears in that list then you may find your MAC. 2) The app was already on: Let me explain: the app attempts to connect to the bluetooth module when it starts! So let's say you turn ON the ESP, and only then you go back to your already running app, this won't work because the attempt to connect was already made when the ESP was off! So what must be done is: turn ON the Arduino/ESP and THEN run a fresh instance of the app. Hope i have helped somehow, Cheers

Serge144

2 years ago

I'm glad it worked out!

Serge144

2 years ago

Ok here's my recommendation then. Create your own project from scratch with a basic activity and then try to recreate what i did in my code by either following the post or the code. It's only 2 java classes

Serge144

2 years ago

Hello, see my reply for Ahmadreza Kashefi comment (below), Cheers

Serge144

2 years ago

I'm sorry, i found that when pasting a URL to these editors it may also catch some characters from the text right next to it. You may now click on the fixed repository URL in the post. Here it is too: https://github.com/serge144/ArduinoConnectorBT

Anonymous user

2 years ago

Hi, could you please check app? I tried and it gave me error.Thank you for your project,I couldn't find anywhere else auto bluetooth connection.

Anonymous user

2 years ago

same here.