5.- App gets the text of a QR using BarcodeScanner. Send that text to ESP32.
p62D_esp32_bluetooth_6.aia (2.8 KB)
- BluetoohClassic. ESP32.
- BarcodeScanner gets the text of a QR.
- Send that text to ESP32 via Bluetooth.
- ESP32 returns the same text to the app.
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
void setup() {
Serial.begin(115200);
initBT();
}
void initBT(){
if(!SerialBT.begin("ESP32CAM-CLASSIC-BT2")){
Serial.println("An error occurred initializing Bluetooth");
ESP.restart();
}else{
Serial.println("Bluetooth initialized");
}
SerialBT.register_callback(btCallback);
Serial.println("The device started, now you can pair it with bluetooth");
}
void btCallback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param){
if(event == ESP_SPP_SRV_OPEN_EVT){
Serial.println("Client Connected!");
}else if(event == ESP_SPP_DATA_IND_EVT){
while(SerialBT.available())
{
String received = SerialBT.readStringUntil('\n');
Serial.println(received);
SerialBT.println(received); // Return
}
}
}
void loop() { }

