Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "BluetoothSerial.h"
- BluetoothSerial SerialBT;
- uint8_t address[6] = {0x98, 0xDA, 0x50, 0x02, 0x4A, 0xFE}; // Change this to reflect real MAC address of your slave BT device
- bool connected;
- void setup() {
- Serial.begin(115200);
- //SerialBT.deleteAllBondedDevices(); // Uncomment this to delete paired devices; Must be called after begi
- //Bluetooth setup and connection
- SerialBT.begin("ESP32test", true);
- Serial.println("The device started in master mode, make sure remote BT device is on!");
- connected = SerialBT.connect(address);
- if (connected) {
- Serial.println("Connected Succesfully!");
- } else {
- while (!SerialBT.connected(10000)) {
- Serial.println("Failed to connect. Make sure remote device is available and in range, then restart app.");
- }
- }
- SerialBT.connect();
- }
- void loop() {
- if (Serial.available()) {
- SerialBT.write(Serial.read());
- }
- if (SerialBT.available()) {
- Serial.write(SerialBT.read());
- }
- delay(20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement