0% found this document useful (0 votes)
11 views25 pages

Lab 10

The document outlines Lab 10 for EE/CE 376L/332L, focusing on establishing Bluetooth communication between a TivaC TM4C123 microcontroller and an Android device using the HC-05 Bluetooth module. It includes tasks for transmitting characters, controlling an RGB LED, and operating a servo motor via Bluetooth commands. Additionally, it provides details on UART communication, circuit connections, and assessment rubrics for evaluating student performance in the lab activities.

Uploaded by

hamzaahmed200072
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views25 pages

Lab 10

The document outlines Lab 10 for EE/CE 376L/332L, focusing on establishing Bluetooth communication between a TivaC TM4C123 microcontroller and an Android device using the HC-05 Bluetooth module. It includes tasks for transmitting characters, controlling an RGB LED, and operating a servo motor via Bluetooth commands. Additionally, it provides details on UART communication, circuit connections, and assessment rubrics for evaluating student performance in the lab activities.

Uploaded by

hamzaahmed200072
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

EE/CE 376L/332L Microcontrollers and Lab

Interfacing 10

Lab 10: Bluetooth Communication

Name: ID: Section:

Objective
To build wireless communication channel between TivaC TM4C123 and Android
device using Bluetooth module HC-05

In-Lab
Task 1: Establish Bluetooth communication between TivaC and Android to
transmit and receive characters
Task 2: To display different colors on RGB LED and control servo using Bluetooth
Task 3: LED Control with HC-05 and Andriod App using Keil uvision

1 Bluetooth Module HC-05

Wireless communication is swiftly replacing the wired connection when it comes


to electronics and communication. Designed to replace cable connections HC-
05 uses serial communication to communicate with the electronics. Usually, it
is used to connect small devices like mobile phones using a short-range wireless
connection to exchange files. It uses the 2.45GHz frequency band. The transfer
rate of the data can vary up to 1Mbps and is in range of 10 meters. The HC-05
module can be operated within 4-6V of power supply. It supports baud rate of
9600, 19200, 38400, 57600, etc.
This module can be used to perform low-cost wireless communication between
microcontrollers such as Arduino, TM4C123, Pic Microcontroller, Raspberry Pi,
BeagleBone, STM32, and Ar- duino Mega, etc. Also, we can use it for
communication between a microcontroller and PC or Android application.
There are many Android applications available in the Google Play store which
we can use to send and receive data to/from HC05. The pin configuration for
this module is given in Fig. 1 with description given below.

• Enable (Key) - This pin is used to set the Data Mode or and AT command
mode (set high)
1
EE/CE 376L/332L Microcontrollers and Lab
• VCC - This isInterfacing
connected to +5V or +3.3V power supply 10

2
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10

Figure 1: Pin Configuration for HC-05

• Ground - Connected to ground of powering system

• Tx (Transmitter) - This pin transmits the received data Serially

• Rx (Receiver) - Used for broadcasting data serially over Bluetooth

• State - Used to check if the Bluetooth is working properly

2 UART communication in TM4C123GH6PM

UART stands for Universal Asynchronous Receiver/Transmitter. It’s not a


communication protocol like SPI and I2C, but a physical circuit in a
microcontroller, or a stand-alone IC. A UART’s main purpose is to transmit and
receive serial data using just two wire TX and RX.

3
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10

Figure 2: UART Channels in TM4C123GH6PM

HC-05 is a two-way full-duplex Bluetooth to serial module. This Bluetooth


device operates on UART communication. In other words, it uses serial
communication to transmit and receive data serially over standard Bluetooth
radio frequency.
UART communication port of the TM4C123GH6PM microcontroller is used with
HC-05. This microcontroller has on-chip 5 UART ports such as UART0 to
UART5. We can use any one of these UART ports to interface TM4C123 with
the BT device. The table in Fig. 2 shows all UART ports of TM4C123 Tiva
launchpad and their corresponding GPIO pins.

3 Android Bluetooth Terminal App

In order to establish Bluetooth communication between TivaC and Android


