Easiest ESP32 BLE (Bluetooth Low Energy) Tutorial | Arduino

  Переглядів 42,462

LiveSparks

2 роки тому

Learn how to use BLE with the ESP32 using the Arduino Development Enviornment.

~~~~~~~~~~~Video Sponsor~~~~~~~~~~~~
Buy Electronic Components from lcsc.com
Get 8$ off using this link : bit.ly/2F0bVcz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~NOTES~~~~~~~~~~~~~~~
Use GPIO 15 to connect the temperature sensor instead of GPIO 36.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~LINKS~~~~~~~~~~~~~~~~
Download the example codes : bit.ly/2XH4Tk2
Download the nRF Connect App : bit.ly/2ICYtfK
Download the custom app : bit.ly/2X4LDA5
Use ESP32 with Arduino : bit.ly/31vHNz8
Pre-defined Services : bit.ly/2IaIeHw
Pre-define Characteristics : bit.ly/2X4EgIN
Use this website to view the GATT specifications (xml files) : bit.ly/2WKSPCh //Use the XML Tree View
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~PRODUCT LINKS~~~~~~~~~~~
Buy the ESP32 FireBeetle Board : goo.gl/5he7bp
Buy the DS18B20 Temperature Sensor : goo.gl/DNTgMb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Help translate this video in your language : www.youtube.com/timedtext_cs_p...

Music by Joakim Karud youtube.com/joakimkarud

