Hi,
even if the discussion is older it is still an everyday problem to solve.
We use multiple ESP32s with arduino and need lots of communication.
So here is my approach:
We want to use eight ESP32s that are build into two robots.
The two robots have to talk via bluetooth, as only peertopeer is allowed so wifi by definition is no option.
On each robot there is one "master" esp32 and three slaves and we played around with I2c, SPI and Serial quite a
lot and none of them worked sufficiently in millisecond time.
Then we discovered the CAN Bus and this was the best option for us.
As CAN is a multimaster bus there is no need to have a "slave" - program on the "slave" circuit boards.
We use the Sandeepmistry library
https://github.com/sandeepmistry/arduino-CAN
even if there still is an unresolved freeze issue when the can cable is removed completely.
Thanks to the filter option of the can bus library we easily managed to build our own master-slave protocol here.
This works fine and if you use the second esp32 core just for canbus, the whole communication between the four boards
(master request 1 - slave 1 answered , master request 2 - slave 2 answered, ...) works within one millisecond, even if we reduce the CAN speed to 500KHz to have some extra security when not using twisted pair on the cables.
We use an SN65HVD233SOIC8HD as our CANBUS driver which is a standard below 1$ device.
So we consider the cable communication between multiple ESP32s as SOLVED.
The other story is the Bluetooth communication.
Here we need something like with the simple HC-05 devices:
once paired (you do this before and it is stored on the device) you switch them on, they pair automagicly and then you simply use serial.Write() and serial.Read().
Is there a ready made library to use BLE in this manner?
Pair at the beginning (without the knowledge of servieUUIDS and charUUIDs) and then simply something like
BLE.Write(byte) and BLE.Read(byte)
If you have something like this, please tell me and Kolban can get his "Thump up"...
I hope this helps for all cable bound problems and gives us some hints for an easy Bluetooth.
Greetings and merry Christmas
Roland