Receive Bluetooth Data from Arduino to MIT App Inventor (HC-05/06)

Title of the project

Receive Bluetooth Data from Arduino to MIT App Inventor (HC-05/06)

Description

In this tutorial you will learn how to make a mobile application that will receive Bluetooth data from Arduino to MIT App Inventor.

This is also a second tutorial from our IOT Garbage Monitoring System project.

Schematic Diagram

Garbage Monitoring System in Arduino - Schematic Diagram
Garbage Monitoring System in Arduino – Schematic Diagram

List of parts and estimated prices

  • Bluetooth Module (HC-05 or 06) – $7.99
  • Arduino Nano – $2.05
  • Jumper Wires (Female to Female) – $3.50
  • Resistors (1K & 2K ohm) – $1.0

How the project works

Previously, we have made a Garbage Monitoring System that will allow user to indicate the amount of trash inside the garbage bin through mobile application, we’ve also discuss how we can send Bluetooth data using Arduino and now we will make a mobile application that will receive this data in order to show the exact status of our garbage bin while also giving a graphical view with a percentage value to the user.

Go to http://ai2.appinventor.mit.edu/ sign in using google account and create a new project.

Receive Bluetooth Data from Arduino to MIT App Inventor - Image1
Receive Bluetooth Data from Arduino to MIT App Inventor – Image1

Name your project.

Receive Bluetooth Data from Arduino to MIT App Inventor - Image2
Receive Bluetooth Data from Arduino to MIT App Inventor – Image2

Add this Non-visible Component to your App

Receive Bluetooth Data from Arduino to MIT App Inventor - Image3
Receive Bluetooth Data from Arduino to MIT App Inventor – Image3

Proceed to put a List Picker and add a Label, change the name of the Label to LevelTitle and StatusTitle this is for the title, add another Label right next to each of them and change its name to LevelValue and StatusValue this is for the value.

Add another Label and name it Title we will use this later to indicate whether the Bluetooth in your phone is ON or OFF by changing its text color.

Receive Bluetooth Data from Arduino to MIT App Inventor - Image4
Receive Bluetooth Data from Arduino to MIT App Inventor – Image4

Also change the text for LevelTitle and StatusTitle to Level: and Status: do the same for the LevelValue and StatusValue and change it to 0% and Empty

Design your application whatever you want this is my personal preference.

Receive Bluetooth Data from Arduino to MIT App Inventor - Image5
Receive Bluetooth Data from Arduino to MIT App Inventor – Image5

We will use the List Picker’s text to see the current value of LevelValue and use a custom image to make it look like a garbage bin. I have also added some few custom images.

Receive Bluetooth Data from Arduino to MIT App Inventor - Image6
Receive Bluetooth Data from Arduino to MIT App Inventor – Image6

Each state (Empty, Moderate, Full) we will change the List picker’s image to TrashBin-Full.png, TrashBin-Medyo.png and TrashBin-Empty.png in order to properly indicate the status of the garbage bin.

To do this we will have to use our code blocks, first let’s use the List Picker to connect to our Bluetooth Module (HC-05/06).

Receive Bluetooth Data from Arduino to MIT App Inventor - Image7
Receive Bluetooth Data from Arduino to MIT App Inventor – Image7

Create two global variable and name them Script and List, we will use this later to store the given data from Arduino.

Receive Bluetooth Data from Arduino to MIT App Inventor - Image8
Receive Bluetooth Data from Arduino to MIT App Inventor – Image8

Inside the When Clock 1.Timer block, we have to check first if the Bluetooth in your phone is ON, if it is we will proceed to check if it is connected to HC-05/06, if it is connected we will change the Label Title text color to GREEN to indicate it is connected and RED if not, If the Bluetooth is OFF then we will reset its color to WHITE

Receive Bluetooth Data from Arduino to MIT App Inventor - Image9
Receive Bluetooth Data from Arduino to MIT App Inventor – Image9

We will receive the given Bluetooth data from Arduino, remember the Arduino will only send a single sentence with two words (ex. “F 100”) we have to split this sentence and store each word on a list, to do this we can split them at spaces then put them on a list, after this we now have a list with two words or index inside, one is for the status and the other one is for the value, use an if statement to verify the status, if the first index is “F” then change the List Picker’s image to TrashBin-Full.png to indicate the garbage bin is full, if the first index is “M” then change the List Picker’s image to TrashBin-Medyo.png to indicate the garbage bin is at the Moderate State, if the first index is “E” then change the List Picker’s image to TrashBin-Empty.png to indicate the garbage bin is Empty while also changing the StatusValue’s text and LevelValue’s text to whatever the second index has.
Else if we do not receive any data we will just reset the mobile application’s design to default

Author:

Hizon Pastorpili
09653873994

Download the mobile application.

Download Source code

You may visit our Facebook page for more information, inquiries, and comments. Please subscribe also to our YouTube Channel to receive free capstone projects resources and computer programming tutorials.

Hire our team to do the project.

, , , ,

Post navigation