Jobsheet Bluetooth Esp32
Jobsheet Bluetooth Esp32
JOB SHEET
PROGRAMME : DKE
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. 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)
Page 2 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
Part 1:
Installing ESP32 Board Installing esp32 board manager
Manager to Arduino IDE
Part 2:
Configuration of Arduino IDE
Page 3 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
your pc.
Part 3 :
Circuit connection to interface
between esp32 and laptop
Part 4:
Writing programming to pair
smartphone with esp32 and
sending and receive data.
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.
Page 6 of 11
DPP B2(c)
PROCEDURE
STEP KEY POINT
Part 6:
Writing programming to pair
smartphone and esp32 to
Control LEDs
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);
}
Notes:
Page 9 of 11
DPP B2(c)
RESULT :
QUESTION/DISCUSSION :
Page 10 of 11
DPP B2(c)
CONCLUSION :
Page 11 of 11