Create a BLE app for your mobile phone! Control an ESP32 with BLE

  Переглядів 49,426

MoThunderz

MoThunderz

Рік тому

Summary:
In this video I show you how to create your own Bluetooth Low Energy (BLE) App to control an ESP32 (Arduino platform). For creation of the app I use the MIT app inventor in combination with the MIT AI2 Companion. I have tested this on an Android phone. I have heard in the meantime that unfortunately MIT App Inventor does not support BLE for the Iphone yet. Please make sure your ESP32 has Bluetooth to make this work. Note that some older ESP32 will not work with MIT App Inventor.
Confirmed to work on:
ESP32-WROOM-32D
ESP32-WROOM-32 (Mini D1 ESP32)
Does not work on (will not connect):
ESP32-WROOM-32 (some of the older versions)
NOTE: In order for the App to work as compiled .apk file, the "BluetoothClient" element needs to be added to the MIT App Inventor project (can be found in the "Connectivity" section). I forgot to mention this in the video.
Starting point for coding along for the Arduino is:
github.com/mo-thunderz/Esp32B...
Final code:
github.com/mo-thunderz/BleMob...
MIT App Inventor:
appinventor.mit.edu/
MIT App Inventor BLE extension:
mit-cml.github.io/extensions/
BLE on ESP32 Tutorial:
• BLE with ESP32 tutoria...
• BLE with ESP32 tutoria...
Might you have problems programming the ESP32, pls refer to:
• Programming ESP32: how...
Have fun with the code and let me know in the comments below what application you are working on :-)
Correction:
6:36 Under "Connectivity" add also the "BluetoothClient" to the project. This is needed so that the app can ask for the appropriate permissions when compiled.
32:06 I mis-spoke here. The correct number to multiply the third byte with is 65536 (2^16).

