logo elektroda
logo elektroda
X
logo elektroda

BLE communication between ESP32 board and phone (with Android and iOS) - basics of data transmission

CC_PL 735 2
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20503551
    CC_PL
    Level 13  
    I want to do a small project based on an ESP32 development board, along with an encoder and GPS. If I need to give more details I will, but in short:

    The project is to count the revolutions of the encoder and every now and then, when the user presses a button connected to the ESP32 board, an IRQ interrupt will be triggered, which will handle two things:

    - it will send the data - the number of revolutions of the encoder since the last trigger (use of the button),

    and

    - it will send the current coordinates - data from the GPS (at the place where the button was pressed).

    This is the basic functionality I want to get. There will be a few other things, but I don't want to write about them to simplify the description.


    Data will be short strings, a dozen or so characters, max. a few dozen. I want to send information from the ESP32 to the phone via Bluetooth Low Energy (BLE).

    I have already read a bit about BLE, but I have questions for people who have already implemented BLE in the ESP32 for some hints, tips and tricks. The documentation of the protocol is extensive and I don't know a lot of things yet.

    What is the best to use (what "services" to send relatively short strings, how best to solve device pairing, is it worth it and how to put BLE to sleep for a short time - up to a few minutes and your other solutions to problems/hardships you have encountered)?
    UUUID will be permanently stored to facilitate pairing of both devices.

    Thank you for any tips and advice!


    I was thinking of making the ESP32 the server for ease of use, and making the phone the client. Or would a "simple" SPP suffice here? (Simplifying even further, the Beacon functionality would probably suffice, but I'm not entirely sure if that's a good idea). This would probably be enough, although, I don't know if this would work in case of some loss of connectivity / errors - I can't let some of the data not reach the phone, so it would be good to confirm receipt of the data (receipt and correctness, after validation on the phone). I don't know how much to rely on the BLE connection (although the distance between the device and the phone will not exceed a few metres).

    Thanks in advance for your help and hints! .
  • ADVERTISEMENT
  • Helpful post
    #2 20504076
    TvWidget
    Level 38  
    1) In this case, it is best if the smartphone is the client and the sensor is the server.
    2) The SPP profile does not apply to BLE.
    3) The BLE stack ensures data integrity and correctness. Nothing needs to be checked additionally.
    4. Data in BLE can be sent with or without acknowledgement. Everything happens automatically. i.e. the BLE stack takes care of it.
    5. I assume that the device does not have to fit into any existing system. So what services and characteristics you want to use is irrelevant.
    6. The term "pairing" in BLE usually means "connection".
    7. Using the UUID as a device identifier in this application rather does not make sense.
  • #3 20504319
    CC_PL
    Level 13  
    Thank you very much for your replies! I will return to the thread if I have additional questions. And I'm currently checking out the solutions I've encountered on the web.
ADVERTISEMENT