MIT APP inventor Arduino:
MIT APP inventor Arduino Bluetooth Application- I have been using Bluetooth supported cell phone apps for monitoring and controlling different types of sensors and electrical loads. I designed all of my previous apps in Android Studio. A few months back I uploaded articles on how to design your own android app for controlling electrical loads and how to design your own android cell phone app for monitoring the sensors connected with the Arduino. These two articles got very popular and helped many boys and girls in designing their own cell phone apps for controlling and monitoring electronics connected with the Arduino. So, if you are into the Android Studio thing then you should read these articles. If you think programming is difficult for you and you are only comfortable with drag and drop type work then this article is for you. Because the Cell Phone App we are going to make today doesn’t require any coding. Amazing!!!
In this article, I am going to use the MIT APP Inventor for designing a Bluetooth supported App which can be used with Arduino boards with the help of a Bluetooth module like HC05 or HC06, or any other Bluetooth module. But, in this article, I will be using HC05 Bluetooth module which I have used in so many projects. You can also check my other Android based projects.
Without any further delay, let’s get started!!!
HC05 Bluetooth module:
HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup.
Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3 Mbps Modulation with complete 2.4 GHz radio transceiver and baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology and with AFH (Adaptive Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm. Hope it will simplify your overall design/development cycle.
As this is my first article on the MIT APP Inventor, so I will try to keep things simpler so that you guys can easily follow each and every step. So, instead of doing something complex, I will start with the LED, You know ? if you can control an LED it means you can control a transistor, a Mosfet, a relay etc. So, In this article we will going to learn how to control the LED connected with the Arduino Uno or Arduino Nano or Arduino Mega, using Bluetooth app. I will add two buttons which can be used to turn ON and turn OFF the LED connected with the Arduino board. In the future you can replace this LED with other electrical devices which you want to control. The cell phone app will wirelessly communicate with the Arduino with the help of the HC05 Bluetooth Module. So, what we have is at HC05 Bluetooth module? if you look at the front side it will look it will show you some kind of antenna here on hc-05 Bluetooth module and on the back side when we look at that we will see the every pin on this module. The first pin is enable en, second pin is VCC, the third pin is a ground and then the fourth one is a TXD and the fifth one is RXD. So this is how the pin label has been given on this hc-05 Bluetooth module.
Interfacing of HC-05 with Arduino:
So let’s take this Bluetooth module and connect it to Arduino Uno. So here we have a Bluetooth module and you see on our Arduino Uno. The digital pin 0 is RXD and the digital pin 1 is TXD. In order to make communication between the HC-05 and Arduino we will connect TXD of the HC-05 to RXD of the Arduino and RXD of the HC-05 to TXD of the Arduino. The ground of the HC-05 should be connected to the ground of the Arduino. Connect the VCC of the HC-05 to the 5V of the Arduino.
This is how we will have to connect at HC-05 Bluetooth module with Arduino Uno then we will connect the led with the Arduino. The longer leg of the LED which is anode will going to connect to 13 pin of the Arduino and the shorter leg of the LED will going to connect to the ground. Don’t forget to add a current limiting resistor with one of the legs of the LED if incase you are using an LED below 5volts. You can select a 330 ohm resistor, which works perfect with 2.5v LEDS.
In order to make a successful communication, you will need to program the Arduino board. Next, we are going to write a very basic program to read the HC05 Bluetooth module and then control the LED as per the command received from the cell Phone App designed in MIT App Inventor.
MIT App Inventor HC05 with Arduino Programming:
char Incoming_value = 0;
if(Serial.available() > 0)
Incoming_value = Serial.read();
if(Incoming_value == '1')
else if(Incoming_value == '0')
The very first thing that you might have noticed is that, no libraries are used. We don’t need to download any library for this particular project. As I am planning to use the Arduino’s default serial port. If in your case you want to use other pins as the Serial port then you will need to add the SoftwareSerial library which I have already covered in my previous articles. So, for now no library is needed.
char Incoming_value = 0;
I started off by defining a variable Incoming_value of the type char and initially stored a value of 0. As I will be sending only one character from my designed cell phone App, so this is why I selected the char data type. So, the received value will be stored in this variable.
You know, every Arduino program has at least two functions which are the void setup() and void loop() functions. Void means these functions have no return type. So, let’s go ahead and start with the void setup() function. You can clearly see, inside the void setup() function we have only two lines of code. The first line Serial.begin(9600); activates the serial port and inside the parenthesis you can see a number 9600, this is the baud rate. This is the communication speed and it should be same on both the devices. As I have selected 9600 for the Arduino so I will use the same baud rate on the cell Phone App as well. Make this a permanent part of your memory, whenever you are communicating between devices use the same baud rate. The next line pinMode(13, OUTPUT);
Tells the controller whether we are going to use pin 13 as the input or as the output. In our case as we will be controlling an LED so we are going to select OUPUT.
One more thing about the void setup() function, When you turn On the Arduino, it executes only once, and then the loop() function runs repeatedly. When you turn OFF the Arduino and turn it ON again, the setup() function will execute only one time and then the loop() function continues to run repeatedly. So, all I want to explain is, the setup() function executes only one time when the Arduino is turned ON.
Now, let’s get inside the void loop() function. You can see inside the loop() function I have used only 1 if condition. I am using this for monitoring the serial port.
if(Serial.available() > 0)
if(Serial.available() > 0) the purpose of this condition is to check if we have received any data on the serial port. Of the value is 0 it means no data is received and if its greater than 0 it means we have incoming data. So, if we have received the data then execute all the instructions inside the brackets.
Incoming_value = Serial.read();
Incoming_value = Serial.read(); this line of code is used to read the serial port and store the received value in the variable Incoming_value.
Serial.print(Incoming_value); this line of code is used to print the received charater.
Serial.print(“\n”);// this line add a new line
if(Incoming_value == ‘1’) this condition is used to check if the received value is 1, then turn on the LED.
digitalWrite(13, HIGH); // led connected with pin 13
else if(Incoming_value == ‘0’) if the received value is 0 then turn off the LED.
So, that’s all about the Arduino Bluetooth Module programming.
Creating Mobile APP using MIT APP inventor:
Now to create a mobile app using MIT App Inventor we have to browse the web page App Inventor https://appinventor.mit.edu/explore/get-started
So, we first have to come to this web page and then we have to click on create app button in your upper right corner.
So once we click on that it will take us to the page where it will ask us if you have the account then it will not ask you it will take you straight away to MIT App Inventor. Just to login normal if you don’t have account then I would rather like to use my Google account to associate with App Inventor. So I will click on that and it will create a quick account with my password. Then it will take you it will ask you here welcome to the App Inventor and click on continue
Then another dialogue will appear and we will click on the start new blink project. Now to start creating a mobile app we have to create a project and you see there is a button called start a new project upper left corner.
I would like to give the name to the app as a Bluetooth and then hit on OK so you see it creates a project with the name Bluetooth. It takes a couple of minutes and then it will straightaway take you to the project itself.
If you look at the App Inventor how it works is it basically gives you two views right if you look at upper right corner there is a designer view and block view. So if I click on block view you can see there are some widgets in the left pan so there we can select some widgets and then we can create an app so design of view.
Now we can start laying down the components which we need in order to make this app work with the hc-05 bluetooth module and arduino. So the first component we need is a list picker so we have to take a list picker element and you see here is a list picker I can select the list picker in the left pan and drag it to my mobile app. So this is a mobile screen where I can drag down.
In the left pane here the width I will make it as a fill parent and say okay and it looks a little bit better. Now and I would like to give it a name so if you scroll down this you can see there must be a text field. So I would like to give the name LED Bluetooth so look at this when I hit enter you see the name of the list picker is changed. So basically this is a normal button which you can click and then you will see a different Bluetooth client in a list. So there we have to select hc-05 because that’s the Bluetooth module that we want to communicate with using this mobile app that we are creating.
Now the second component we want is an horizontal arrangement. So if we click on layout section there is a horizontal layout. In a layout section so I will drag it to my mobile apps and I select it and then I would going to say width and say fill parent.
Then go to user interface once again and then select the button in the left pan and put one button and then I will select the button and I will put another button so now we I have two buttons but it looks very ugly so I select the first button here in the user interface and I will say worth fill parent.
Then again just the way we did in the text section I will give the name on and you see the name of a button one is changed to on because when I press the button in a mobile app it will turn on the LED connected to Arduino using hc-05 Bluetooth module and let’s give it a name to other button. Button number 2 select the button number two and then weight fill parent and then give it a name OFF.
The one very important thing is we have to add now is the bluetooth component. So we will go to connectivity section select the connectivity in the left pan
Select the bluetooth client from the list and then drop it to your mobile app and you see this bluetooth client is added into the component list.
Now we laid down the user interface components now we have to write logic so that it will take an action that we want it to perform through the mobile app. So we will click on upper right corner you see there is a block view so we click on block view and then we select the list picker.
There are two components we want list picker 1 basically after picking and list picker before picking.
So before you press the button the list picker button and after you press the list picker element. When you don’t connect then it just does not do anything just have the Bluetooth connections and when you press after picking. So when you press the button then it will show you the list of Bluetooth clients.
So the next thing in order to make the logic work is we have to go to the list picker element again and then we have to select your list picker 1 element.
Then we have to use the Bluetooth client if there’s any so bluetooth client could be found into the Bluetooth client section.
I will drag the Bluetooth component and go to block view and now I go to Bluetooth components and now you see I have this list of elements and I would select a Bluetooth client address name basically and I will put it. So that’s how it works and then we have to go to the list picker once again and then we have to take the selection.
Then we have to select for the Bluetooth client and the Bluetooth client is to connect.
So this one we want because whenever we press the list then it will give us the list of Bluetooth connected Bluetooth clients which are paired with your mobile phone with this app is running basically so the next component is a list picker and then we have to select the list picker 1 selection element.
we just want to through the text so whenever you select the hc-05 bluetooth module then the button name has to be changed from LED bluetooth to say for example something like connected.
So whenever you select Bluetooth line then o it will change the text to be connected so once you place the button.
In order to connect to the Bluetooth Arduino Bluetooth when you press this button then it will give you the list you select at zero five and then the name of this pattern will be changed as a connected so you then confirm that your mobile phone and the app is connected to your hc-05 Bluetooth module which is connected to other. We know then go back to the blog section and in a button I have to take button one and then we have to go to button two and take the button 2.
So here we have two buttons and then we have to write a logic where when we placed the button then the button one will send the text to Arduino over HC-05. I will send text element that we want to put here and then in the next section whenever somebody press the button one then it will send one so that turn on the LED connected to Arduino.
Then you can copy and paste by the way so I can just duplicate the element and put it here and I would just say zero.
So whenever somebody pressed the button off it will send a zero. Accordingly our logic is written so when we press on button then it will send one because that’s what we wrote and when we press a button OFF it will send zero so it will turn off the LED connected to Arduino.
Now to make this app work with your mobile phones now once the project is ready on a screen that we have to take our phone in order to transfer the mobile app from our MIT App Inventor to the mobile phone.
We can save the app in two one way is to save it to in computer and in other way we can scan the QR code and by scanning this QR code it will be downloaded in Mobile phone.
Now turn on the Bluetooth in the mobile phone and connect it to the module. Then open the app in the mobile and from where we can on and off the led. From all this, no doubt MIT App Inventor is any amazing platform for designing cell phone apps, but seriously I have been making apps for Arduino using the Android Studio, and I personally like Android Studio. Anyway, everyone has its own point of view. If you have any question regarding this article let me know in a comment.