КОМЕНТАРІ: 184
@Galeazzi2006
@Galeazzi2006 4 місяці тому
Awesome! One of the best ESP32 BLE video on youtube
@mothunderz
@mothunderz 3 місяці тому
Thank you very much!
@domebevi
@domebevi 16 днів тому
FIX for people having issue with sending data from app to esp32: I followed every step (nice job mate), but my app was crashing with no error whenever I tried to send data (after changing the slider position). So I've tried different things, apparently what works is to stick with only one characteristic, add the write and read property and the callback to it, and of course use the same UUID for both receiving and sending functions in the app inventor. Do know why, maybe it's my cheap phone, but it worked for me
@davidkempton2894
@davidkempton2894 Місяць тому
Crikey! That was very very good. Thanks very much for sharing your knowledge in this very clear and concise video.
@mothunderz
@mothunderz 20 днів тому
Glad it was helpful!
@fatih_basaris
@fatih_basaris 5 днів тому
Thanks a lot from Turkey. Explanation is really good. I really appreciate your works..
@geralltgriffiths7772
@geralltgriffiths7772 Рік тому
An absolutely indispensable guide, expertly explained! Thank you. (Just to show that I was paying attention -- and I hesitate to mention it -- but 2^16 is 65,536, not 56,536).
@mothunderz
@mothunderz Рік тому
🤣 Amazing how I manage to say it wrong while writing down the right number Thank you for your feedback!
@geralltgriffiths7772
@geralltgriffiths7772 Рік тому
@@mothunderz With the screen resolution I had, I couldn't quite see what you wrote, so I was going by the audio only. I suspect that it has much to do with the old chestnut of German being fünfundsechzig, whereas English uses sixty-five. (Apart from arcane use, like in the old nursery rhyme, were "four and twenty blackbirds were baked in a pie" -- the things we teach our kids leave much to be desired!). Thanks for all the great work. It's much appreciated.
@mothunderz
@mothunderz Рік тому
I never quite figured out why in many European languages we pronounce numbers in such a weird way, but yes, most likely that is where this came from :-)
@user-wy8jc8gx1y
@user-wy8jc8gx1y 13 днів тому
You are the goat. You just saved us so much time and it actually worked.
@leighpringle286
@leighpringle286 8 місяців тому
Thanks so much! Big help in learning how to do this. My project is for an automotive security product.
@mothunderz
@mothunderz 7 місяців тому
Glad it helped! Thank you for your post :-)
@hernandobolanos798
@hernandobolanos798 2 дні тому
Good tutorial. The APP is available in MIT app Inventor Gallery?
@user-hf5ts2cv6h
@user-hf5ts2cv6h 8 місяців тому
Very good and interesting explanation! I am just working on Smartphone connected to ESP32 to open Garage door as for exchange an old remote control!
@mothunderz
@mothunderz 8 місяців тому
Thank you for your feedback. That is an excellent application :-)
@marcobuttner6357
@marcobuttner6357 2 місяці тому
Tested on ESP32-WROOM-32 (Mini D1 ESP32) and Samsung S23+ today. Works fine for me. Thank's for this great tutorial!
@mothunderz
@mothunderz 20 днів тому
Thank you for the feedback!
@ernestorivero9909
@ernestorivero9909 7 місяців тому
Very good video, you have some to send text from the phone to esp32
@mysporelo
@mysporelo Рік тому
Well this series is going amazingly! I've found your channel because I was looking for exactly this, a mobile app that communicates with esp32! Since I didn't expect for you to make just what I needed I launched myself into doing an app of my own in ReactNative, which works fine, but... I'm actually having a problem with the communication, and since you did this tutorials I think you probably can help me or at least point me in a direction that leads to an answer: Using your previos video example (the BLE sending a increasing number) I've modify it a bit so it reads a sensor value that goes from -127 to 127, and it works fine until the sensor (correctly sensing, btw) reads many data together, but never as fast as the 3ms that the example code says. The thing is, when it happens, the esp32 freezes and stops. Only a reset un-freezes it. Do you happen to know what could be? It's not the sensor because without the BLE it never happens.. Thanks a lot for the time you take in doing this guides, I really love them!!
@mothunderz
@mothunderz Рік тому
Thank you for your feedback. BLE is not the best with "fast" communication. The 3ms was the absolut minimum that can be achieved with two ESP32s communicating together on one single Characteristic. If you add more complexity to the code, the required delay between packets will definitely go up (especially if your packets are more than just 1 to 4 bytes). What I would recommend it that you implement a minimum time for BLE packets to be sent. You can vary this time to see if the communication stabilizes with for instance 100ms or 500ms buffer time. If it still does not stabilize with such buffer times, then definitely something else is wrong. I found it often can be simple things such as that you added a characteristic that is not known on the other side or something like that. Hope you find what the problem is!
@a_boy_can_dream
@a_boy_can_dream 5 місяців тому
Thanks so much!
@mothunderz
@mothunderz 3 місяці тому
you are welcome!
@jak_k
@jak_k Рік тому
Just something to note and I may have missed you covering it, is that BLE scan doesn't work unless you allow MIT App Companion permission to access your precise location! At least on a Pixel 5. Even the Emulator didn't work until I clicked on allowing location permission. The permission request may have flashed on the screen but only briefly. Please keep up the good work with your excellent videos. I am trying to use your code as a basis for a small 6V solar panel meter using an ESP32-C3 although about to modify my board due to a tiny screwup with the voltage supervisor.
@mothunderz
@mothunderz Рік тому
Thank you for your comment! Yes, some Android platforms do require location information when bluetooth is used. As far as I understood this is not caused my MIT App Inventor, but rather a requirement from the Android platform itself. Indeed on my samsung s22 I have to have GPS enabled as well for ble to work. Good luck with your project!
@GameChanger77
@GameChanger77 11 місяців тому
Yeah, precise location is required for bluetooth on android except for some of the older versions.
@ming-huiChen-pl7lg
@ming-huiChen-pl7lg 2 місяці тому
First of all, thanks for such a great video. It is very helpful to understand from the scratch. I have a question. It seems like that the App will disconnect with ESP32 after awhile (phone screen off awhile). I have to re-scan and connect to ESP32. Is it possible to keep it connected? Thank you so much!
@ernestorivero9909
@ernestorivero9909 7 місяців тому
Muy bueno el video,tienes alguno de mandar texto desde el teléfono al esp32
@cliffs6479
@cliffs6479 7 місяців тому
First let me thank you for a great tutorial, my question is, I have been working with the bluetoothserial library and wondered if this project could be adapted for it?
@mothunderz
@mothunderz 7 місяців тому
Yes, it is definitely possible to change from Bluetooth serial to BLE. Hopefully you can understand from my video how to send and receive and then adapting the code should be relatively straightforward.
@erenkaya5371
@erenkaya5371 10 місяців тому
Thank you for this great series. I wonder if it is possible to use this same ESP board as a client simultaneously. I mean, in this same system the ESP32 will get sensor readings from another BLE device (server) and send it to mobile app. Although I am not expert, this may be possible with multitasking via FreeRTOS. Another small demonstration of this would be great.
@mothunderz
@mothunderz 10 місяців тому
I have so far not looked into FreeRTOS. While it might be possible to create a BLE server and BLE client at the same time, there is a way simpler solution and that would be to communicate with your sensors using BLE and with your mobile phone through Wifi, for this, see: ukposts.info/have/v-deo/fHV3hImdg4iAw58.html (and the explanation of the code starts here: ukposts.info/have/v-deo/aWWJZI2tfpeHyGw.html)
@veedonfleece3694
@veedonfleece3694 Рік тому
Once again, very clear and helpful. In my project I am trying to switch (in the client,) between the data feeds from 2 connected BLE servers. It seems to be possible? If I understand correctly there can be many connected servers at once, depending on chipset used and memory, etc?
@mothunderz
@mothunderz Рік тому
Thank you for your feedback. So if I understand correctly you want to connect with one phone to multiple ESP32 servers? Yes, in principle this is possible, however, I have not tried this with MIT App Inventor yet. From what I have seen, the MIT App Inventor library for BLE works, but is not 100% mature. I would not be surprised if multi-server connections have not been implemented .
@rodrigomatos7267
@rodrigomatos7267 27 днів тому
I'm very happy for discover yours videos, Thank you for a graet contribution. Do you know if is possible using this app or esp32 conect direct to a smartband to get data from heart beat? thank in advanced...
@absabs6481
@absabs6481 Рік тому
Good job bro. Thank you very much. I'm following. The eyes are a little weak, I hope I can handle it. Good luck. Greetings at friends who follow you
@mothunderz
@mothunderz Рік тому
Thank you very much for your feedback! Well appreciated
@TNHT_rnd
@TNHT_rnd 3 місяці тому
Hi, great video. I want to send a text from android app to BLE, how to setup translate from bytes to text on MIT app inventor ? All i recieve is a array of decimal number but i cant find a way to process them in MIT app.
@Chris_Mn
@Chris_Mn 7 місяців тому
Hi great video, it is veru helpfull for me , I'm doing a little rc car, it is really small so im using the xiao esp32, but the BLE dfficult to make an application
@mothunderz
@mothunderz 7 місяців тому
Glad it helped, good luck with your project!
@bartdenturck5134
@bartdenturck5134 5 місяців тому
First, BIG thank you! just what I needed, or almost. Now the question of course. What if you have two sliders p.e. that send data (not together of course). I see nowhere in the CharacteristicCallBack class a way to differentiate between UUID's of chars from the app.
@mothunderz
@mothunderz 5 місяців тому
Hi Bart, you can check in the callback function what UUID the data was sent from. See for instance: github.com/mo-thunderz/Esp32BleServerCallback/blob/main/Arduino/BLE_client_2characteristics/BLE_client_2characteristics.ino
@bartdenturck5134
@bartdenturck5134 5 місяців тому
Thank you! I found out overnight myself too :-) Took me a while to get the code right but it is an elegant way indeed.
@user-do5kh3nf3i
@user-do5kh3nf3i 7 місяців тому
@7:40 Could you please mention the reason for adding a custom permission name in the form of a text "BLUETOOTH_CONNECT". I see that the inbuild permission name list also have a permission name "BluetoothConnect". Could you please clarify on why that was not used. Thanks in advance.
@mothunderz
@mothunderz 7 місяців тому
I tried to use the inbuild one, but that did not work for me at the time. Please try and let me know if it works for you.
@randallyoung6715
@randallyoung6715 5 місяців тому
Thanks for posting, this is a tremendous help to my project.
@mothunderz
@mothunderz 3 місяці тому
Great to hear, thank you for your feedback!
@csongorvarga
@csongorvarga 2 місяці тому
Thanks a lot for this. I have an ESP32 which measures a few data points and I want to log it to a CSV file. I was thinking about ESP32 with a SD card reader, but I rather transfer the data over BT to have the phone log the data into CSV. My values will be float values but only with 1 decimal place precision, therefore I was considering pushing them over as integers. All my values should fit into 2 bytes and I can easily split them up in the app. I did not watch you first video, I hope that explains how to define what data type a characteristic is. Or that is always assumed to be byte list? I assume there is an option to install the app permanently on the phone eventually.
@csongorvarga
@csongorvarga 2 місяці тому
I watched your part 1 video and I got answers to these questions. I modified the Arduino code to send multiple values in an array over the same characteristic and it works fine. CSV export in the Android app is working fine as well. So I am very happy.
@mothunderz
@mothunderz 20 днів тому
Great to hear you got it all working and good stuff you were able to solve the problem yourself!
@minkduchoangduc5630
@minkduchoangduc5630 9 місяців тому
Great video! Could you please suggest the way to plot the receiving BLE data?
@mothunderz
@mothunderz 8 місяців тому
Great suggestion. At the moment I am a bit overloaded with work, but as an intermediate solution you might want to use a WEB interface instead: ukposts.info/have/v-deo/fHV3hImdg4iAw58.html
@unpredictable14686
@unpredictable14686 8 місяців тому
Thank you for this great series, I want know will it work with ESP32 WROVER IE ? I have tried with ESP32 WROVER IE but not able to connect with ESP32. I could get data on nRF Connect & BLE Scanner App.
@mothunderz
@mothunderz 8 місяців тому
Thank you for your feedback. I dont have the ESP32 WROVER IE myself, so have not tested this version myself, but as said in the description, there are some models where the "connect" does not work. As far as I have understood this is predominantly on the older ESPs. I used the ESP32-WROOM-32D myself.
@user-bj8fd3rk8q
@user-bj8fd3rk8q 6 місяців тому
Thankyou for this videos. I want to ask question, recently I am trying to build a project in which I am using BLE sensor known as TPMS(Tire Pressure Monitoring System) with ESP32 or Arduino Uno. If i use ESP 32 then how can i see the uuid of the BLE sensor? . Also If i used Arduino Uno then I have to used Bluetooth module which has different programming as compared to ESP32. I only need to know how can i captured the data from the BLE sensor ? IF you can assist me in this I will be very thankful for you. :)
@mothunderz
@mothunderz 5 місяців тому
I have not looked into this, but for BLE basics I recommend this video series: ukposts.info/have/v-deo/aImnmJWiZ56Tt6c.html
@user-dg5ji9gh9p
@user-dg5ji9gh9p Місяць тому
if I want to transmit bytes and then drive the motor to rotate. How should I do this? Thankyou
@Soundlmpact
@Soundlmpact Місяць тому
what if you dont know the uuids of the device you connect to? edit: ok nvm, I just watched your other BLE videos, all clear, thank you for the videos!
@JeahBee66
@JeahBee66 4 місяці тому
Hi Mo, You ask for our projects. I'm creating a control for a greenhouse in which mushrooms will grow. Thank you for your educational videos. They are very clear and understandable. ciao Joerg
@mothunderz
@mothunderz 3 місяці тому
Hi Joerg, What a fun project, thank you very much for your feedback. I with you all the best and hope the project worked out for you! ciao Sander
@user-co8eq6xu6d
@user-co8eq6xu6d 3 місяці тому
Hello, first of all, sorry for my english, it is not my native language, With a lot of interest I pulled in all of your videos (several times): Im exactly looking for such program to get my IOT boards connected to a smart phone. Thanks a lot for this lessons and the time you spent. I followed your instruction to import the extension for BluetoothBLE. While connecting to my iphone13 with iOS 17.1.2 I received the message: Extensions are not currently supported by iOS devices. Do I something wrong here, is there a work around ?
@mothunderz
@mothunderz 3 місяці тому
My apologies, but unfortunately MIT app inventor is not available for iphone. As I dont have an iphone myself I dont have the right code for that...
@sagarmulagund9256
@sagarmulagund9256 2 місяці тому
hello sir, Can you make it for the wifi scan and connect to entered ssid and password and make user to control led?
@PaulCan2006
@PaulCan2006 7 місяців тому
Hi Mo,working using a BLE and wondering if you can assist me please. I just want to send AT commands over to the BLE without using arduino - serial over BLE.
@mothunderz
@mothunderz 5 місяців тому
If you want to use serial Bluetooth, please refer to: ukposts.info/have/v-deo/mX1jn6qEgnemz6s.html (part 1 to 3)
@dhanushkawijesinghe4393
@dhanushkawijesinghe4393 7 місяців тому
Hi, I am using this tutorial and build a app to connect my ESP32 via BLE. When I click scan devices, it shows me a whole bunch of BLE devices. But if I use inbuild nrf connect app it only shows a very few BLE devices. Further, when I click on my ESP-32 server in the list, it doesn't connect to the device. Is there any particular reason? anyone can help please.
@mothunderz
@mothunderz 5 місяців тому
My apologies, but it is from your description not clear to me what exactly is going wrong in your case.
@olaabrahamsson9441
@olaabrahamsson9441 5 місяців тому
Thank you for a nice and very clear review. Unfortunately, it doesn't seem to work from Android version 12 and up. There will be problems with security and permissions. You can see but no connection takes place.
@JLaurel
@JLaurel 4 місяці тому
in Android 12 and up you should not ask for permission to bluetooth_connect or bluetooth_scan, it's dome automatically. Remove the Block Screen1.PermissionGranted, and from Screen1.Initialize remove the call for BLUETOOTH_CONNECT and it's working. I had the same problem and did an intensive research and found out this... now it works. And don't forget to give MIT App Companion permission to access your location!
@mothunderz
@mothunderz 3 місяці тому
Thank you Laurel for answering here!!
@ernestorivero9909
@ernestorivero9909 7 місяців тому
I am confused and I would like you to clarify if I send text or message from a cell phone to an esp32 so that the esp32 shows me on a screen who is the server and who is the client, clarify that I am confused to know that code to load the esp32 if the server or the client
@mothunderz
@mothunderz 5 місяців тому
My apologies for my late reply, I have been very busy. One can use the WriteStrings function in MIT App Inventor to send strings from the mobile phone to the ESP32.
@quadepchai
@quadepchai Місяць тому
Hello friend, im from Vietnam, I am participating in a contest and I have a question and need your help. I want to create a touch application on the phone, meaning that when the phone receives a signal from the BLE device, it will go to a layout or screen available on mitapp. Do you think this is possible?
@cristian980t
@cristian980t 3 місяці тому
Hello MoThunderz, do you plan to make an web app that uses web ble and do the same as in the android app, by the way, your videos are cool, I like them.
@mothunderz
@mothunderz 20 днів тому
Thank you very much for your feedback. Unfortunately I am overloaded with work at the moment and cant make any YT videos :-/ However, once my work load improves I will look into this :-)
@anguilla301
@anguilla301 12 днів тому
hi this video helped me a lot but I still have an issue: I would like to receive data from an esp32 even when the phone is off or when the app is in the background, do you have any advice for this?
@anguilla301
@anguilla301 12 днів тому
I'm actually creating an app which receives a message from the esp32, and if the message is equal to a certain thing, it makes a phone call. I would like that it makes the phone call even if the phone is off or the app is in the background, so that I just have to plug the esp32 in and just wait for the call. I would really appreciate if you know how to solve this problem :)
@mubasirkhafid9582
@mubasirkhafid9582 6 місяців тому
hi siri is it possible if communication using ble takes data from esp32 real time
@mothunderz
@mothunderz 3 місяці тому
Yes, that is definitely possible. Here an example with a web browser and real-time data. You can do the same with BLE: ukposts.info/have/v-deo/fHV3hImdg4iAw58.html
@user-ke2ih7xr5g
@user-ke2ih7xr5g 29 днів тому
i am useing same library for esp32 but it showing name in NRF app in IOS but not showing in IOS Bluetooth setting place help me. i tried your code also but it not show name in ios Bluetooth setting.
@marwan.naasan
@marwan.naasan 10 місяців тому
Hi, Great video, what if i want to connect to my ESP32 auto ? without list and chosing the Bluetooth.
@mothunderz
@mothunderz 10 місяців тому
Thank you for your feedback. In case you want to automatically connect to a certain Bluetooth interface, the easiest would be to skip the whole list and use the ConnectWithUUID function. You can find this function by clicking in MIT App Inventor on the Blocks page on BluetoothClient1 on the left (part of Screen1). I have not tried this function myself yet. It might just continue scanning until it finds the BT interface with the correct UUID, or you might need a clock to periodically run this until it can connect.
@marwan.naasan
@marwan.naasan 10 місяців тому
@@mothunderz Thank you for your response to your followers' questions. In fact, I'm having a problem running the application...because whenever I want to try it, it shows errors as it appeared to the rest of the users as they wrote on your channel, but I may dispense with this matter after I explain to you what my project is exactly, I have an ESP32 I want to make Bluetooth somewhat safe because I will be controlling a real car, so it is a matter of safety... Now I have relied on the Bluetooth serial library.. There is no PASSKEY for Bluetooth and this is what makes anyone connect to it.... Also, do not forget that the messages sent are a One letter is easy to guess.... What do you think is the solution to my problem? Is BLE technology safer? (Sorry about my language, I use translation)
@mothunderz
@mothunderz 9 місяців тому
First of all I would not use MIT App Inventor for a project like that. MIT App inventor is great for fast prototyping, for switching on some lights or doing home automation, but not for an application with a car. Either you should use a more professional App development environment like react native, Maui, etc, or you should consider using wifi like I show in some of my other videos.
@marwan.naasan
@marwan.naasan 9 місяців тому
@@mothunderz I apologize for my long comment, but I am a beginner in the application industry... Is react native and the development environments you mentioned easy to use? Can it be learned quickly? I've been learning kotlin for a while and it's not easy to be honest
@marwan.naasan
@marwan.naasan 9 місяців тому
@@mothunderz Thank you for your interest. I actually managed to design it using the MIT app. The approach I used was slightly different from yours, and I'm surprised that your method didn't work. However, I'm currently facing some challenges. But before I discuss them, I want to mention that I've uploaded a brief video on my channel demonstrating the car control process. Feel free to watch it if you're interested. One of the issues I encountered is that the Bluetooth connection remains open, allowing anyone to pair with it. I addressed this problem by setting a 6-digit Bluetooth password. However, here's the strange part: even without pairing, I discovered that I can retrieve the UUID using an application that displays numbers and codes. This compromises the car's security. Although I implemented complex operational commands with long numbers that are nearly impossible to guess, I'm concerned about this vulnerability. What are your thoughts on this matter? How can I solve this problem and conceal the UUID from devices that aren't paired with Bluetooth?
@kelleyga
@kelleyga 3 місяці тому
Great Video thanks. I followed very closely and everything works, except: When I move the slider I get the message on the phone "The variable $Slider_var is not bound in the current context". Also, no data shows up on the serial monitor. The data from the ESP32 shows up as expected on the phone app. I would appreciate any help!
@kelleyga
@kelleyga 3 місяці тому
Disregard! I improperly constructed the Initialize local variable block. Everything good now.
@mothunderz
@mothunderz 20 днів тому
Great to hear it works!
@rittol2365
@rittol2365 8 місяців тому
Can you try to do this with actual android studio, the docs are terrible and the old videos do not work because the methods are depreciated
@mothunderz
@mothunderz 8 місяців тому
Unfortunately I am a bit overloaded with work at the moment, so have not yet had the time to look into this.
@stevedevspace6970
@stevedevspace6970 2 місяці тому
hiya, just such a great help .. im trying to achieve a specific task and have a lot to do, and having to write an app is the last thing i need to be doing lol .. so app inventor is going to speed things up a LOT .. however, you have kindly uploaded your bluetooth aia file for reference and i just CANT get it to upload - it says its not a correct file type .. i tried zipping it as well .. and using its url as a repository .. any ideas? .. just to save me a little bit of a mountain climb :)? kindest regards - steve
@mothunderz
@mothunderz 20 днів тому
The aia file is to be imported in MIT App Inventor. Can you confirm that that is what you have tried to do? Or did you try to open the aia file with the Arduino editor? that wont work... Regards, Sander
@MrRichn01
@MrRichn01 5 місяців тому
Hell, great video, would you no how to make it work for Ios? Says the Ios does not suport extensions. Thnakyou
@mothunderz
@mothunderz 3 місяці тому
Thank you very much for your feedback. My apologies for my late reply, I am swamped with work at the moment. What do you mean with los? Loss of Signal?
@krcao9511
@krcao9511 Рік тому
is it possible to connect a esp32 ble to arduino nano 33 ble sense via ble?
@mothunderz
@mothunderz Рік тому
I have not tried to do this myself, but I see no reason why this would not be possible. Have you watched my video on esp32 to esp32 communication? The communication with a nano 33 will be quite similar: ukposts.info/have/v-deo/q2Oqo5CYbaGr1qc.html Good luck with your project!
@jak_k
@jak_k Рік тому
I have a problem when trying to create more than 4 Characteristics. Using your BLE_Server code if I copy CHAR1_UUID renaming as _3, _4 etc the first 2 copies create Characteristics but more than that fails. So far after several days I am at a loss as to why. Grateful for any help. I did see a 5th Characteristic but that disappeared after I added the Descriptors and even without a 6th can't be created.
@mothunderz
@mothunderz Рік тому
I was able to reproduce the issue and the solution is quite simple. Just make sure you first define all the descriptors before you define the callbacks, so for instance: pCharacteristic->addDescriptor(pBLE2902); pCharacteristic_2->addDescriptor(new BLE2902()); pCharacteristic_3->addDescriptor(new BLE2902()); pCharacteristic_4->addDescriptor(new BLE2902()); pCharacteristic_5->addDescriptor(new BLE2902()); and then pCharacteristic_2->setCallbacks(new CharacteristicCallBack()); This should work up to 15 Characteristics. If you need more than that, than you should add the maximum number of characteristics in the service definition, so here: BLEService *pService = pServer->createService(SERVICE_UUID); This will become: static BLEUUID BLESERVICE_UUID("4fafc201-1fb5-459e-8fcc-c5c9c331914b"); // this line right below the #define statements at the top BLEService *pService = pServer->createService(BLESERVICE_UUID, 30, 0); // the "30" in this statement defines the max number of characteristics, feel free to increase. Hope this is understandable for you. I can cover it in my next BLE video as well.
@mothunderz
@mothunderz Рік тому
Actually, I need to correct myself. I did some more investigations and you always will need to extend the max number of characteristics to make this work. Please see my latest video where I specifically address this topic: ukposts.info/have/v-deo/sqikk5Vveq-cpXU.html
@jak_k
@jak_k Рік тому
@@mothunderz ok, thanks. I did a quick test but no joy but I didn't yet try extending the number of characteristics. I will also let you know the result with creating more services as that did get around the problem but probably also related to max numbers limit. I should get to this at the weekend.
@Steve98345
@Steve98345 40 хвилин тому
Doesn't work at all on my Samsung s22+. App just crashes out when you connect. Never did get it working
@GameChanger77
@GameChanger77 11 місяців тому
I would like to write the app in java with Android studio or something, can you provide some information on how to do this?
@mothunderz
@mothunderz 11 місяців тому
It is not very common to write Java with the ESP32. I personally have not done this yet, but looked around for you a bit. It seems that MicroEJ has a solution here that could work for you: developer.microej.com/create-your-first-application/get-started-app-development-on-espressif-esp32-wroverkit-v41/ However it is unclear to me if this solution has a license fee to it. Please check it out for yourself. Would be great if you could post here if it worked out for you.
@GameChanger77
@GameChanger77 11 місяців тому
@@mothunderz Thanks for the response! However, I think you may have misunderstood my question. Instead of writing the android app with MIT app inventor and blocks, I would like to use java in android studio. I'm just not sure how to write the Bluetooth code in Java. I am totally fine with using the arduino IDE in my project, and I am already using it. Thanks!
@mothunderz
@mothunderz 11 місяців тому
Ah, that makes a lot more sense :-) Sorry, totally understood that the wrong way. I have not looked into java in android studio, but recently uploaded a video on how to implement the Bluetooth code in Xamarin: ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html Xamarin really works nicely for me. At the moment that is all I can contribute on this topic. Will ping you if I get around to implementing it in Android Studio as well.
@janani.p.gjanani1028
@janani.p.gjanani1028 Місяць тому
I can't able to see my esp32 on my list view😢is there any solution
@sdranju
@sdranju 6 місяців тому
Is it possible to show Android native app example other than MIT App Inventor. I got it working with MIT App Inventor but failed to make it working in native Android (Java) app. App is not connecting to ESP32.
@mothunderz
@mothunderz 5 місяців тому
The only other app I have looked into myself is Xamarin: ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html However, there are many other implementations online
@gearsssssable
@gearsssssable 4 місяці тому
I have a problem. I tried with de first block code when the app only show the devices list, but it never find any bluetooth device. I conced permission to use bluetooth and the precise location. Any idea? :c Note: using the tradicional BluetoothClient the app show the list of paired devices, but when i tried to connect with ESP32, the app shows me the error 507 like ESP32 was off
@mothunderz
@mothunderz 3 місяці тому
It is a bit tricky to debug remote. But lets try: are you using Android or Iphone (only Android works). Which version ESP32 are you using exactly? Have you tried this final code? github.com/mo-thunderz/BleMobileAppMitAppInventor
@davidleswell8115
@davidleswell8115 10 місяців тому
Hi , could you help, i am getting no serial output from the Arduino serial monitor .
@mothunderz
@mothunderz 10 місяців тому
Hi, this is a very basic problem. The BLE code is quite advanced, you might want to first get some experience with arduino/esp before trying to implement this. But anyway, I assume you are using the Arduino IDE for programming? In that case, make sure you open the serial monitor to the correct serial port. Another thing you will run into is that the esp will not continuously write to the serial port. As such first program the esp, then open the serial monitor and then restart the esp with the reset push button.
@sridevipindi1547
@sridevipindi1547 8 місяців тому
can u show us in espressif ide pls
@mothunderz
@mothunderz 7 місяців тому
Thank you for your feedback. So far I have not had the time to look into espressif ide... its on my list though...
@ttoscanoqui
@ttoscanoqui Місяць тому
Hello friend, help, I get a permission not granted error. I am up to minute 12, in the first test of the app, and I get that it does not grant the Bluetooth permission
@JeahBee66
@JeahBee66 4 місяці тому
Hello Mo, I send and receive several variables to and from the ESP32 without any problems. But I also have variables that have to be sent by the ESP32 after the connection has been established and then sent back again after they have been changed in the app. I think this should work with one UUID. Do you have a solution for this? regards Joerg
@mothunderz
@mothunderz 3 місяці тому
Yes, you could do that with a single UUID, but why not take two UUIDs -> one to send and one to receive. That way you dont get confused. See the "Server Callback" section here. That should help with the return path: ukposts.info/have/v-deo/sqikk5Vveq-cpXU.html
@JeahBee66
@JeahBee66 3 місяці тому
I don't think that is a good idea with 2 ids for 1 variable @@mothunderz
@fabrizionovello
@fabrizionovello Рік тому
Hello. Thank you for the tutorial. I can't get the app to ask for permission to scan o connect to bluetooth devices, when the app starts I get a message with error 908 saying that the permission has been denied and that I need to enable in the settings, but I can't do that either. I'm using a moto g51 with android 12. I also tried a beta version of the extension (20230223). Do you know any solution to this problem?
@mothunderz
@mothunderz Рік тому
Hi, it is a bit difficult to figure out the root cause without being in front of your computer, but here some ideas: Could it be that you have rejected the permissions at some point in time?Do you have the possibility to try with a different phone? On your phone, can you go to "settings->Apps->MIT AI2 Companion" and make sure that "Location" and "Nearby devices" are included under the list with "Allowed permissions"? It will need location permission to work. I hope you can figure out what the root cause is. I use a Samsuns s22 with android 13, but also have used older android versions without a problem.
@fabrizionovello
@fabrizionovello Рік тому
@@mothunderz Hello. Thank you for your response. I didn't use MIT companion, I directly install the app on the phone. At first I was trying to make my own app following your steps, then I used your .aia and your sketch for the esp32 but the error message was still appearing. The solution was to add a BluetoothClient (classic bluetooth) from the built-in options in MIT app inventor without using any blocks of classic bluetooth, and then when I start the app for the first time it ask me for permissions.
@mothunderz
@mothunderz Рік тому
@Fabrizio: thank you very much for your comment. Yes, you are right, you need to add the classic bluetooth interface when you want to compile it to run it directly on a phone. I should have included this in the video and will add a correction to the description so that others are informed as well. Thank you very much for bringing this up!
@ryanwilliams3014
@ryanwilliams3014 2 місяці тому
so this BLE extension can it work on the new Samsung phone? s22 and up???
@mothunderz
@mothunderz 20 днів тому
Yes, I have an s22 myself and it works :-)
@LearningToFly77
@LearningToFly77 3 місяці тому
How can i automatically pair a Device with Pin Code? I don't want to enter it every Time i start the App.
@mothunderz
@mothunderz 3 місяці тому
That should indeed be possible, however, so far I have not looked into that yet...
@semilleroalive1639
@semilleroalive1639 10 місяців тому
hello. please why happen this __ error 908: the per,ission BLUETOOTH_CONNECT has been denied. please enable it in the settings app
@mothunderz
@mothunderz 10 місяців тому
I would be glad to help, but with such little information it is really hard to give pointers. I just double checked the code and everything works on my end, so, here some questions: 1) What phone did you use? Android or IOS? I assume Android. 2) What version of Android are you using? I am using version 13 3) How are you testing the code? Did you compile to an .apk or are you using MIT App Inventor? 4) Does the app at least show all available Bluetooth devices? When do you get the error, when you start the code, or when you select a device to connect to?
@ernestorivero9909
@ernestorivero9909 7 місяців тому
Yo estoy confundido y quisiera que usted me aclarara si yo mando texto o mensage desde un celular a un esp32 para que el esp32 me lo muestre en una pantalla quien es el servidor y quien es el cliente,aclareme eso estoy confundido para yo saber que codigo cargarle al esp32 si el de servidor o el de cliente
@mothunderz
@mothunderz 3 місяці тому
Please refer to the final code: github.com/mo-thunderz/BleMobileAppMitAppInventor The BLE Server code will be loaded into the ESP32 and the MIT App inventor will be used for the phone. Please note that at the moment only Android phones are supported for BLE in MIT App Inventor. Good Luck with your project!
@andos1114
@andos1114 Рік тому
Waiting for a real tutorial with Android Studio
@mothunderz
@mothunderz Рік тому
I am now working on a video with Xamarin, should be done in a week or two. Have not had the time to look into Android Studio yet.
@mothunderz
@mothunderz Рік тому
FYI: just uploaded my video on Xamarin and BLE ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html
@harshavardhantangudu3239
@harshavardhantangudu3239 11 місяців тому
I am not able to search nearby bluetooth devices using this.Can u help me to get out from this difficulty.
@mothunderz
@mothunderz 11 місяців тому
My apologies, but with this little information I cannot help you. Did you download the latest .aia file from my github website? What platform are you using (Android or Apple)? What SW version is running on your phone? How are you testing the app SW (do you compile to an apk or do you use the Companion)? Did the phone ask for permission when you run the app? Which ESP32 did you use to test it with? etc etc
@sharankumar1480
@sharankumar1480 11 місяців тому
Am getting an error stating " The companion has disconnected". May i know y ??
@mothunderz
@mothunderz 11 місяців тому
Yes, I sometimes have seen this error as well with "The companion has disconnected". This has to do with the fact that the BLE drivers of MIT App Inventor are not very stable. However, if you compile to an .APK then you should not have any issues. As far as I have seen, the error only occurs when you mess around with the BLE interface itself. So as soon as you have set that up, it should work. Pls try that and worst case you will need to convert to apk. Alternatively you can use another language like Xamarin for the app development, but that has a steep learning curve to it: ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html
@JLaurel
@JLaurel 4 місяці тому
Why MIT Companion stops every time I change the Slider? Everything else works fine.
@mothunderz
@mothunderz 3 місяці тому
What do you mean with MIT Companion stops? Does it crash? It should not. Have you checked the final code? What phone are you trying it on?
@flaviodenis9465
@flaviodenis9465 Рік тому
I am using Arduino nano and Bluetooth module HC-05. But it is not visible in the app.
@mothunderz
@mothunderz Рік тому
The best way forward is to check first if your Arduino is working correctly. To do so there is a simple app you can use. Just go to 11:05 in this video an I show you how to do this. I am using an esp, but it works exactly the same with an arduino: ukposts.info/have/v-deo/aImnmJWiZ56Tt6c.html
@flaviodenis9465
@flaviodenis9465 Рік тому
@@mothunderz I'll try this and let u know
@flaviodenis9465
@flaviodenis9465 Рік тому
@@mothunderz Can I contact you through mail? I need some help
@mothunderz
@mothunderz Рік тому
@@flaviodenis9465 my email address is my UKposts name at Gmail.com
@flaviodenis9465
@flaviodenis9465 Рік тому
@@mothunderz 👍😊
@tommieedwardberry
@tommieedwardberry 3 місяці тому
I guess this is not working for iPhone, since extensions for bluetooth are needed.
@mothunderz
@mothunderz 3 місяці тому
Yes, iPhone is unfortunately not supported in MIT app inventor. A possibility would be Xamarin, but that is way more difficult: ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html
@mypatentlawyers1548
@mypatentlawyers1548 10 місяців тому
Just keep getting this error "invoke: unable to invoke method `StartScanning` in object of type boolean. Irritants: () Note: You will not see another error reported for 5 seconds
@mothunderz
@mothunderz 10 місяців тому
Unfortunate that the code does not work for you. Can it be that you are using an IOS device? Unfortunately the BLE Extension for MIT App Inventor does not (yet) work on IOS devices. I did recently post an implementation for Xamarin that can be adapted to work with IOS. However, I do not have IOS devices myself thus cannot test this: ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html
@OLDNEWTECH
@OLDNEWTECH Рік тому
It's not working on android 11 or greater
@mothunderz
@mothunderz Рік тому
Hi Burhan, thank you for your feedback. What exactly is not working at the moment? What exactly is not working? Are you testing the App with the AI Companion or as an APK on the phone? What ESP32 are you using? I have tested quite a few ESPs in the meantime and the ESP32-WROOM-32D does work while it will not connect to the ESP32-WROOM-32. I think the reason for that is that the 32 (without D) is older and treats BLE differently. The MIT App Inventor App does not like that.
@OLDNEWTECH
@OLDNEWTECH Рік тому
@MoThunderz well I'm using AI companion for testing, but not showing any bluetooth devices
@mothunderz
@mothunderz Рік тому
Do you have GPS enabled on your phone? Did the app ask for permissions when you started it the first time? Have you checked with the nRF app whether or not bluetooth devices are around? Also what helps is to go into the bluetooth menu of your phone (swipe down and long press the bluetooth symbol) and manually connect to the ESP there once. Hope this helps
@OLDNEWTECH
@OLDNEWTECH Рік тому
@MoThunderz i saw your previous video in this video your app used bluetoothclient2020 extension if you have please share with me through Email
@OLDNEWTECH
@OLDNEWTECH Рік тому
Because its working with esp32
@deonbowers6706
@deonbowers6706 11 місяців тому
@33:35 Mobile App to ESP32
@mothunderz
@mothunderz 11 місяців тому
Actually, in this first example in the video the Server (so the ESP32) is generating a value and updating that every second. With Notify this value is sent to the mobile app and that is then shown on the mobile phone. So I do think that I say it the right way in the video. Please let me know if I miss something here. Thanks!
@deonbowers6706
@deonbowers6706 11 місяців тому
@@mothunderz Sorry this was actually just a reference for myself.
@mothunderz
@mothunderz 11 місяців тому
Ah understood, all set :-)
@biesys
@biesys 8 місяців тому
Can you help me apply this to the prototype i built based on this video? nRF Connect, 2020-11-05 TAIDOC TD1107 (C0:26:DA:01:D5:14) V 14:41:58.971 Connecting to C0:26:DA:01:D5:14... D 14:41:58.972 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M) D 14:41:59.340 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED D 14:41:59.385 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 14:41:59.385 Connected to C0:26:DA:01:D5:14 V 14:41:59.411 Discovering services... D 14:41:59.411 gatt.discoverServices() I 14:41:59.938 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms) D 14:42:00.230 [Callback] Services discovered with status: 0 I 14:42:00.230 Services discovered V 14:42:00.259 Generic Access (0x1800) - Device Name [R] (0x2A00) - Appearance [R] (0x2A01) - Peripheral Preferred Connection Parameters [R] (0x2A04) Generic Attribute (0x1801) Device Information (0x180A) - System ID [R] (0x2A23) - Model Number String [R] (0x2A24) - Serial Number String [R] (0x2A25) - Firmware Revision String [R] (0x2A26) - Hardware Revision String [R] (0x2A27) - Software Revision String [R] (0x2A28) - Manufacturer Name String [R] (0x2A29) - IEEE 11073-20601 Regulatory Certification Data List [R] (0x2A2A) - PnP ID [R] (0x2A50) Health Thermometer (0x1809) - Temperature Measurement [I] (0x2A1C) Client Characteristic Configuration (0x2902) Nordic LED Button Service (00001523-1212-efde-1523-785feabcd123) - Button [N W] (00001524-1212-efde-1523-785feabcd123) Client Characteristic Configuration (0x2902) D 14:42:00.259 gatt.setCharacteristicNotification(00002a1c-0000-1000-8000-00805f9b34fb, true) D 14:42:00.263 gatt.setCharacteristicNotification(00001524-1212-efde-1523-785feabcd123, true) I 14:42:00.321 Connection parameters updated (interval: 48.75ms, latency: 0, timeout: 5000ms) V 14:42:09.877 Enabling indications for 00002a1c-0000-1000-8000-00805f9b34fb D 14:42:09.878 gatt.setCharacteristicNotification(00002a1c-0000-1000-8000-00805f9b34fb, true) D 14:42:09.880 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0200) I 14:42:09.976 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00 A 14:42:09.976 "Indications enabled" sent V 14:42:09.986 Indications enabled for 00002a1c-0000-1000-8000-00805f9b34fb I 14:42:10.074 Indication received from 00002a1c-0000-1000-8000-00805f9b34fb, value: (0x) 06-68-01-00-FF-DA-07-05-16-04-06-00-00 A 14:42:10.074 "36.00°C Time: 22 May 2010, 04:06:00 Type: Unknown" received V 14:42:11.178 Enabling indications for 00002a1c-0000-1000-8000-00805f9b34fb D 14:42:11.178 gatt.setCharacteristicNotification(00002a1c-0000-1000-8000-00805f9b34fb, true) D 14:42:11.180 gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x0200) I 14:42:11.243 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00 A 14:42:11.243 "Indications enabled" sent V 14:42:11.247 Indications enabled for 00002a1c-0000-1000-8000-00805f9b34fb I 14:42:11.341 Indication received from 00002a1c-0000-1000-8000-00805f9b34fb, value: (0x) 06-68-01-00-FF-DA-07-05-16-04-06-00-00 A 14:42:11.341 "36.00°C Time: 22 May 2010, 04:06:00 Type: Unknown" received V 14:43:15.016 Reading all characteristics... V 14:43:15.016 Reading characteristic 00002a00-0000-1000-8000-00805f9b34fb D 14:43:15.016 gatt.readCharacteristic(00002a00-0000-1000-8000-00805f9b34fb) E 14:43:16.426 Error 133 (0x85): GATT ERROR V 14:43:16.490 Reading characteristic 00002a01-0000-1000-8000-00805f9b34fb D 14:43:16.490 gatt.readCharacteristic(00002a01-0000-1000-8000-00805f9b34fb) D 14:43:16.490 [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0) E 14:43:16.490 Error 8 (0x8): GATT CONN TIMEOUT I 14:43:16.490 Disconnected D 14:43:16.538 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED D 15:43:04.916 gatt.close() D 15:43:04.975 wait(200)
@mothunderz
@mothunderz 7 місяців тому
Thank you for the interest in my channel. Unfortunately I will not be able to assist in coding at this point in time. The YT channel is a hobby for me and my way to give something back to the community. However, I have a fulltime job and in the last months barely got to recoding videos at all. I hope you understand this.
@biesys
@biesys 7 місяців тому
@@mothunderz thanks. Some pointers can help, if posible. I don't need you to build the blocks, just pointers as in what uuid to use when.
@mothunderz
@mothunderz 7 місяців тому
Well understood, however, just seeing the nRF debug output without the actual code makes it very difficult to debug. Especially since I dont know what you want to achieve. I recommend starting simple: did you get the code working that I posted? If you did, then step by step adapt the code to what you need and test every step. That way you dont get lost as easily. Hope this helps.
@biesys
@biesys 7 місяців тому
@@mothunderz the prototype based on your example worked up to discover, select, connect but no data. I do have the source code of the actual apk that reads the data from my 5 BLE devices and then creates a txt file which my main App created in MIT AI is waiting for in 4 secs interval loop.
@kenaldo7707
@kenaldo7707 Рік тому
hi there, thanks for the amazing work, after I scan the QR code on my phone, there's an error message on my laptop that says "Error from Companion: error: undefined variable. (irritants: yail/edu.mit.appinventor.ble.BluetoothLE)," could you possibly know how i can fix this issue please?
@mothunderz
@mothunderz Рік тому
Hi, could it be that you are using an Iphone? Unfortunately extensions are not yet supported by MIT App Inventor for Iphones. Please see this link for more details: community.appinventor.mit.edu/t/error-from-companion-undefined-variable-irritants-yail-1/28558/12 So as long as extensions are not supported it will not be possible to use BLE with MIT App Inventor in an Iphone. I am now finishing a video on BLE with Xamarin. That should be able to run on an Iphone. I dont have an Iphone myself though, so cannot verify this.
@kenaldo7707
@kenaldo7707 Рік тому
yes i did use an iphone. i have an android emulator tho, appreciate it!
@mothunderz
@mothunderz Рік тому
I have tested quite a few ESPs in the meantime and the ESP32-WROOM-32D does work while it will not connect to the ESP32-WROOM-32. I think the reason for that is that the 32 (without D) is older and treats BLE differently. The MIT App Inventor App does not like that. If this really does not work for you, perhaps have a look into Xamarin: that BLE implementation is more robust: ukposts.info/have/v-deo/i5Z4qYKqgpuAxnk.html
@LyNaa2
@LyNaa2 10 місяців тому
Hello Sir, Can I please contact you so you can help me with a small problem i have with receiving data, i am using Arduino Nano BLE 33 and MIT APP. Please, and if yes can I have your email.
@mothunderz
@mothunderz 10 місяців тому
Hello, I get many code review requests and as such it is difficult for me to answer all reviews. I see you already sent me an email and will reply to that.
ESP32 Guide 2024 | Choosing and Using an ESP32 Board
41:06
DroneBot Workshop
Переглядів 196 тис.
BLE with ESP32 tutorial part 1: the Server
25:23
MoThunderz
Переглядів 68 тис.
Китайка и Хеликоптер😂😆
00:18
KITAYKA
Переглядів 1,3 млн
Секретная разработка КГБ! Волга «Догонялка» на V8…
1:07:10
Мастерская Синдиката
Переглядів 2,3 млн
Xamarin BLE App for latest Android releases (12 and higher)
38:51
MoThunderz
Переглядів 8 тис.
Arduino Bluetooth Control From Your Mobile Phone Using MIT App Inventor
1:05:36
Bluetooth LED Control App with MIT App Inventor - STEP By STEP
11:02
Enjoy Mechatronics
Переглядів 73 тис.
XIAO BLE Digital Output Control using Arduino and MIT APP Inventor
8:24
Easiest ESP32 BLE (Bluetooth Low Energy) Tutorial | Arduino
11:28
LiveSparks
Переглядів 90 тис.
iPhone control of ESP32 using Bluefruit Connect
4:40
Wim der Kinderen
Переглядів 14 тис.