Lampiran DPP C2(c)-1
MARA-Japan Industrial Institute
Beranang, Selangor
JOB SHEET
PROGRAMME : DKE
SESSION : JANUARY – JUNE 2024 SEMESTER : 4
DFE40113/
CODE/SUBJECT : WIRELESS EMBEDDED SHEET NO : JS 05/02
DEVICES
LECTURER : NORHAMIMI BT HAMDAN DURATION : 3 HOURS
TOPIC : BLUETOOTH
Serial Bluetooth connection using ESP32 and listen
SUB TOPIC:
for data from paired devices.
At the end of the lesson, students should be able to :
1. Use the Bluetooth device
LEARNING
2. Interface between Bluetooth device ESP32 and
OUTCOME :
microcontroller.
3. Control LED using Bluetooth device.
1. ESP32
2. Microcontroller
3. LEDs (3 unit)
TOOLS / 4. Resistors (3)
EQUIPMENTS/ 5. Jumper wire
MATERIALS 6. Arduino IDE
7. Laptop
8. Power Supply
DRAWING AND
DATA
1
DPP B2(c)
1. All students must read and understand the
information in this document with regard to
laboratory procedure.
2. Do not use any equipment unless approved by
INSTRUCTION your instructor.
3. If a piece of equipment fails while being used,
report it immediately to your instructor.
4. Clean up your work area before leaving.
Page 2 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
Part 1:
Installing ESP32 Board Installing esp32 board manager
Manager to Arduino IDE
1. Launch your Arduino IDE.
2. Go to file : prefences and
paste url :
https://dl.espressif.com/dl/p
ackage_esp32_index.json
3. Then click ok.
4. Go to tool: board manager
and search for esp32 and
click install.
Figure 1.1: paste url
Figure 1.2: installing esp32 software
Part 2:
Configuration of Arduino IDE
1. Launch Arduino Ide.
2. Go to tools: choose ESP Dev
Module (or DOIT ESP32
DEVKIT V1), change upload
speed to 115200
3. Set port to com as shown in
Page 3 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
your pc.
Figure 2.1: esp32 configuration on Arduino
ide
Part 3 :
Circuit connection to interface
between esp32 and laptop
1. Connect ESP32 to your
computer.
2. Launch your arduino software
3. Upload code to Figure 3.1: Connection
microcontroller.
Part 4:
Writing programming to pair
smartphone with esp32 and
sending and receive data.
1. Launch Arduino Ide.
2. Make a new sketch and write
the programming.
3. After complete programming
click, verify.
Page 4 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
4. Make sure your programming
is success.
Source code:
#include "BluetoothSerial.h"
#if !
defined(CONFIG_BT_ENABLED)
|| !
defined(CONFIG_BLUEDROID_
ENABLED)
#error Bluetooth is not enabled! Figure 4.1: Compiled programming
Please run `make menuconfig` to
and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test");
//Bluetooth device name
Serial.println("The device
started, now you can pair it with
bluetooth!");
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
Page 5 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
delay(20);
}
Part 5:
Pair ESP32 with bluetooth
terminal application to send
and receive data.
1. Install Serial Bluetooth Figure 5.1 serial Bluetooth terminal
terminal application to your
phone.
2. Open your serial Bluetooth
terminal.
3. Enable your phone Bluetooth
connection.
4. Go to device tab and choose
your esp32 device name.
5. Make sure each device is
connected. Figure 5.2 Setting devices
6. Type any text at your test field
at both devices.
7. Now you will be able to send
and receive text on both
device.
Figure 5.3 Choose your Bluetooth device
Page 6 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
Figure 5.4 Connected
Figure 5.5 Send and receive text.
Part 6:
Writing programming to pair
smartphone and esp32 to
Control LEDs
1. Launch Arduino Ide.
2. Make a new sketch and write
the programming.
3. After complete programming
click, verify.
4. Make sure your programming
is success.
Source code:
int inputdata;
int LED_BUILTIN = 2;
#include "BluetoothSerial.h" Figure 6.1: Compiled programming
Page 7 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
#if !
defined(CONFIG_BT_ENABLED) || !
defined(CONFIG_BLUEDROID_EN
ABLED)
#error Bluetooth is not enabled!
Please run `make menuconfig` to
and enable it
#endif
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32testing");
//Bluetooth device name
Serial.println("Bluetooth Device is
Ready to Pair !");
pinMode(LED_BUILTIN,OUTPUT);
}
void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
inputdata=SerialBT.read();
Serial.write(SerialBT.read());
Serial.println("Receive data: ");
Serial.println(inputdata);
if (inputdata== 49){
digitalWrite(LED_BUILTIN,
HIGH);
Page 8 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
SerialBT.println("LED turned
ON");
}
if (inputdata== 48){
digitalWrite(LED_BUILTIN,
LOW);
SerialBT.println("LED turned
OFF");
}
}
delay(20);
}
//the incoming variable with 48 and
49 to check for 0 and 1 respectively.
//If it is a 1 then we turn off the LED
and also print an acknowledgment
message back to Bluetooth saying
that LED was turned off and vice
versa for 0.
Notes:
1. Need to press boot once during uploading
2. If port cannot detect need to update on silicon
driver at windows update
3. If uploading jump to exit can down version the
ESP manager to 1.5
Page 9 of 11
DPP B2(c)
RESULT :
QUESTION/DISCUSSION :
1. Describe the Bluetooth communication protocol used in this experiment.
2. Determine potential applications of Bluetooth technology with the TTGO T-
Call ESP32 in IoT projects.
3. Provide an example of a simple program that initiates a Bluetooth connection
using the TTGO T-Call ESP32.
Page 10 of 11
DPP B2(c)
CONCLUSION :
Page 11 of 11