device, we will use a android application named ”Serial Bluetooth Terminal”,
freely available on Play Store app. You are required to download and install
that application. Once the application would be downloaded, and our HC-05
connections are made with TivaC in Task 01 below, we will follow the steps
shown in Fig. 3 to send and receive commands over Serial monitor of the app
and the Energia.

4
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10

Figure 3: Steps for Serial Bluetooth Terminal App

4 TivaC LaunchPad with Energia

In Energia IDE, unlike Kiel uVision, we can use TivaC LaunchPad pins for
various peripherals without the need to activate Ports using registers or
specifying function of the pin. But it also comes with limitations of usability and
programmable scope of the board. In Energia, we can refer to Pins of TivaC
directly using numeric digit like 1,2,3.. and so on. Pin map for the EK-
TM4C123GXL LaunchPad is given in Fig. 4 with Black Columns under J1, J2, J3
and J4.

Figure 4: TivaC Pin Distribution with Energia


5
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
In-Lab Tasks

Task 1: Establish Bluetooth communication between TivaC and


Android to transmit and receive characters
In this task, we are going to establish simple Bluetooth communication using
UART0 of TivaC and send characters and string from Android device to be
displayed on Energia Serial Monitor. Follow the step below to achieve the
communication:

• Make the connections given in Fig. 5.

• Download and open ”bluetooth.ino” in Energia.

• Modify the code where you are required to in order to make it functional.

• Download and Install ”Serial Bluetooth Terminal” in your Android Mobile


Device.

• Connect your mobile device with Bluetooth module using steps given in
Fig. 3 with password ”1234” or ”0000”. The Bluetooth device name is
mentioned on module itself.

• Once a successful communication is established, you should be able to send


and receive the characters using Serial.

Figure 5: Circuit Connection between TivaC and HC-05

6
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Write your brief and complete understanding of how the code works. Explain
how Bluetooth module use UART protocol to communicate?

Provide your clear circuit image below.

7
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Provide your code here with appropriate comments below (Get the circuit
demonstration checked with RA within Lab)

8
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Task 2: To display different colors on RGB LED and control servo
using Bluetooth

In this task, we will control the color of the built-in RGB LED of TivaC and
position of servo according to command received by Android Terminal. In order
to achieve the above, follow the instructions below:

• Connect Servo’s VCC, GND and PWM pins to 3.3V/Bus, GND and PD3 of
the TivaC Board.

• Initialize pinModes for Servo PWM, and built-in RGB LED which is present
on PortF at pins PF1, PF2 and PF3.

• Use myservo.write(x) to rotate servo to position x.

• Use analogWrite() to obtain different colors on built-in RGB

LED. Using the above steps, you are required to achieve the

following in this task:

• Servo to be moved 45 degrees with color RGB color RED on command ”A”

• Servo to be moved 90 degrees with color RGB color GREEN on command ”B”

• Servo to be moved 135 degrees with color RGB color BLUE on command ”C”

• Servo to be moved 180 degrees with color RGB color WHITE on command ”D”

Write your brief and complete understanding of how the code works for
controlling servo and RGB color using Bluetooth communication.

9
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Provide your code here with appropriate comments below (Get the circuit
demonstration checked with RA within Lab)

10
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Attach Screen-shot of Energia Serial Monitor Below

Provide your clear circuit image below.

11
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Task 3: LED Control with HC-05 and Andriod App using Keil uvision

TM4C123 Tiva Launchpad has an RGB LED connected with PF1, PF2, and PF3
pins. We will send ON/OFF commands from an Android application. Based on
these commands, LEDs will turn on or off.

Commands used to control onboard LEDs of Tiva Launchpad are listed below:

Figure 6: Commands for LEDs

For example, if we send the character ‘A’ from the Android app to HC-05 the
green LED of Tiva Launchpad will turn on. Similarly, if we transmit ‘B’ from the
Android app to HC-05 green LED of Tiva Launchpad will turn off. Likewise,
commands for the other two LEDs are mentioned in the above table.

