Skip to content

13. Networking and communications

Group Assignment

  • send a message between two projects

Connect two ESP32 boards with Bluetooth Serial (FAILED)

We referred to the website below(Japanese) for the procedure.

Ref:ESP32同士をBluetoothシリアルでつないでみる

After we connect two boards, general flow was as follows: 1.Install ESP32 using Arduino IDE Boards Manager Ref:Installation instructions using Arduino IDE Boards Manager

2.Check BluetoothMAC Address of ESP32 on the secondary side. 3.Write the sample program on the master side after modify some part

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;

String MACadd = "24:0A:C4:11:97:4E";
uint8_t address[6]  = {0xAA, 0xBB, 0xCC, 0x11, 0x22, 0x33};
//uint8_t address[6]  = {0x00, 0x1D, 0xA5, 0x02, 0xC3, 0x22};
String name = "OBDII";
char *pin = "1234"; //<- standard pin would be provided by default
bool connected;

void setup() {
  Serial.begin(115200);
  //SerialBT.setPin(pin);
  SerialBT.begin("ESP32test", true);
  //SerialBT.setPin(pin);
  Serial.println("The device started in master mode, make sure remote BT device is on!");

  // connect(address) is fast (upto 10 secs max), connect(name) is slow (upto 30 secs max) as it needs
  // to resolve name to address first, but it allows to connect to different devices with the same name.
  // Set CoreDebugLevel to Info to view devices bluetooth address and device names
  //connected = SerialBT.connect(name);
  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.");
    }
  }

4.Write the sample program on the secondary side without modifying. 5.Check the connection of two ESP32 boards on the serial monitor.

We followed the instructions correctly, struggled for a few hours, however it didn’t work till the end… We could not find the reason for it this time, then tried another way.

Connect ESP board with the mobile phone with Wi-Fi (Succeeded!)

General Flow is was follows:

1.Find the following sample code on Arduino IDE.

2.Write the program and Check the IP address on the serial monitor.

3.Access the IP address above with the web browser of the mobile phone.

4.As turning on/off the LED from the phone, the instruction went well to ESP32 board!


Last update: May 2, 2021