BLE with ESP32 tutorial part 3: many characteristics and Server Callback for Client commands

  Переглядів 7,864

MoThunderz

MoThunderz

День тому

In part 3 of this tutorial we will cover two important features for the ESP32 server, namely:
1) How to use many characteristics
2) How to create a callback function so that the client can send commands to the server
Starting points for coding along:
github.com/mo-thunderz/Esp32B...
github.com/mo-thunderz/Esp32B...
Final code for callback function:
github.com/mo-thunderz/Esp32B...
Final code for many characteristics:
github.com/mo-thunderz/Esp32B...
Create a mobile app for your phone to control an ESP32:
• Create a BLE app for y...

КОМЕНТАРІ: 43
@veedonfleece3694
@veedonfleece3694 Рік тому
Once again, clear and well explained, especially the reason for and logic of the callback. thank you!
@mothunderz
@mothunderz Рік тому
My pleasure, glad you liked it!
@alicizationalicization9621
@alicizationalicization9621 Рік тому
I am now writing a flutter ble app to connect to the arduino. Pretty impressed by your tutorials, APPRECIATE IT
@mothunderz
@mothunderz Рік тому
Thank you for your feedback, happy it is useful! Let me know if you post your code online. I am now making a video on Xamarin and BLE as per request. I have not looked into Flutter yet.
@mothunderz
@mothunderz Рік тому
FYI: just uploaded my video on Xamarin and BLE ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html
@alicizationalicization9621
@alicizationalicization9621 Рік тому
Great video
@davidkempton2894
@davidkempton2894 Місяць тому
Thanks for sharing your knowledge 👍
@mothunderz
@mothunderz Місяць тому
My pleasure
@user-sj3oc3pd9v
@user-sj3oc3pd9v 2 місяці тому
Very well done. You break the process down into small enough chunks to understand the communications between server and client. If I have a system which one of the two devices has to run on battery. And I will be putting the remote device into sleep mode. Would it be best to make that device the server or client, as far as power consumption goes ? I only need to be concerned with communications between those two devices.
@kommzu187
@kommzu187 9 місяців тому
Thank you so much for the videos, it helps a lot! One Question pls. How can I work with the Value in server, that the client sent(notify) with the CharacteristicCallback function?
@mothunderz
@mothunderz 8 місяців тому
Let me make sure I understand the question correctly: you are asking how you can use the value received in the CharacteristicCallback function in the main loop on the server? Basically you can make a global variable, assign it in the callback and use it in the loop. See as well: arduino.stackexchange.com/questions/77882/how-to-get-variable-from-callback-function Hope this helps
@ghislainborremans3708
@ghislainborremans3708 5 місяців тому
Perfect clear explanation. What i miss is a video or tutorial where a ESP32 server sends a long string or array to the client ( on pc or tablet). In my case i want to getthe IMU data grouped in measurements of 100+ points of 9 DOF, added with microphone info. These infos have to be sent every minute. I cannot find a good example on this. If you find the time, that would be great and help a lot of people.
@mothunderz
@mothunderz 3 місяці тому
Thank you very much for your feedback. The problem you raise is indeed not very straightforward. Unfortunately I am completely swamped with work (hence the late response) and I have no time for creating content. I hope this will change in the mid-term, but for now I unfortunately cannot assist.
@jak_k
@jak_k Рік тому
Great video as usual. Fixed my problem running out of characteristics which was also hidden by a problem with App Inventor where creating a 4th RegisterForBytes caused the phone emulator to crash. Unfortunately now registering a 5th characteristicUuid causes it to crash although strangely not if I set it's global to a previous global Uuid. Very frustrating without log files.
@mothunderz
@mothunderz Рік тому
Great to hear that you were able to solve the problem on the server side for scaling characteristics. When you say the phone emulator crashes, do you mean the nRF app? That would be a bit surprising to me as it has been quite stable for me.
@piotrolczyk2679
@piotrolczyk2679 3 місяці тому
Do you have any example of communication between a BLE server and a BLE client in INDICATE characteristic mode. Any hint?
@AtenIndustries
@AtenIndustries Рік тому
Thanks for your tutorials. I learned a lot from this. One question: do I have to create a separate class for each characteristic that I monitor with a CallbackFunction, or can I write all callbacks in one class?
@mothunderz
@mothunderz Рік тому
I have not tried that yet, but it should be possible to use the same callback function for multiple characteristics
@mothunderz
@mothunderz Рік тому
I would recommend to write all callbacks in the same class. You can read the UUID from pChar to figure out which Characteristic was received.
@LinconNS
@LinconNS 11 місяців тому
Hi nice video! Thanks, it helped me so much. Is it possible to a ESP32 server connect to 2 clients? If it is do you have an example code or could you make an video about it? I would appreciate so so much... I want to make an ESP32 wifi gateway, I already tried it with espnow, but apparently it blocks one each oder, perhaps I could use ble instead espnow.
@mothunderz
@mothunderz 10 місяців тому
Yes, it is possible to connect 2 clients to a single server with BLE. However, I have not tested this yet myself. At the moment I am quite busy with work, but will look into it when I have some free time again.
@johantandberg4304
@johantandberg4304 Рік тому
Thank you for yet another great video 👍 I have gotten my server (a Wii Nunchuck communicating over BLE) to work with eight characteristics, as per your tutorial. However, I get kind of the same problem on the client side. It only reads the four first (out of my eight) charateristics, and I can't find any way to increase this, analogus to increasing the numHandles parameter in "createService" on the server side. Do you know how this could be fixed?
@mothunderz
@mothunderz Рік тому
Thank you for your comment. I will look into this, however, I am traveling this week, so it will take me some time
@mothunderz
@mothunderz Рік тому
I just tried to read more characteristics and this worked without a problem. Please refer to my github page for the code I used. It read in all 9 Characteristics without a problem.
@johantandberg4304
@johantandberg4304 11 місяців тому
@@mothunderz Thank you for your swift reply. I have looked at your code in "BLE_client_many_char.ino" and as far as I can see , in the notifyCallback() function you only look for the first UUID. I have expanded upon your code, looking for seven differnet UUID notifications, and only the first four gets detected. Have you tried to detect all nine UUID notifications in the callback function?
@mothunderz
@mothunderz 11 місяців тому
@Johan Thank you for coming back to me with this. I could reproduce the limitation you describe above. I created a server with 8 notifications and could only detect four at the receiver. However, after a bit more investigation I saw that this is a receiver problem -> when I tested with the nRF app as receiver everything was working fine. After (quite) a bit of Googling it seems that the reason is that the ESP32 is limited in HW to receive only 4 notifications. However, I did create a workaround for you. Please navigate to: github.com/mo-thunderz/Esp32BleManyChars and download BLE_many_notify_workaround_server/client. In this example I use one notification to read out 8 characteristics. I hope this works for you.
@johantandberg4304
@johantandberg4304 11 місяців тому
@@mothunderz You are brilliant. Good detective work! And a smart work around, that should work for me, as I control both the server and the client. Thank you for helping me out and for your good videos.
@WeiHuang-kc1zf
@WeiHuang-kc1zf 9 місяців тому
Hi; are we be able to use nordic app upload a video and read that data?
@mothunderz
@mothunderz 8 місяців тому
In general I have only tested with nordic whether the BLE server is setup correctly. It is a very powerful tool, but I have not yet looked into the functionality you are asking for. Hope you find a good solution.
@TOGAMANYAMA-jt7kr
@TOGAMANYAMA-jt7kr Рік тому
Sir, thank you! for your tutorials, I watched your previous tutorials about webpage with json but I stuck to move on this, please! can you give advantages BLE at least 5 to understand?
@mothunderz
@mothunderz Рік тому
My apologies, but I do not understand your request. What do you mean with "can you give advantages BLE at least 5"? Do you mean examples?
@TOGAMANYAMA-jt7kr
@TOGAMANYAMA-jt7kr Рік тому
sorry Sir, am new in these learning, but I need just short written importance of using BLE or anyway Sir if I have questions about previous tutorials can I ask? and where? I worry to comment on past several months, please! help me.
@mothunderz
@mothunderz Рік тому
It is unclear to me what exactly you need help with. BLE is useful for applications where you need to be energy efficient. Wifi consumes a lot more energy but provides a higher bandwidth. As for your question on where to ask questions: best is to ask these with the video that covers that topic. I do check questions with older videos as well. However, please try to be specific. Thank you
@TOGAMANYAMA-jt7kr
@TOGAMANYAMA-jt7kr Рік тому
ok, thank you! Sir, I understand
@shanishah7131
@shanishah7131 4 місяці тому
hi sir I want to connect the esp32 to other esp32 through BLE but i want the server to connect with client manually. and how can i send data from serial monitor by user to the client.
@mothunderz
@mothunderz 3 місяці тому
It definitely is possible to take data from the serial monitor and the forward it through BLE. However, I have not looked into this myself yet. As I am swamped with work at the moment I cannot assist here. My apologies.
@SA-oj3bo
@SA-oj3bo Рік тому
Hi I try to replace the HM10 by the ESP32 BLE, can you help me? I want to use APP's that work with HM10 also with the ESP32 BLE. Stuck now. Can we mail? Thx
@mothunderz
@mothunderz Рік тому
My apologies, but I unfortunately do not have the time at the moment to re-write code from HM10 to ESP32.
@maser9433
@maser9433 Рік тому
could you please share a code, or atleast a resource, for ESP32-ESP32 two way communication(half duplex) via router? I am looking into UDP and TCP protocols but am not able to code on my own.
@mothunderz
@mothunderz Рік тому
Pls check out this series on WiFi with the ESP32: ukposts.info/have/v-deo/aWWJZI2tfpeHyGw.html I still have not had time to make the video on ESP32 to ESP32 communication with WiFi, but that should be relatively straightforward if you follow Part 2 and Part 3 of this series. Am now finishing a video on Xamarin, but will upload it after that.
@josephdallinplania7536
@josephdallinplania7536 Рік тому
The 37th person who liked this vid. Thank you Engr MoThunderz! 💫
@mothunderz
@mothunderz Рік тому
Thank you very much for your feedback! Very much appreciated
Create a BLE app for your mobile phone! Control an ESP32 with BLE
47:04
Espressif’s Bluetooth® Mesh 1.1 Demo
3:47
Espressif Systems
Переглядів 3,5 тис.
Мы играли всей семьей
00:27
Даша Боровик
Переглядів 3,4 млн
GPT-4o Is Here And Wow It’s Good
16:57
AI For Humans
Переглядів 9 тис.
BLE with ESP32 tutorial part 1: the Server
25:23
MoThunderz
Переглядів 71 тис.
ESP32: Webserver, Websockets and JSON (WiFi Part 2) - Arduino
35:17
MoThunderz
Переглядів 73 тис.
Make Your Own Arduino BLE App in Android or iOS with Capacitor
1:22:45
ESP-Now Range Test: Real-World Results for ESP32 Devices!
8:01
atomic14
Переглядів 103 тис.
BLE with ESP32 tutorial part 2: the client
36:07
MoThunderz
Переглядів 27 тис.
ESP32: How to create a config file with SPIFFS or LittleFS
12:46
MoThunderz
Переглядів 10 тис.
Server Components in Client Components?? (React / Next.js)
6:49
ByteGrad
Переглядів 15 тис.