1. We will use a UART5 port. For the UART5 port, the PE4 GPIO pin is a
receiver pin (Rx) and the PE5 pin is a transmitter pin (Tx). Now make
connections with HC-05 Bluetooth module and Tiva Launchpad according
to schematic diagram (Figure 7).

2. Now create a new project in Keil uvision and compile the skeleton code
(will be given in modules section on LMS). After that upload the generated
hex file to Tiva Launchpad.

3. Modify the code where you are required to in order to make it functional.

4. Download and Install ”Serial Bluetooth Terminal” in your Android Mobile


Device.

5. Connect your mobile device with Bluetooth module using steps given in
Fig. 3 with password ”1234” or ”0000”. The Bluetooth device name is
mentioned on module itself.

6. Once a successful communication is established, you should be able to


send and receive the characters using Serial.

12
EE/CE 376L/332L Microcontrollers and Lab
Interfacing
Write your brief and complete understanding of how the code works. 10

13
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10

Figure 7: Circuit Connection

14
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Provide your code here with appropriate comments below (Get the circuit
demonstration checked with RA within Lab)

15
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
Provide your clear circuit image below.

16
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
5 Assessment Rubrics

Marks distribution

LR1 LR2 LR4 LR5 LR9


Task 1 - 10 points 5 points 10 points 15
Task 2 10 points 10 points 5 points 10 points points
In-lab Task 3 - 10 points 5 points 10 points
Total
Marks 100

Marks obtained

LR1 LR2 LR4 LR5 LR9


Task 1 -
Task 2
In-lab Task 3
Total
Marks 100

17
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
# Assessment Level 1: Un- Level 2: De- Level 3: Level 4: Ex-
El- ements satisfactory veloping (2) Good (3) emplary (4)
(0-1)
LR1 Circuit Layout Connections Few of Circuit Neat,
between the layout and clean,
circuit connections and correct
made con- connections
com- between nections are of all the
ponents circuit correct but circuit
are com- not all components/
mostly ponents connections e- quipment
wrong. are are neat and are made as
Circuit wrong. Cir- clean as per per
lay- out cuit layout standards. standard
is is not neat cir- cuit
clut- and clean as diagram.
tered. per
Needs standards.
guidance
to
make
correct
equipment/-
component
connections.
LR2 Program/Code/ Program/ Program/ Program/ Program
Simulation code/ code/ code/ /code/
Mod- sim-
el/Network simu- simu- simu- ulation
Model lation lation lation mod-
mod- el/network
el/network mod- mod- model
model el/network el/network is
does model model efficiently
not has gives implemente
implement some correct d and gives
the out- put cor- rect
errors but output.
required and does not Student
functionality not produce efficiently has full
and has completely implemente command on
several ac- curate d or the
errors. results. imple- basic tools
The Student mented of
student is has by the
not able to limited com- computation software.
18
EE/CE 376L/332L Microcontrollers and Lab
Interfacing
utilize even mand on the - ally 10
the basic basic tools
tools of of complex
the the software. routine.
software.
LR3 Troubleshooting Unable to Able to iden- Able to iden- Able to iden-
identify tify the fault tify the fault tify the fault
but unable but partially and takes
the to remove it. removes it. nec- essary
fault/minima steps and
l effort actions to
shown in correct it.
troubleshoot
- ing.

19
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
# Assessment Level 1: Un- Level 2: De- Level 3: Level 4: Ex-
El- ements satisfactory veloping (2) Good (3) emplary (4)
(0-1)
LR4 Data Collection Measuremen Measuremen Measureme Measuremen
ts are ts are nts are ts are both
somewhat mostly ac- curate
incom- inaccurate accurate. and precise.
plete, inac- and Ob- Data
curate, imprecise. servations collection is
and Observation are systematic.
imprecise. s are generally Observation
Ob- incomplete complete. s are
servations or vague. Minor
are Ma- jor very
incomplete errors are errors are thorough
or not there in present in and
using using include
included. symbols, symbols, appropriate
Symbols, units, and units, symbols,
units, significant and units, and
and digits. significant significant
significant digits. digits,
figures are and the
not task
included. is
completed
in due
time.
LR5 Results and Figures/ Figures, All figures, Figures/
Plots graphs graphs, graphs, and graphs
/tables are and tables are /tables
not tables are cor- rectly are
developed drawn but drawn correctly
or are contain but drawn,
poorly errors. contain and
constructed Titles, cap- minor errors appropriate
with tions, units or some of titles/captio
erroneous are not the details ns and
results. accurate. are missing.
Titles, Data proper units
captions, presenta- are men-
units are tion is not tioned.
not men- too clear. Data
tioned. presentation
Data is is
systematic.