КОМЕНТАРІ
LiveSparks
LiveSparks 2 роки тому
How many times did I say 'BLE'?
LiveSparks
LiveSparks 2 роки тому
That's a good question. I haven't actually measured the current consumption on this board but on the M5Stack (a ESP32 board with an absolutely minuscule battery), the everything-to-string sketch runs for about a hour (while a client is connected) while a WiFi web server sketch dies within minutes.
Tom Donnelly
Tom Donnelly 2 роки тому
What's the current consumption of this loaded board while running this "Low Energy" sketch?
Random Guy
Random Guy 12 днів тому
Is it possible to extend its range?
LiveSparks
LiveSparks 12 днів тому
There are some ESP32 modules that have external antennas. Those would have better range.
wei48221
wei48221 3 місяці тому
This is a very helpful tutorial for newbies. Thank you very much for your effort.
Radu Horga
Radu Horga 4 місяці тому
Hi! Do you know any method to limit on the server the number of incomming connections (clients) to one? Thank you.
LiveSparks
LiveSparks 4 місяці тому
Glad to hear it.
Radu Horga
Radu Horga 4 місяці тому
@LiveSparks Thank you, it worked! I stop on connect and start on disconnect.
LiveSparks
LiveSparks 4 місяці тому
Sorry, I meant pAdvertising->stop().
Radu Horga
Radu Horga 4 місяці тому
@LiveSparks Thank you. I'm not sure I get it, if I start it even if the first client has connected, it will still advertise for the second and subsequent clients, right?
LiveSparks
LiveSparks 4 місяці тому
You can use pAdvertising->start() after the first client has connected.
Mahendra U
Mahendra U 4 місяці тому
Superb explanation boss and thanks for this tutorial.
froh_do
froh_do 5 місяців тому
Will this code also work if I use other hardware? I am using the dht22 as a sensor and I have the bluefruit spi friend as a bluetooth device both connected to the arduino
LiveSparks
LiveSparks 5 місяців тому
The Bluetooth code is hardware specific to the esp32
SoloSailor sv
SoloSailor sv 5 місяців тому
The BLE Viewer App does not see any devices at all, the nRF Connect works fine as sees all BLEs in the area
SoloSailor sv
SoloSailor sv 5 місяців тому
Please clarify: This sets up the ESP32 as a BLE Server in Broadcast mode? THANKS
LiveSparks
LiveSparks 5 місяців тому
Yes
KRISHNA
KRISHNA 6 місяців тому
Thanks for great tutorial but BLE_Viewer2.apk is not able to detect my esp32 ble device
Gaurav Badgujar
Gaurav Badgujar 6 місяців тому
Can you guide me
Gaurav Badgujar
Gaurav Badgujar 6 місяців тому
Can you guide me
Vishal Panchal
Vishal Panchal 9 місяців тому
Best BLE tutorial... 👌🙌
sandeep singh jagdev
sandeep singh jagdev 10 місяців тому
Best tutorial also I want to know that is connection remain connected when esp32 wakes up from deep sleep (i use deep sleep for very low battery power consumption (1mA) )??
Matthew H
Matthew H 10 місяців тому
Thank you so much for this tutorial!!!
Jairo Reyes
Jairo Reyes 10 місяців тому
Good video, how can I make a simple process a resend some data to the phone? For example, a humidity sensor and a light sensor send data to a device, and then the device sends these data to my phone via Bluetooth. Can a ESP32 be configured as Client and server at the same time? Thanks
Goran Josic
Goran Josic 11 місяців тому
Really good explanation!! Thank you!
Kevin Thomas
Kevin Thomas 11 місяців тому
Thank you for your BLE videos. I have an ESP32 and I have tried your BLE examples and they all work on my phone. I am struggling to get the BLE Client to work as I want to be able to have another ESP32 read these values. Here is what happens when I run your BLE_everything_to_string program on another client BLE which I am using the built in BLE_client app: Starting Arduino BLE Client application... BLE Advertised Device found: Name: , Address: 4b:41:58:c8:94:f2, manufacturer data: 4c0010050818237b8e BLE Advertised Device found: Name: , Address: 1e:44:1e:8d:54:08, manufacturer data: 0600010920021f0f72b658f8fa6a56054b76f656467d07548b169b875d BLE Advertised Device found: Name: , Address: 4a:f7:2c:59:b5:ec, manufacturer data: 4c001005421c6e4d8a BLE Advertised Device found: Name: , Address: 7f:79:4e:7f:82:4e, manufacturer data: 4c0010050818237b8e BLE Advertised Device found: Name: , Address: 57:b1:e4:c9:d2:82, manufacturer data: 4c001005401c7dd543 BLE Advertised Device found: Name: , Address: 7b:d8:62:bc:e9:84, manufacturer data: 4c001005241c548cdc, txPower: 8 As you can see I do not see the Device Name or any of the messages like this is a string as I am seeing them on my phone app but not on the BLE_client. Any help would be appreciated!
Arthur Goujon
Arthur Goujon 11 місяців тому
best tutorial on this topic by far! many thanks!
Rakitha De Alwis
Rakitha De Alwis 11 місяців тому
best BLE tutorial i have seen so far !!
Clifford Mathew
Clifford Mathew Рік тому
Excellent! Thanks
David Clawson
David Clawson Рік тому
Very helpful, thank you!
shaiseg
shaiseg Рік тому
Thanks for a great tutorial! May I ask where do I find the XML that defines a pre-defined standard characteristic like the temperature (8:30 in the video) I do not find it anywhere in bluetooth site. The service XML does not have this info. Thanks!
Tamer Salmem
Tamer Salmem Рік тому
Didn't work at all.... Couldnt connect to iOS (iphone XS) or Windows 10. 2 months looking for a solution and nothing... I guess I'll go back to Arduino....
Shaik Nadeem Sameer
Shaik Nadeem Sameer Рік тому
sir, can we consider RSSI value without pairing one with another BLE and perform action based on RSSI value?
Milton Roa
Milton Roa Рік тому
Amazing clear guide! Im looking into building my own vertical hydroponic garden and using audrinos in order to compile data on the garden and make sure its recieving proper amounts of water and nutrients. Please keep it up!!
M R
M R Рік тому
Very good detail description of BLE on ESp 32
dirtyv69
dirtyv69 Рік тому
I loaded your app into MIT App Inventor, compiled and put it on my Pixel 3A phone. I also loaded your switch code onto my ESP32 board. There seems to be something wrong with the App as it always comes back with "No Devices Found". Running a "BLE Scanner" app I can find the ESP32 and see that the switch program is working. Running an app I wrote on MIT App Inventor for a different BLE module, I was able to see the ESP32, but could not connect because it was looking for a different service ID. I even tried loading your APK, and it was unable to find any devices. Not sure what is wrong, but something seems broken as both my APP and the BLE scanner can see the ESP32, but your APP does not.
Rahman Mahmud
Rahman Mahmud Рік тому
How to receive integer data from an iphone BLE app? I was able to receive just 1 digit in ASCII. No matter the length of my data is it only take the first digit in consideration. But if I send whole string like name then it is fine. This is the receiving code" if (rxValue.length() > 0) { Serial.println("*********"); Serial.print("Received Value: "); for (int i = 0; i < rxValue.length(); i++) x = (rxValue[i]); Serial.println(x); I want to assign any value I send from my iphone
Em Wintle
Em Wintle Рік тому
I’ve been struggling with an ESP-32 BLE project for a long time. It’s a project for reading devices for medical missions to 3rd world locations. I’ve read dozens of articles, PDFs, etc. All were too low-level or high-level. From this I understand all the theory, but putting it into practice has been too much. This is the first resource that gave me hardcore practical information. I’m excited that now I understand how I can make it work! Thank you so much for this help!
P Fehlberg
P Fehlberg Рік тому
Hello, great tutorial, can you help with idea? Can you connect to the zwift cycling program as a fitness machine ftms and receive or obtain the gradient or resistance level. I have been trying for months. Thanks for any help.
Bilge Kaan Tekin
Bilge Kaan Tekin Місяць тому
Hi, did you finish your fitness machine or indoor bike project?
PUBG Mobile
PUBG Mobile Рік тому
Hi, I'm making an android app like mojipic with ble. Can you help me? I have to convent gifs to c array and then show it on a led panel with arduino
biker2k3
biker2k3 Рік тому
Gracias!!! muy buena explicacion!
Rick Miles
Rick Miles Рік тому
Trying to get a 2nd ESP32 to act as a client for the BLE switch (server). Any suggestions on what code to load on the client side?
Rudy Candu
Rudy Candu Рік тому
I appreciate your video. But it would help if the sound was better. It is hard to understand you because of the room reverberations. Move the mic closer to you. Or use some soft items to absorb the sound of the room.
LiveSparks
LiveSparks Рік тому
I don't have a mic currently, I just use my phone but I'll try to get better sound.
mattygsa
mattygsa Рік тому
Great video thanks. Question. Am I able to send a bluetooth classic throttle signal over serialBT from a transmitter ESP32 to a receiver ESP32 whist also sending temperature readings back to the transmitter ESP32? If so! Would I use BLE for this? Can I even use BT and BLE at the same time?
Umashankar Umashankar
Umashankar Umashankar Рік тому
nice vedio im trying to use float variable and i want to perform read and write value using BLE but im not able to do that can you exeplian me . thanks
swaroop bu
swaroop bu Рік тому
how to transfer data between two ble server and client plzhelpme in tht
Trần Tuấn
Trần Tuấn Рік тому
Thanks for your clear instruction. How about making a BLE beacon. Do you have any project that touched on subject ?
Mario Delgado Serrano
Mario Delgado Serrano Рік тому
How could I do to read the Slope in Zwift (bike simulator) and the said a motor move to position 1 to 10?
Mike Lemon
Mike Lemon Рік тому
8:26 how do I access this page to view how data for different pre defined characteristics needs to be formatted for a guide for an incoming project.
Mike Lemon
Mike Lemon Рік тому
@LiveSparks OK I understand now you have to literally copy the hyper link of the service\characteristic and throw it to the online converter to view that.
Mike Lemon
Mike Lemon Рік тому
@LiveSparks OK, But how to I find the relevant URL for say the temp characteristic?
LiveSparks
LiveSparks Рік тому
There are links in the video description for services and characteristics. Download the xml for the appropriate thing and view it in the XML viewer.(Link also in the description).
Andreas Podlich
Andreas Podlich Рік тому
Hey, nice Video. Im trying atm to communicate with a bluetooth radiator-valve atm. If i scan for ble devices with the examplecode given by the IDE, i can find it. But i was hopeing i could use your video to find out which data i can request or just get from the device. There is an existing project on github already, but i want to build my own. I need abit of help. Do you have any idea?
LiveSparks
LiveSparks Рік тому
You need to code for each service that you want to read. Use nrf connect app to see what services are being advertised.
Andreas Podlich
Andreas Podlich Рік тому
@LiveSparks Thank you very much. with that, i could connect to the service uuid and get a data. But only one. the valves consisting of alot of data. weird
LiveSparks
LiveSparks Рік тому
github.com/espressif/arduino-esp32/blob/master/libraries/BLE/examples/BLE_client/BLE_client.ino
Rob Allen
Rob Allen Рік тому
Thanks for the nice tutorial! I did have difficulty with the audio, however, as your voice sounds highly distorted here. A look at the audio shows that it is indeed clipped rather severely. I made a graphic of this clipping, which can be found here: photos.app.goo.gl/ZBSTEcZ3mdqVADWe7 This is probably some part of your tool chain as I've seen this happen elsewhere. In one case, the creator fixed it, but could not determine what caused it in the first place. Something is being over-driven here, but later processing (or youtube's transcoding) has obscured much of the clipping by backing it off just a tiny bit. Good luck!
hondaman900f
hondaman900f Рік тому
What was the dev tools you mentioned you created the Android app in?
LiveSparks
LiveSparks Рік тому
MIT App Inventor 2
Future Farming Labs
Future Farming Labs 2 роки тому
I'm am to able to convert incoming Lora data packet to char at initialization sir how I can send seprate sensor value to custom app I have tried all the stuff. I want to send my Lora reciver data packet which is coming from node to reciver to my custom app sir how I can achieve that
LiveSparks
LiveSparks 2 роки тому
I have shown how to do so in the video. You can also look at the examples that I have linked in the description
Dot Dot
Dot Dot 2 роки тому
Not working, I'm using a huzzah32 board with ds18b20 and I am not able to get any temp readings using this code. i can connect via ble but will not give me any temp values on the app or on the serial monitor ive tried many different pins. Any help please?
Dot Dot
Dot Dot 2 роки тому
LiveSparks I figured it out.. Apparently only the android app will display the converted temp value, so I used an android and it works perfectly. Thanks
LiveSparks
LiveSparks 2 роки тому
If the temperature characteristic is showing up correctly then the nRF Connect app should have automatically converted the data to decimal. I am sorry but I am stumped as to why this might be. The last suggestion I can give is to check if you are correctly sending a 16 bit unsigned int and not a float.
Dot Dot
Dot Dot 2 роки тому
LiveSparks Yes everything is showing up correctly but for some reason the temperature value is given in some hexadecimal value. I know the sensor is working because if I touch the sensor the hexadecimal value increases.
LiveSparks
LiveSparks 2 роки тому
I am sorry but I am stumped as to why this might be. Is the environment sensing service showing up correctly in the nRF Connect app?
Dot Dot
Dot Dot 2 роки тому
So i believe im getting a hexadecimal value
Rohit Khot
Rohit Khot 2 роки тому
Hi, thanks for the wonderful tutorial, I am trying to connect my ESP32 board to Chrome using web Bluetooth, however, the chrome is not able to detect it, can you please help what might be the problem? It works well with nrfConnect
Rohit Khot
Rohit Khot 2 роки тому
@LiveSparks Thanks I will look into it :)
LiveSparks
LiveSparks 2 роки тому
Sadly I am not very familiar with web Bluetooth. You can take a look at the client app project inside the MIT App Inventor to see how the client flow works which you can then try and replicate with web Bluetooth.
Muhammad Ja'far Shiddiq
Muhammad Ja'far Shiddiq 2 роки тому
Hello, thanks for the tutorial! but i've got some problem that my potentiometer analog value is always 255 (shown in the serial monitor), or the value at the characteristic is always FF at the nRF Connect App. I use GPIO14 from ESP32 DOIT DEVKIT V1 Board. Can you help me please? thanks
LiveSparks
LiveSparks 2 роки тому
Not all pins of the ESP32 are suitable for analog readings. Try some other pins too.
Axa Axa
Axa Axa 2 роки тому
You can send more than a single byte in a characteristics value. Using the setvalue byte array parameter is not a workaround, it's a feature
LiveSparks
LiveSparks 2 роки тому
You are right, of course. I should have worded that better.
Mukund Baviskar
Mukund Baviskar 2 роки тому
hello the app is not connecting to ESP32 always responds no device found
LiveSparks
LiveSparks 2 роки тому
They can both work at the same time but since they share the same radio, the program needs to be very optimized to work without performance issues.
Mukund Baviskar
Mukund Baviskar 2 роки тому
Does wifi and Bluetooth both run simultaneously at same time?
LiveSparks
LiveSparks 2 роки тому
@Mukund Baviskar MIT App Inventor has some good documentation available here : appinventor.mit.edu/explore/get-started.html
LiveSparks
LiveSparks 2 роки тому
@Mukund Baviskar Hey, I just tried the examples again and they seem to work fine for me. NOTE that only the switch example and the everything_to_string example would work correctly with the custom app but the ESP should still be discovered when you search for it. It might be possible that the compiled app is not compatible with your phone.
Mukund Baviskar
Mukund Baviskar 2 роки тому
I am trying to add button on mit app intventer but not able to make one can help on how to do that
#173 ESP32 Bluetooth BLE with  Arduino IDE (Tutorial) and Polar H7
15:55
Andreas Spiess
Переглядів 126 тис.
24 ЧАСА В КОМНАТЕ С 10 000 ТАРАКАНОВ!
45:53
It's Mamix
Переглядів 4,8 млн
Ани Лорак - Наполовину [ЖАРА’21]
3:54
Ани Лорак
Переглядів 172 тис.
My first ESP32 project: Bluetooth Low Energy RGB LED Controller
5:34
BitBastelei #340 - Bluetooth-Android-Apps für ESP32
31:51
BitBastelei
Переглядів 24 тис.
#274 Free Inline Debugging for ESP32 and Arduino Sketches
17:46
Andreas Spiess
Переглядів 110 тис.
#149 ESP32 Dual Core Programming + Speed 💨Test vs Arduino UNO (fast!)
31:18
#366 9 New ESP32 Boards: Comparison and Tests
15:11
Andreas Spiess
Переглядів 115 тис.
Bluetooth 2.0 VS Bluetooth 4.0 (BLE) || Is an Upgrade worth it?
7:54
GreatScott!
Переглядів 536 тис.
Behringer FCB1010 Full Tutorial / Video Manual
46:53
In The Mix
Переглядів 108 тис.
24 ЧАСА В КОМНАТЕ С 10 000 ТАРАКАНОВ!
45:53
It's Mamix
Переглядів 4,8 млн
Ани Лорак - Наполовину [ЖАРА’21]
3:54
Ани Лорак
Переглядів 172 тис.
ЦИТАТЫ ВЕЛИКИХ ЛЮДЕЙ | 13 Карт meme
0:46
Феникс Анимация
Переглядів 1,1 млн
🔴🎥350 000 вірян святкують День Хрещення Русі 2021 | ЯСКРАВЕ ВІДЕО
7:26
Українська Православна Церква
Переглядів 53 тис.