@tutorial: Android app + Bluetooth + Arduino control

In this small tutorial we will see how to create a small android App using an online tool called App Inventor from Google.

External Link: https://electronoobs.com/eng_arduino_tut7.php

by: ELECTRONOOBS on 2026-05-26

One Arduino UNO (4€-6€) LINK eBay

2. Bluetooth module HC-05 or HC-06 (3€-4€) LINK eBay

3. One Relay module (1€) LINK eBay

4. Android smartphone(x€)

5. PC with internet connection

6. Wires, conectors, solder, soldering iron... (0€)

In this small tutorial we will see how to create a small android App using an online tool called App Inventor from Google. After we create the visual design of the app we will create the code blocks. There we will choos the data we whant to send via bluetooth connection. We will create a new bluetooth client and 4 buttons in order to control 4 outputs of an Arduino UNO. Then we'll make the arduino connections and connect one android smartphone to the Arduino bluetooth module. By pressing the App buttons we will control the Arduino's outputs.

OK, so first we will create the Android App. We google App Inventor 2. We open the page. If you don't have an acount you should create a new one.


When we first open the too we will see our projects. If it is a new account you will have no created projects. So click new project and give a name to your new project. I've called mine Room control since I whant to create a new app in order to control stuff around my room using my phone.


A new viewer is created. In the center we can see our screen. On the left we have our palette with all the components that we could add. On the right we have the settings of each block taht we add.


OK, so we can see the palette, components and propierties. In the components tab we can see that the only thing that we have is our screen. We select that screen and go into properties and start changing settings. We can give a title to our screen, change the background color or even add a image background. We can also switch between the lanscape or portrait modes of screen. I've choosed a portrait mode, grey background and Room control title.

Once we finish with the screen settings we can start adding more blocks. We go to our palette. We first have to add some new layouts where we will add the 4 buttons that we want to create. We go to Layout and drag a new horizontal layout to our screen. In the settings of the new layout we give the a fill parent width and a 80 pixels height and olso a grey background color as the screen.

Now we go back to the palette in to the user interface and drag a new button in to the new added layout. In the settings we delete the button name. We give a 80 by 80 pixel size for our button. In the image settings we upload a new image for this button. I will first add a "light bulb" icon since this button will turn on and off the main light of my room. I recommend you to use ".png" files for the images if you whant transparent buttons.

If you want you can give your own settings to fill your requierments. Now we add two more layouts in the same way as before. Now we add 3 more buttons each one with his own icon. We have to upload a image for each one. I whant to control a vent, a lamp, my pc and the main light. I make the middle layout 40 pixels height and add as a background my logo. That will give a better look to my app. Between each two buttons I've added one more layout and make the width to fill parent in order to separate the buttons. This is the final result.

Now we have to add our bluetooth client and the bluetooth list button. We go to conectivity in the palette. We drag the bluetooth client on oue screen. You can see it is a non visible object. Now we go back to user interface and drag a list picker to the bottom of our screen, below the 3 created layouts. As the buttons I will amke this block 40 by 40 pixels and add a bluetooth icon image as background.

~Code Blocks

Now we go in the right top corner and click the blocks button. A new viewer will open. On the left we can see all the blocks that we've added and the extra ones.

First we have to code the bluetooth client comunication. We want to open the bluetooth list every thime that the list picker that we've added is pressed and to connect to the selected bluetooth client when the list is closed. For that we select the list picker and drag the before picking block. Then we go another time to the list picker and drag the set list picker elements to block inside the before picking block. Finnaly we go to the bluetooth client and drag the adresses and names block.

Now we drag the after picking block from the list picker. We add the selection to block from the list picker. Finnaly we go again to the bluetooth client and drag the conect adresses block and after that we drag the list selection block from the list picker.

Now that our bluetooth connection block is done we have to edit what we will send when each of the buttn is pressed. For that we select first the button one. We drag the when click do block to our wiwer. After that we go to our bluetooth client and drag the send text block. Finnaly We go to the text blocks and drag a "" text block. I whant to send a "1" every thime that the button 1 is pressed.

We do the same for the other buttons. Just "CTRL+C" and "CTRL+V" the button 1 bloch and change the button and the text to send.

I whant to send an "a" when the button 3 is pressed and a "2" when the button 4 is pressed. In the case of button 2 I want to send an "9" just when the button is pressed and a "9" when is not pressed. For that we drag the button 2 touchDown and touchUp block and send a "8" and "9" in this case.

Our blocks are done. Now we ho to the top, we click build and save the app to our PC. Next we copy the ".apk" file to our smartphone using a USB connection and install it on our android smartphone.

~Arduino part

The connection between the bluetooth module and Arduino is just a normal serial comunication where we connect the Rx pin of the module to the Tx pin of the arduino and Tx pin of the module to the Rx pin of the Arduino. I'll use a normal relay module. Connect 5 volts and gnd to the module and the enable pin as well. I'll use pin 11 this time to turn on my lamp. Connect the other 3 enable pin to other relays. The example is made with just one relay.



Arduino bluetooth Android Schematic
Arduino bluetooth Android Schematic

The next code will receive the sended characters via serial comunication. It will decide when to turn to high or low each of the declared outputs. Opening the serial monitor we could see each sended character.

Leave a comment

Please login in order to comment.

Comments

ADVERTISERS
ADVERTISERS
PCBWAY