how to connect two esp32 boards

minimax
Posts: 1
Joined: Mon Oct 02, 2017 9:14 am

how to connect two esp32 boards

Postby minimax » Mon Oct 02, 2017 9:57 pm

Hi all,
I am new to esp32 world and I usually use arduino for my projects. With multiple arduino boards projects I usually use I2C for interconnection with one board in the master mode as an orchestrator and and other in slave mode. But I learnt that esp32 doesn't yet implemented I2C slave mode. If I'm right, what is the most appropriate interface for a wired connection for a couple or more esp32 boards?

Resch2061
Posts: 40
Joined: Mon May 01, 2017 1:56 pm

Re: how to connect two esp32 boards

Postby Resch2061 » Tue Oct 03, 2017 12:27 pm

https://esp-idf.readthedocs.io/en/v2.1/ ... ight=slave

The SPI drivers allow slave functionality. Maybe it'd be possible to achieve the same with this? I'm not quite sure.
I'm just thinking aloud, but maybe it'd be possible to use the UARTs to achieve the same?

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: how to connect two esp32 boards

Postby loboris » Tue Oct 03, 2017 2:09 pm

Why not use WiFi or Bluetooth? No wires needed.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: how to connect two esp32 boards

Postby kolban » Tue Oct 03, 2017 3:23 pm

Just the other day I had a user ask about Bluetooth (BLE) communication between two ESP32s and we tested it out and it seemed to work just great.

Just a data point to also give a thumbs up for BLE and some evidence that others are also using BLE for ESP32 to ESP32 communications.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

robpelu
Posts: 4
Joined: Fri Dec 29, 2017 5:57 pm

Re: how to connect two esp32 boards

Postby robpelu » Fri Dec 29, 2017 6:09 pm

I just arrived here while looking for the same, but in my case BLE or wifi is not an option, because as I'm not able to use BLE and Wifi at the same time in my ESP32, I will have to use two boards, one with wifi and the other one with BLE, then comunicate both via some cabled protocol.

I was thinking USART, SPI or I2C as some of you mentioned above.

BR, Robert.

Update: 22/04/18
Actually after tweaking the config file and taking care of using just small buffers got it working. Mostly it was a case of RAM memory.
I'm now considering using the WROVER board that has more RAM.
Last edited by robpelu on Sun Apr 22, 2018 11:31 pm, edited 1 time in total.

DowJohn
Posts: 1
Joined: Wed Jan 03, 2018 3:19 pm

Re: how to connect two esp32 boards

Postby DowJohn » Wed Jan 03, 2018 3:21 pm

kolban wrote:Just the other day I had a user ask about Bluetooth (BLE) communication between two ESP32s and we tested it out and it seemed to work just great.

Just a data point to also give a thumbs up for BLE and some evidence that others are also using BLE for ESP32 to ESP32 communications.
Is there a discussion on that or a description you can give me for that?

Thank you very much.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: how to connect two esp32 boards

Postby kolban » Thu Jan 04, 2018 1:55 am

Howdy @DowJohn,
BLE is a bluetooth protocol used to transmit relatively short packets of information. An ESP32 can be either a BLE client, a BLE server or both. If you have two ESP32s, one can be a BLE Server, one a Client and they can exchange data between each other.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Roland.Stiebel
Posts: 2
Joined: Sun Oct 28, 2018 3:48 pm

Re: how to connect two esp32 boards

Postby Roland.Stiebel » Mon Dec 24, 2018 11:29 am

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

Who is online

Users browsing this forum: No registered users and 117 guests