I want little help from you. Can you suggest me how to create a multiple services in the BLE? & How to advertizing the multiple ble services?
I think same manner we create another service and for advertising loop is required.I am confusing with my idea. Please help me.
Just to clarify:
- Do you want to create multiple BLE services?
- Or do you want to have a BLE service with multiple characteristics?
You don’t need anything in the loop, you just need to start the advertising and all the functions run as callbacks. Regards,
I want multiple services and each service display the value like I am use temperature sensor and gas sensor, etc so right now I am use only one service but instead of that now I want to create each service for each sensor.
Ok, I would probably still just use one service with multiple characteristics. A service usually holds all the data in different characteristics.
For example, if you had 2 DHT sensors reading 2 temperatures and 2 humidity values, it makes sense to create two services (each service having 2 characteristics).
If you want to create multiple services, I recommend starting with the sample sketch that comes with the ESP32 add-on. Open your Arduino IDE, go to File > Examples > ESP32 BLE Arduino > BLE_server.
You’ll need to start duplicating the sections that create the service with a different name:
#define SERVICE_UUID_2 "4fafc201-1fb5-459e-8fcc-c5c9c331914X" #define CHARACTERISTIC_UUID_2 "beb5483e-36e1-4688-b7f5-ea07361b26aX" (...) BLEService *pService2 = pServer->createService(SERVICE_UUID);
You’ll need to duplicate those sections to having two services. Unfortunately I don’t have any tutorial on that exact subject.
I hope that helps!
I am using 2 types of Mobile with different BLE Version
- BLE 4.2
- BLE 5.0
So I just want to know from you, I am use ESP-WROOM-32 module. In datasheet it written Bluetooth 4.2 EDR/BT & BLE.
So it is supported into BLE 5.0 or not?
because in BLE 5.0 mobile it is only show one service and in BLE 4.2 device it shows all service.
I’m glad you were able to make it work with multiple services!
The ESP32 supports BLE 4.2 according to what I can find online. It might be some incompatibility with BLE 5.0… I’m not sure, but I think it should show all the services regardless of the BLE version…