20
EE/CE 376L/332L Microcontrollers and Lab
Interfacing
presented in 10
an obscure
manner.
LR6 Calculations Formulae Formulae Formulae Formulae
used and/or used are used and used,
calcu- correct but end results
lations are there are are end
in- correct. few correct. results,
Units are mistakes in Com- plete and all
not men- calculation calculations
tioned with which lead working are
re- sults. to incorrect steps are
results. not shown. correct with
Proper units all
are not the
mentioned intermediate
with results. steps
clearly
shown.
Units
are
mentioned
with results.

21
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
# Assessment Level 1: Un- Level 2: De- Level 3: Level 4: Ex-
El- ements satisfactory veloping (2) Good (3) emplary (4)
(0-1)
LR7 Viva Response Response Response Response
shows a shows shows shows
com- plete shallow com-
lack understandi sub- stantial plete under-
of ng of the under- standing of
understand- assigned standing of the
ing of task. the assigned completed
the task. task.
assigned/-
completed The student
task. is able to
explain all
the
related
concepts.
LR8 Equipment/ Inappropriat Appropriate Appropriate Appropriate
Instrument e handling handling handling handling of
Han- dling of the of of all the tools
tools and some of most of and
equipment the the equipment.
with tools tools
and and
minimal equipment. equipment.
accuracy.
LR9 Report All the in- Most of Good sum- Detailed
lab tasks the mary of sum- mary
are not tasks are most of the of the in-lab
included in in- cluded in- lab tasks is
the report in the tasks is provided.
and/or the report included in All tasks are
report is but are the report. included
submitted not The work is and
too late. well supported explained
explained. by figures well. Data is
All the and pre- sented
necessary plots clearly
figures/plots with including all
are not explanations the
in- . The necessary
cluded. report is figures,
The plots, and
report is submitted tables.
sub- mitted timely.
22
EE/CE 376L/332L Microcontrollers and Lab
Interfacing after 10
the due
date.

23
EE/CE 376L/332L Microcontrollers and Lab
Interfacing 10
# Assessment Level 1: Un- Level 2: De- Level 3: Level 4: Ex-
El- ements satisfactory veloping (2) Good (3) emplary (4)
(0-1)
LR10 Analysis Results are Analysis of Results are Results
not the obtained analyzed are well
interpreted results and
or are concluded analyzed
analyzed is but are not supported
incorrectly. incomplete. well with
Conclusions explained,
are not and reasons.
drawn. justification Good
is not compar-
provided ison is
with the made
help of between
reasoning. the
theoretical
and experi-
mental
results with
correct
and useful
conclusions.
LR11 Design Proposed Justification Proposed Proposed
design is for the design design
un- pro- posed is is
substantiate design substanti- substanti-
d or is weak, and ated, ated,
does it only prefer- prefer-
not satisfies ably ably
satisfy some
most of con- through through
the straints. proper proper
given The anal- anal-
constraints. breakdown ysis, ysis, and
The break- of the satisfies all
down of the system is and satisfies given con-
system into missing most given straints. The
features is some con- breakdown
in- complete features straints. The of the
and still at and breakdown system
lower resolution is of the into
resolution. not system
appropri- into features
ate at some features seems

24
EE/CE 376L/332L Microcontrollers and Lab
Interfacing places. seems 10com-
com- plete and
plete, but at
resolution is appropriate
not resolution,
appropri- given
ate at some the
places. students’
level.

25

You might also like