Communication with 2 ESP32 over BLE

pchatill
Posts: 4
Joined: Thu Jul 04, 2019 12:42 pm

Communication with 2 ESP32 over BLE

Postby pchatill » Mon Jul 15, 2019 6:15 pm

Hi.
I would like to have one ESP32 reading a sensor, sending the value to the second ESP32,
then second ESP32 sending acknowledge to first one.
I thought it was a basic function, but I spend days to find example or a tuto.
I found examples sending datas to smartphone only.
I'm new to ESP and BLE, so I tried to modify the arduino Ble examples, but with very small succes....
What are the basics to start to do that?
I succeed to send values (with ble_notify on the first one and ble_client on the other one), but how can I send the acknoledge?
And how the second one can request the first one to send values?
Anybody have a complete example?
Thanks!

Aussie Susan
Posts: 45
Joined: Thu Aug 22, 2019 3:48 am

Re: Communication with 2 ESP32 over BLE

Postby Aussie Susan » Thu Aug 22, 2019 4:12 am

It might pay to start using the standard terms.
I think the device that takes the sensor readings would be the 'server' and the other device would be called the 'client'.
Also the type of communication and acknowledgement you describe is called an 'Indicate' (which is like a notify but with an acknowledgement).The advantage of an indicate is that it can send the data whenever it likes (just like a notify). The disadvantage is that it will wait for an acknowledgement or a timeout but with the radio active all the time.
If you want the client to request information from the server then you need to use a 'read'.
Of course all of the above require a connection first. If you just want the client to send out the data regardless then you can use a 'beacon'. This does not require a connection (it is just a blind 1-way transmit). An alternative is to put the value into the advertisement packet.
If you go down that path, then you can let the server just keep sending as it needs to but then get the client to connect to the server and perform a 'read' (or some other operation) to indicate that it has got that value so the server can (perhaps) read a new value.
As for the examples you have found that only send to a smartphone, that does not really matter - at least from the servers point of view. The advantage of a protocol such as Bluetooth is that it defines how the devices interact but does not care what the devices are on each end. If you can send to a smartphone, then you can just as easily replace that with any other client that implements the Bluetooth protocol.
Susan

Who is online

Users browsing this forum: No registered users and 10 guests