#173 ESP32 Bluetooth BLE with Arduino IDE (Tutorial) and Polar H7

Поделиться
HTML-код
  • Опубликовано: 10 дек 2017
  • So far, we had to use Espressif’s tools to use Bluetooth on the ESP32. Today I will try it with the Arduino IDE. I am curious how it will work. Maybe you come with me on this discovery tour? For sure, we will learn a lot about how Bluetooth low energy, or BLE, works.
    In this video we will cover:
    - The basics of Bluetooth Low energy
    - The different roles of devices
    - How we debug BLE connections using our Smartphone
    - We will build a notifier and a client
    - We will try to fake a Polar H7 Heart Rate monitor (at least, the BLE part
    - If we have time, we will have a look at An iTag Chain finder and a Xiaomi Flower care system
    - And maybe we will discover some “secret sauces” necessary for a delicious meal?
    Links:
    BLE services: www.bluetooth.com/specifications/gatt/services
    Neil Kolban Github: github.com/nkolban
    Neil Kolban books: leanpub.com/u/kolban
    ESP32 Development Board: bit.ly/2sOMR3E
    Supporting Material and Blog Page: www.sensorsiot.org
    Github: www.github.com/sensorsiot
    If you want to support the channel and buy from Banggood use this link to start your shopping: bit.ly/2jAQEf4 (no additional charges for you)
    Official Wemos Store: s.click.aliexpress.com/e/jUzBiIq
    facebook.com/profile.php?id=100013947273409
    twitter.com/spiessa
    www.instructables.com/member/Andreas%20Spiess/
    Please do not try to Email me or invite me on LinkedIn. These communication channels are reserved for my main job
    If you want to buy me a coffee: www.paypal.me/AndreasSpiess
  • Наука и техникаНаука и техника

Комментарии • 247

  • Analog Channel
    Analog Channel 29 дней назад

    Hello Andreas!! Thanks for sharing!!! could you show us any example using two spe32 (one like a server and another like a client)? Regards, Túlio

    • Analog Channel
      Analog Channel 28 дней назад

      +Andreas Spiess THANK YOU ANDREAS!!! I think you solved my problem!!!

    • Andreas Spiess
      Andreas Spiess  28 дней назад +1

      Maybe you watch the ESPnow video?

  • Vinicius
    Vinicius Месяц назад

    Do you have any news about ESP32 and the BLE Remote Button??
    That would be extremely useful, a very small, cheap and wireless button.

    • Andreas Spiess
      Andreas Spiess  28 дней назад

      I did not use BLE since then because I was disappointed and I wait till things are fixed.

  • Julián
    Julián Месяц назад

    good tutorial bud! thanks. By the way, someone know an android code example for a ble client?

  • Anton Juul-Naber
    Anton Juul-Naber 2 месяца назад

    You can also go to chrome://bluetooth-internals/#devices in your chrome browser to debug BLE. I think it has the same feature-set as the app

    • Andreas Spiess
      Andreas Spiess  2 месяца назад

      Interesting link. Thank you. I will try it next time I work with BLE

  • PH
    PH 2 месяца назад

    Does BLE from esp32 suffer interference from something like pcb boards? Does BLE use any pin?

    • Andreas Spiess
      Andreas Spiess  2 месяца назад

      BLE works wirelessly with the same antenna as Wi-Fi. It needs no pins

  • Adel Shokry
    Adel Shokry 4 месяца назад

    What is the name of the BLE scanner app, Thanks

    • Adel Shokry
      Adel Shokry 4 месяца назад

      I found it, It's nRF Connect, Thanks for the video.

  • may nards penales
    may nards penales 4 месяца назад

    sir i have a thesis proposal with using this ble sir can you help me?

    • Andreas Spiess
      Andreas Spiess  4 месяца назад

      I am a RU-clipr. I answer special questions when I see you tried it hard yourself.

  • Paulo Abrahão
    Paulo Abrahão 4 месяца назад

    how to connect an esp32 with bluetooth another esp32 ?

  • Didier Solheid
    Didier Solheid 7 месяцев назад

    Hi,
    Thanks for your great Job!
    I tried the sample with an ESP32 .. without success :
    C:\Users\dso\Documents\Arduino\libraries\ESP32_BLE_Arduino-master\src/BLEDevice.h:16:20: fatal error: esp_bt.h: No such file or directory
    I have a too old ESP32 Library ?
    Regards

    • Andreas Spiess
      Andreas Spiess  7 месяцев назад

      I would always download a new version. Things move quite fast in the ESP32 environment

  • Jose Luis Rodriguez de Torres
    Jose Luis Rodriguez de Torres 7 месяцев назад

    Hello Mr. Andreas,
    First, thank you for your videos. They are really usefull.
    Second, a question related both with Arduino and this bluetooth implementation (and my very limited knowledge).

    When I connect, I find this:
    "ESP32 Dev Module, QIO, 80MHz, 4mb (32Mb), 921600"

    By using the " BLE_server" code in the examples and after compilation/Upload, this is what I get:
    "Sketch uses 1085933 bytes (82%) of program storage space. Maximum is 1310720 bytes.
    Global variables use 69056 bytes (23%) of dynamic memory, leaving 225856 bytes for local variables. Maximum is 294912 bytes"

    I pretended to use ESP32 bluetooth functionality as part of the project but it seems that it leaves no much space for aditional code (18%). If it is so, it is not practical to me (and thers, I suppose), from a practical point of view.
    My question: I´m I wrong? Can program storage be expanded somehow? If yes, could you please explain, here in in any other video? If it cannot, I will have to find out other alternatives (I guess other people will also have to address this issue).

    For pure bluetooth functionality I was checking this product. It´s a different approach,, true, out of the Arduino world.
    www.lairdtech.com/products/bl600-series

    Thanks in advance,

    • Andreas Spiess
      Andreas Spiess  7 месяцев назад

      BLE is new on the ESP32 and the Arduino IDE and we all hope it will improve. You can do things with the few % left. What's left is probably still more than an Arduino has.

  • NIJIL N
    NIJIL N 8 месяцев назад

    Hi Mr Spiess, I am not able to change my service UUID and characteristic UUID to custom UUID created from UUID generator. Am able to change my other parameters like set value and blue tooth name . Would you be able to tell me why this happening ?

    • Andreas Spiess
      Andreas Spiess  8 месяцев назад

      I do not know. Did you watch all my BLE videos?

  • Michele Brunelli
    Michele Brunelli 8 месяцев назад

    Have you tried the Flower Care? I'm able to read sensor data but sometimes an error occour. Can you help me?

  • Maneco Urquhart
    Maneco Urquhart 9 месяцев назад

    great video Andreas!!!

  • mahesh s
    mahesh s 9 месяцев назад

    Bluetooth jammer with this?

    • mahesh s
      mahesh s 9 месяцев назад

      both work at 2.4ghz and are radio wave

    • Andreas Spiess
      Andreas Spiess  9 месяцев назад

      No

  • arunbm123
    arunbm123 9 месяцев назад

    Very Wonderfull vedio Sir

    • arunbm123
      arunbm123 9 месяцев назад

      ok....which is best chip according to you?

    • Andreas Spiess
      Andreas Spiess  9 месяцев назад

      No. It uses too much power

    • arunbm123
      arunbm123 9 месяцев назад

      can I use ESP32 to develop my own beacons for asset tracking, your Views Please

    • Andreas Spiess
      Andreas Spiess  9 месяцев назад

      Thanks!

  • weerobot
    weerobot 10 месяцев назад

    I cant get Wifi to work ?? I use standard #include ?? DOit board...

    • Andreas Spiess
      Andreas Spiess  9 месяцев назад

      :-)

    • weerobot
      weerobot 10 месяцев назад

      Got it working thanks...must have had the wrong libraries....Arduino IDE was saying too many versions of ...but ok now.

    • Andreas Spiess
      Andreas Spiess  10 месяцев назад +1

      Should work. Try an example file first.

  • MrLQKD
    MrLQKD 10 месяцев назад

    Andreas, take a look at the Simblee BLE module: www.simblee.com, and the RfDuino: www.rfduino.com

    • MrLQKD
      MrLQKD 9 месяцев назад

      Andreas Spiess Yes, indeed, they are not cheap, unfortunately. All the best!

    • Andreas Spiess
      Andreas Spiess  9 месяцев назад

      Thanks for the links. These are good products, however not cheap. I hope, we will come to a similar performance with ESP32 libraries on BLE.

  • Jorge Teixeira
    Jorge Teixeira 11 месяцев назад

    waiting for xiaomi band 2 :D.. continue the nice work i learn so much from you

  • Bat Steg
    Bat Steg 11 месяцев назад

    Any news on BLE Mesh support in ESP32?

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад

      No. Where would this fit? BLE seems to have a limited reach

  • Bat Steg
    Bat Steg 11 месяцев назад

    Here's a link to the NRF Connect Android app mentioned in the video - play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en

  • Rana Ankit
    Rana Ankit 11 месяцев назад

    PLEASE RESEARCH MORE SIR

  • stupossibleify
    stupossibleify 11 месяцев назад

    Andreas, your videos are superb!

  • Fernando Marengo Rodriguez
    Fernando Marengo Rodriguez 11 месяцев назад

    Great tutorial!!
    Is there any video about the HM-10 or any other bluetooth 4.0 module?
    Thanks!!

  • Timothy Woo
    Timothy Woo 11 месяцев назад

    Great video! However, I couldn't get the BLE examples to compile in Arduino IDE. I updated the ESP32 library by using Git GUI and get.exe but it didn't include the library so then I went to Neil Kolban's Github page and downloaded the library and put it in my libraries folder, but the example wasn't listed under "ESP32 Examples" and it didn't compile. It gave a few errors, but this was the first one: "ESP32_BLE_Arduino\src/FreeRTOS.h:46:3: error: 'pthread_mutex_t' does not name a type". Any ideas? Thanks!

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад +1

      I do not know. But I am glad it worked now!

    • Timothy Woo
      Timothy Woo 11 месяцев назад

      I deleted the ESP32 files and reinstalled and it worked, thanks! I guess the update from Git GUI didn't work?

    • Timothy Woo
      Timothy Woo 11 месяцев назад

      Hmmm the strange part is that I updated the library and it's not there. The ESP32 library for Arduino also doesn't show the libraries in Neil's repo and it only has "SimpleBLE": github.com/espressif/arduino-esp32/tree/master/libraries

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад +1

      If you just install the ESP32 support bluetooth is already there. No library necessary. Maybe you delete the library. Then it should work. Or you reinstall the ESP32 support.

  • Hyss
    Hyss 11 месяцев назад

    That heart monitor can be fooled by putting some water between it and your skin. No need for excess effort.

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад

      Thanks for the tip. Unfortunately too late:-(

  • Jens Jensen
    Jens Jensen 11 месяцев назад

    Another great smartphone util for ble is LightBlue. Bluetooth like usb is incredibly over engineered, and thus have a steep learning curve, but that’s also probably why both of these protocols have persisted for many years!

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад

      Thanks for the lightblue tip. Seems also to be a good product!

  • LeBogo
    LeBogo Год назад

    Hi, weißt du wie man sich die URL im WiFi server sketch ausgeben lassen kann ? ich habe es mit "Serial.pirntln(currentLine.endsWith());" versucht, aber ohne erfolg. Ich hoffe du kannst mir helfen :)

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад

      Nein, weiss ich leider nicht.

  • One Penny
    One Penny Год назад

    Perhaps the watch check the mac address in Polar H7 Heart Rate monitor
    If you see my example, you can change the bluetooth mac in esp32 and testing again.
    If you have all services , chars and mac adress I think there is nothing more the watch can check in a fake Polar Monitor.

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      It had a much simpler reason (shame on me): The watch did not use BLE, but the Polar proprietary protocol. But you will see an update soon

  • One Penny
    One Penny Год назад +1

    Dear Andreas, you can see my iTag emulator > www.instructables.com/id/ITag-With-an-ESP32-a-Bluetooth-Low-Energy-Button-A/
    Hope you can enjoy it, thanks for your videos.

    • Andreas Spiess
      Andreas Spiess  11 месяцев назад

      Thank you for your link. I will try it out.

    • One Penny
      One Penny Год назад

      I have done a iTag client or receiver, useful for using the cheap bluetooth buttons in our projects:-))
      It is only a PoC but it works !
      Thank you for sharing your work.
      github.com/aknik/ESP32/tree/master/iTag32

    • Andreas Spiess
      Andreas Spiess  Год назад +2

      Thanks for the link. I was also looking at the one you mention, and for sure will use it for my future work.

  • Marc Paradis
    Marc Paradis Год назад

    Andreas, what version of Arduino IDE you have ?
    Thank you.
    Marc.

  • Andre Muensti
    Andre Muensti Год назад

    Hello Andreas ,
    as always very good!
    Is there a possibility (example) for an SPP profile - to send text?
    RFCOMM protocol

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      You will see a video about UART BLE soon

  • Hans Schenker bei Google
    Hans Schenker bei Google Год назад

    Please keep on with BLE! It will have a bright future!

    • Andreas Spiess
      Andreas Spiess  Год назад

      You can bet on this one. I am very interested and worked nearly the whole week on it...

  • Bala Kumar G
    Bala Kumar G Год назад

    Hai...please tell how to make audio frequency oscillator using arduino........

    • Bala Kumar G
      Bala Kumar G Год назад

      thank you very much....

    • Andreas Spiess
      Andreas Spiess  Год назад

      www.arduino.cc/reference/en/language/functions/advanced-io/tone/

  • Ten Minute Tokyo 2
    Ten Minute Tokyo 2 Год назад

    linux.die.net/man/3/uuid

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thanks for the link. Maybe useful if I leave the predefined UUIDs.

  • hasan Infogeek
    hasan Infogeek Год назад

    Have you tried to work on ble with RPI in python? I have a ble rgb bulb, company got out of iot business so no support. I was successful in controlling the basic functions using a python script with RPI3, couldn't figure out the music sync part.. it is a much better interface and with RPI zw it could be in the same cost territory as esp32..

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      Python definitively is on the screen here.

    • hasan Infogeek
      hasan Infogeek Год назад

      Andreas Spiess yeah that is the end game.. Also micro python in esp32 should support ble soon it's like halfway there.. I am planning to teach a small micropython course and would love to hear your thoughts on the topic.. you have the best analysis for the ESP chips and micropython is probably the best interface (imho) for students so please try to make a video about it..

    • hasan Infogeek
      hasan Infogeek Год назад

      Andreas Spiess yeah that is the end game.. Also micro python in esp32 should support ble soon it's like halfway there.. I am planning to teach a small micropython course and would love to hear your thoughts on the topic.. you have the best analysis for the ESP chips and micropython is probably the best interface (imho) for students so please try to make a video about it..

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      Thanks! Maybe I have to investigate the possibilities of the RPI. But at the end, of course, we want to use the ESP32...

  • Christian Fuchs
    Christian Fuchs Год назад

    Im wondering you dont discover ble with wireshark... github.com/greatscottgadgets/ubertooth/wiki/Capturing-BLE-in-Wireshark

    • Andreas Spiess
      Andreas Spiess  Год назад

      I used Wireshark for Wi-Fi. But it seems to be different for BLE.

    • Christian Fuchs
      Christian Fuchs Год назад

      Andreas Spiess last time i id that my mac was ‚man in the middle‘, so i didnt need add. devices. But i sniffed on wifi, no bt or ble. I guess if one of your ble device can become man in the middle it will work. In other words: wireshark is a amazing tool, maybe u can use that for your purposes.

    • Andreas Spiess
      Andreas Spiess  Год назад

      AFAIK you need a special device to capture the traffic and I do not have such a device. I ordered now a BLE sniffer from Adafruit and will see where this goes...

  • Nick Burton
    Nick Burton Год назад

    Managed to get the UART example working for tx rx. by using the BLE Scanner app on an iPhone.
    Also got it to pair with a raspberry pi3, didn’t get any farther though.
    Think there’s a good Python Bluetooth library so might give that a try on the pi3
    Always found bluetooth a bit complicated but with the esp-32 it could be very useful for battery powered projects. So probably worth spending a bit more time with it.
    Thanks again for another great video.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Maybe I also will go the RPI route. We will see...

  • ytfp
    ytfp Год назад

    Good reminder of why I don't muck around with BLE, just not there yet. The only thing that is dissapointing is by the time something is figured out, something new is out.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Each technology has its "bleeding edge" where only a few join. Hopefully, BLE on the ESP32 will be mainstream soon...

  • mispeaced
    mispeaced Год назад

    Polar uses 4 protocols - GymLink (non-coded), GymLink, Wind, Bluetooth. Your FT60 watch is only compatible with GymLink heart rate devices (T31,H1,H2,H7,H10), it doesn't work over BLE. And H7 sensor provides both GymLink+Bluetooth compatibility. So, H7 works over GymLink with your FT60 watch and over Bluetooth with smartphones/esp32/.
    This info can be found here: support.polar.com/en/support/compatibility_with_my_Polar
    How do I know that? I also owe H7 + FT4 watch (GymLink only) :)
    And thanks for another great video!

    • Andreas Spiess
      Andreas Spiess  Год назад

      You are absolutely right! Thank you for your hint. Saves me time! Now I remember that I had to buy the H7 in addition to the normal sensor a few years ago because I wanted to use it with the iPhone.
      I am getting old...

  • Bike Vids
    Bike Vids Год назад

    Dood what’s a good cheap Android tab that can run the current Android?

    • Bike Vids
      Bike Vids Год назад

      Andreas Spiess Mee too, just need to look into dev.

    • Andreas Spiess
      Andreas Spiess  Год назад

      I am still on IOS ;-)

  • Sorin Negulescu
    Sorin Negulescu Год назад

    Hello Andreas,
    Congrats for one of the best introductory videos I could find on BLE!
    There are ble devices allowing discovery and pairing even if they are already paired. Kind of promiscuous, but that's life! :))

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thanks for your info. I did not know that. As I mentioned, I am still scratching at the surface...

  • 0gizmo
    0gizmo Год назад +1

    You can generate the UUIDs with this command:
    BLEUUID((uint16_t)0x2AB3)
    So you don't need the long numbers..
    Source: www.hackster.io/ManniAT/esp32-ble-environmental-gatt-server-14cceb
    Regarding BLE I can recommend this Book:
    shop.oreilly.com/product/0636920033011.do

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thank you for the hint. I used it and it works fine!

  • Tomasz Durlej
    Tomasz Durlej Год назад

    Strange, hr sensor should work without sweat.

    • Andreas Spiess
      Andreas Spiess  Год назад

      My experience is different (at least for the chest bands). The new one builtin in the watches works only with light.

  • Giampiero Raschetti
    Giampiero Raschetti Год назад

    It should be interesting some experiment with iBeacon advertising on BLE. There are some examples out there but I did not found anything compiled under the arduino ide.

    • Andreas Spiess
      Andreas Spiess  Год назад

      I hope, we will come to this topic later on. For the moment, I try to go step-by-step...

  • Dean Greenhough
    Dean Greenhough Год назад

    Congratulations on 50k subscribers. Very well deserved and the quality just keeps getting better. You sir are always my number 1 to go to for information first!
    Eternally grateful and appreciative of your outstanding work.
    Merry Xmas to all the intelligent people that follow your work and of course to our very own Electronics Father Xmas whom delivers a present every Sunday on the dot 🙏

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thank you for your continued support. But for this Christmas (because it is a Sunday), I do not plan a video. This is my one week RU-clip holiday this year. And I hope, that most people anyway would not have the time to watch my video...

  • Xano Trevisan Kothe
    Xano Trevisan Kothe Год назад

    This library is pretty good! Thank's for sharing.
    BTW: Too much secret sauce in the UUIDs. It reminds me of SNMP OIDs (I hate SNMP).

  • s bright
    s bright Год назад

    Running those stairs in the creepy gloves, after too much fondue is ill advised

    • Andreas Spiess
      Andreas Spiess  Год назад

      We really had fondue this WE, but after the finishing of the video ;-)

  • Jorge Macias
    Jorge Macias Год назад

    To make it work the polar clone you need to hack the company manufacturing data from the advertising package and by this way clone it into the esp32. Is the same if you want to accept your peripherals with the apple ble. I happen to know the company manufacturing data for apple is 4c 00 but for polar you must reverse engineer the polar.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thanks for your hint. I will stick to this BLE stuff, and eventually will be able to read it...

  • chegewaras
    chegewaras Год назад

    I wanted to say something about this vid but i wont because im not maintainer ESP32 BLE library, just someone who can help you with issues.
    But i want to say about polar, yes you can fake polar H7 device or at least you can use esp32 with this library as heart rate monitor device. If you are interested how to do that, you are welcome to open issue here ->> github.com/nkolban/esp32-snippets/issues

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thanks for the hint about opening issues. I will follow this path.

  • lamarched21
    lamarched21 Год назад

    Very interesting video. Let us know if you find the answers to your questions.

    • Andreas Spiess
      Andreas Spiess  Год назад

      I do not think, that this is the last video about BLE...

  • Richard Mullens
    Richard Mullens Год назад

    I bought a SHT31 Smart Gadget Development Kit (humidity sensor). Bluetooth is ubiquitous so thanks for prompting me to get it working.

  • Manick N
    Manick N Год назад

    This is interesting but I have a lot of groundwork before I can understand properly. This is definitely on my watch over list.

    • Andreas Spiess
      Andreas Spiess  Год назад

      So we are two with lots of learning in front of us ;-)

  • Adrian
    Adrian Год назад

    For reading miflora you can check this: github.com/open-homeautomation/miflora
    I bought for 0,10$ these BLE tags on Gearbest, I have at least 30 pieces. :D

    • Adrian
      Adrian Год назад

      Haven't tried yet + only the Miflora with rPi3.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thanks for the link. Were you able to read the tags with the ESP32?

  • Steve Groen
    Steve Groen Год назад

    Many hobbyists would like to remotely control a flex strip of "smart" RGB LEDs with a smart phone and the ESP32 as the controller. The LED strip would be powered by a 5V, 2A supply and not require BLE.
    Could this be accomplished by basic Bluetooth? Does the Arduino IDE currently support this project?
    If you could "RU-clip" this project I think you would have a hit because so many hobbyists love to play with LEDs.

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      You can use BLE for such a device. But most people use Wi-Fi because they use Wi-Fi for their other Home-Automation devices.
      Maybe I will cover something like that in the future, but now my priority is to understand the protocol itself...

    • ReanimationXP
      ReanimationXP Год назад +1

      He's given you the pieces necessary to implement this, and there are plenty of examples elsewhere.

  • Anas Omary
    Anas Omary Год назад +1

    I came, I liked, I watched. Thnx Andreas

  • Ton dB
    Ton dB Год назад

    Thanks Andreas.

  • opless
    opless Год назад

    I was hoping you'd take apart the keyfinder widget :-) I'm guessing it's an nRF51 part. Great Video as always Andreas!

    • Andreas Spiess
      Andreas Spiess  Год назад

      Unfortunately, it is my only one. This channel is not known to take things apart, more to build things. But looking at the numbers of such channels, maybe I will change my opinion ;-)

  • Jdragunov
    Jdragunov Год назад

    Good video, i will try to do something like this with a glucometer to download the data and populate a spreadshieet with it, need it for further analysis

    • Andreas Spiess
      Andreas Spiess  Год назад

      Please keep us posted if you are successful!

  • Giblet535
    Giblet535 Год назад

    Thank you once again, Andreas. Bluetooth, IMO, and for many reasons, sucks. This is due to bluetooth using a very noisy, crowded, 2.4GHz RF band, plus the usual absence of 2.4GHz antennas in bluetooth hardware, plus sloppy software in almost every implementation, and dodgy hardware that takes liberties with the specification. With all of that to build upon, the highest goal attainable for any new Bluetooth project is an end product that sucks in direct proportion to the combination of noise, bad software, and dodgy hardware. Best case scenario: it sucks, but maybe not so badly that distracted insouciant people will notice during the warranty period.
    That said, bluetooth headsets seem to work more than half the time, on average. Yay!

    • Andreas Spiess
      Andreas Spiess  Год назад

      I can not complain about BLE. So far it does the job as expected on my smartphone connecting different devices. But of course, I only use it on short distances. But it seems not easy to write software for it...

  • SeanHodgins
    SeanHodgins Год назад +3

    That was very helpful. I have a quite a few projects that could benefit from more knowledge in BLE technology.

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      We all have such ideas. But it is still a way to go till we will master it as we master Wi-Fi now.

  • Giampiero Raschetti
    Giampiero Raschetti Год назад

    Excellent work as usual Andreas. I had some experience with modules such as HC08, but working with esp32 is a completely different and better world. Thanks a lot

  • Martin Robotz
    Martin Robotz Год назад

    Very useful tutorial on BLE, not the usual IoT stuff for internet connected nonsense gadgets. While IoT has no more secrets left, BLE is still a mistery for makers. Because there is no literature on Arduino BLE this video is a valueable knowledge base.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thanks! And I hope, I can continue this way...

  • Doug Manatt
    Doug Manatt Год назад +1

    So many fun references to others great youtube channels!

  • squall513
    squall513 Год назад

    Thank you for the video! A great watch and you've taught so much in so little time.

  • Eman Jones
    Eman Jones Год назад

    Nice video, love your style :)

  • Daniel Garcia
    Daniel Garcia Год назад +3

    Great video as always!
    Finally a good bluetooth tutorial.
    So excited for part 2! :)
    P.S. I'm a lazy nerd. I use water with salt to make fake sweat (fast and easy way to make a electrolyte solution) xD

    • Andreas Spiess
      Andreas Spiess  Год назад +2

      Concerning water and salt: This is what I also did at the end ;-)

  • Verlinden Wim
    Verlinden Wim Год назад +1

    Hi Andreas, nice to see the first video about BLuetooth with ESP. Can I suggest an interesting subject for a future video? The Chinese manufacturers of ESP based products all use "SmartConfig", a clever way to connect in seconds a new ESP with a smartphone and cloud on any WiFi network, without the need to go to the ESP by webinterface or serial. They use some UDP broadcasting by the App if I understand it correctly, that includes the WiFi credentials in the packet. Unfortunately I can not find a lot about it and would like to understand it better, I think it is interesting for all your viewers too....thanks in advance!

    • Verlinden Wim
      Verlinden Wim Год назад

      www.espressif.com/sites/default/files/30b-esp-touch_user_guide_en_v1.1_20160412_0.pdf

    • Verlinden Wim
      Verlinden Wim Год назад

      There is not a lot available, it is a bit mysterious, but I see it more and more used in the Chinese products and App's. It seems to be part of the Espressif functions. For Arduino I found : tzapu.com/esp8266-smart-config-esp-touch-arduino-ide/ Hope that helps. Thanks in advance. Wim

    • Andreas Spiess
      Andreas Spiess  Год назад

      I do not know this. Can you help me with some more info to give me a quicker start?

  • Charles Thatisall
    Charles Thatisall Год назад

    Damn, I need a new phone... :P
    Very interesting video, as always ! :)

  • Confused Wolf
    Confused Wolf Год назад

    At this rate you will be up for role in new marvel supernurd film (working out)?

    • Andreas Spiess
      Andreas Spiess  Год назад

      Maybe my "Arnold Schwarzenegger" accent even helps there ;-)

  • Chris B
    Chris B Год назад

    Lol, running up stairs. You would kill me doing that.

  • Philip Gevaert
    Philip Gevaert Год назад

    Interesting, looking forward for the next video(s) on this topic.

  • Cornee
    Cornee Год назад

    +1 for the flower sensor ;)

  • Roelski unPlugge d
    Roelski unPlugge d Год назад

    Excellent as always! Not afraid to learn and try things. And in the progress of learning, we also learn! As for the xiaomi sensors: I have used a script from github.com/ChristianKuehnel/ to read the sensors in my home automation (pimatic on rpi). As the script is in python, a lot can be learned (at least I hope you can) about ble and the sensors. Hope it will help!

  • Asger Vestbjerg
    Asger Vestbjerg Год назад

    Thanks for sharing 😀👍

  • Dean Greenhough
    Dean Greenhough Год назад

    Morning Andreas😀
    Great work yet again my friend👍👍👍👍
    Your amazing 👈

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      Thanks, Dean. I finally subscribed to your channel. You officially doubled the number of subscribers!

  • Spikey DaPikey
    Spikey DaPikey Год назад

    Great AvE reference :oD

    • Ted Timmons
      Ted Timmons 11 месяцев назад +1

      chooch

    • Jens Jensen
      Jens Jensen 11 месяцев назад +1

      Yeah I can’t watch ave with kids around. Thankfully the Swiss guy is more family friendly.

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      :-)

    • electron1979
      electron1979 Год назад +1

      Skookum

  • Fiachra Matthews
    Fiachra Matthews Год назад +1

    So it’s possible that polar have what is like a subdomain of Bluetooth mac addresses and the watch won’t connect to any device outside that domain. That’s how we did it with ours. As you learned, without direct disconnection ble will assume it’s still connected the other device has just gone out of range ( I think timeouts are pretty long). While connected it won’t transmit advertising packets and (I think) will refuse other direct connections. The other think to contend with when trying to spoof commercial devices is pairing is different between BLE and BT Classic but depending on how their security is setup there’s usually a handshake that involves key exchanges and the server adding the clients to a trusted device list. All in all BLE is way easier to work with than classic but it does have some really irritating gotchas that are very confusing.

    • Thomas Bland
      Thomas Bland 11 месяцев назад

      The high order 24 bits of the UUID is the company code similar to how MAC addresses have an assigned company code in the high order bits. The low order 24 bits are supposed to be unique per device and allows a company to manufacture over 16 billion devices before running out of available UUIDs.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thank you for your insight. It explains a few things for me. I still have to learn a lot and there is not a lot of info out there, or it is so complicated I do not understand it. So I will try to go step by step...

  • northshorepx
    northshorepx Год назад +3

    eewiki.net/display/Wireless/A+Basic+Introduction+to+BLE+Security makes interesting reading. I think spoofing the devices is going to be harder than just adverting if the manufacturer has properly implemented security.

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      Thanks for the link. I will have a look at it.

    • northshorepx
      northshorepx Год назад +1

      thank you fixed it now

    • Alexander Sandberg
      Alexander Sandberg Год назад

      Haha totally missed that, thanks

    • SeanHodgins
      SeanHodgins Год назад +1

      Remove the second bracket which included itself in the link. eewiki.net/display/Wireless/A+Basic+Introduction+to+BLE+Security

    • Alexander Sandberg
      Alexander Sandberg Год назад

      page not found... :( can you link again? Or are you logged in to the site so you have permission to view it?

  • NS Gaming
    NS Gaming Год назад +1

    Maybe the watch checks those hardware version and id and stuff and only works if they are correct too.

    • Gerriko io
      Gerriko io Год назад

      You need to "construct" your data type for the heart rate measurement characteristic - you cannot send just a value as the watch won't know how to interpret. First you have to set your flags, which are represented in 8 bits. Depending on which bit is set will determine whether the heart rate value (bpm) is uint8 or uint16, similarly, flags are also used to show that an optional "Energy Expended" uint16 value is sents etc.

    • Andreas Spiess
      Andreas Spiess  Год назад

      I think you are right. I have to investigate further...

  • Максим Сафронов
    Максим Сафронов Год назад +11

    Hi, mr. Spiess. I think I know the main reason why your watch did not recognize the ESP32. The main reason could be simple: The data format sent by the ESP32. I've checked the official description of "org.bluetooth.characteristic.heart_rate_measurement" and find the "Heart Rate Value Format bit", which is setting the "org.bluetooth.unit.period.beats_per_minute" value type to UINT8 or to UINT16. "Note: The format of the Heart Rate Measurement Value field is dependent upon bit 0 of the Flags field."

    • Максим Сафронов
      Максим Сафронов Год назад

      So, we need to find another device for reverse engeneering :D

    • mispeaced
      mispeaced Год назад +1

      Polar uses 4 protocols - GymLink (non-coded), GymLink, Wind, Bluetooth. FT60 watch on video is only compatible with GymLink heart rate devices (T31,H1,H2,H7,H10) - it doesn't work over BLE. And H7 sensor provides both GymLink+Bluetooth compatibility. So, H7 works over GymLink with FT60 watch and over Bluetooth with smartphones/esp32/.
      This info can be found here: support.polar.com/en/support/compatibility_with_my_Polar
      How do I know that? I also owe H7 + FT4 watch (GymLink only) :)

    • chegewaras
      chegewaras Год назад

      This is not about more knowledge, i thought it is possible so i did study bluetooth specs and ive found it is working. Since you are talking about mr Neil's Kolban stack it would be pleasure to explain how to make it working on his "ground". IMO youtube is not the place to talk about issues and code which dont belong to you.

    • Andreas Spiess
      Andreas Spiess  Год назад

      Thank you for your help. I will come back if I go the H7 route further (or go the "issues" way on Neil's GitHub). For the moment, I am still learning the basic basics. But it is good to know that I have viewers with much more knowledge.

    • chegewaras
      chegewaras Год назад

      Close enough.

  • northshorepx
    northshorepx Год назад

    oooh so close!!!! Great intro to BLE Andreas. Thinking about your connections to existing devices (like the watch) made me think that the manufacturer is putting device specific info in the connection protocol and this is what prevents third parties from spoofing the server. I had a v. quick look at this docs.mbed.com/docs/ble-intros/en/latest/Introduction/BLEInDepth/ and it talks about a device information services. Perhaps that's what we need to hack correctly in the sketch. Then I thought perhaps a sniffer would be useful so I did a quick search and this popped up - www.adafruit.com/product/2269

    • Gerriko io
      Gerriko io Год назад +1

      Yes this is quite likely. When the watch searches for a device to connect to, it will look for specific advertising data and can filter out non relevant devices. The nRFconnect app should help here. If you click on the device but do not connect with it, you can see what information is sent as advertising data packets. This should help.

    • Andreas Spiess
      Andreas Spiess  Год назад

      I once had a Texas instruments sniffer running, but was no more able to make it work this time. I only remember that the interpretations were very complicated. So, for the moment, I have to stick to the surface. But for, later on, this is for sure a good device.

  • Arthur Yarnell
    Arthur Yarnell Год назад

    Excellent.

  • anlumo1
    anlumo1 Год назад +3

    Are you including the service in the announcement? This could be the problem why some devices can't find the BLE server.

    • Andreas Spiess
      Andreas Spiess  Год назад

      I think so, but I am still scratching at the surface... There are other suggestions what can go wrong. So, still, a lot to be done.

  • solidfuel86
    solidfuel86 Год назад

    try to specify the Bluetooth MAC of the device you want to connect to. this way you can force the client to connect to your esp32 and not to the polar

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      You are right, this is a possibility. But as far as I understand, would be against the idea of working with services. And usually, I will not have two devices with the same service, or I have to find a way for the client to deal with it in its program.

  • ThomasHaberkorn
    ThomasHaberkorn Год назад +7

    Please continue your BLE effort! Thank you for your support.

  • John Spounias
    John Spounias Год назад

    The people who built the arduino library worked hard on it. I have been watching the threads for a while and have some firmware which use it. I also converted this github.com/objectsyndicate/Kotlin-BluetoothLeGatt from java which helps people build BLE apps on android with Kotlin (which I prefer by far to Java)

    • Andreas Spiess
      Andreas Spiess  Год назад

      So you are far in front of me! I hope I will be able to close-up a little in the next months.

  • Andrew Rain
    Andrew Rain Год назад +9

    Best use for BLE-enabled esp32 would be presence sensor that detects phone. If phone is within the range - HomeAlarm is deactivated, or something like that. Do you think you can implement it?

    • chegewaras
      chegewaras 11 месяцев назад

      blog.bluetooth.com/part-2-how-do-smart-locks-and-bluetooth-work-to-keep-your-home-safe?_ga=2.26603133.1388292024.1514452135-134914153.1514452135

    • Andrew Rain
      Andrew Rain Год назад +1

      Well, I guess you do :)

    • Andreas Spiess
      Andreas Spiess  Год назад +6

      I already did a Wi-Fi sniffer with MQTT and maybe, one day, I will be able to offer a similar Bluetooth sniffer. Who knows?

    • Andrew Rain
      Andrew Rain Год назад

      Well, not really. Yes, PIN is only 6 digits but you can setup timeouts or even better - MAC address check.

    • Wowthatsfail
      Wowthatsfail Год назад

      Andrew Rain that's too easy to break into with just a laptop

  • Илья Гирс
    Илья Гирс Год назад

    error build "C:\Users\Girs\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLEClient.cpp: In member function 'void BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t*)':
    C:\Users\Girs\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLEClient.cpp:126:78: error: 'struct esp_ble_gattc_cb_param_t::gattc_notify_evt_param' has no member named 'srvc_id'
    BLERemoteService *pBLERemoteService = getService(BLEUUID(evtParam->notify.srvc_id.id.uuid));
    ^
    In file included from C:\Users\Girs\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLEClient.cpp:9:0:"

    • Илья Гирс
      Илья Гирс Год назад

      try amd and core i7 ,windows 10 sys not work

    • Илья Гирс
      Илья Гирс Год назад

      i reinstall all , not work,lasted version all

    • Andreas Spiess
      Andreas Spiess  Год назад

      Maybe you do not use the newest version of the ESP32 environment. In my case, the examples worked.

    • Илья Гирс
      Илья Гирс Год назад

      errors building example code yours lib

    • Andreas Spiess
      Andreas Spiess  Год назад

      ???

  • AfricanWizz
    AfricanWizz Год назад +1

    Thanks for the video, it's great that you show the fails as well!

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      And they happen more than you can imagine ;-)

  • rodstartube
    rodstartube Год назад +1

    Hello andreas nice video about Bluetooth. Apart: can you do a video about ESP WiFi security? I mean, connect several smartphones to an ESP8266 (or ESP32) and prevent brute force password attack, MAC address authentication before connecting (whitelist in sd database), to hide SSID, change SSID name, to set a password to “builtin” router, and if it is possible to auto disconnect a client after a given period (example 1 minute), in other words to make connection as secure and un-hackable as possible. I know you are the one.

    • Anders Jackson
      Anders Jackson Год назад

      Just use encryption/signing with asymetrical encryption (that is certificates like when making connections to XMPP, HTTPS and MQTT with certificate) and use WPA2 connections.

    • Anders Jackson
      Anders Jackson Год назад +2

      To hide SSID do not make a WIFI any securer. That is an old missconception. On the contrary, it will make the clients less secure, and the attacker can anyway get the SSID to use by just listening- Neither are MAC address authentication (whitelist of MAC addresses) increasing the security. MAC addresses are easy to fake.
      Please don't do that or suggest that as a security matter.

    • Andreas Spiess
      Andreas Spiess  Год назад +1

      Unfortunately, I have no clue about security. So somebody else has to do this.

    • rodstartube
      rodstartube Год назад

      I mean to be a strong connection in a community of authorized users, but what if a user wants to fraud or clone MAC address into other smartphone to allow access? Example: a building's automated door with smartphone over WiFi without using a PC or a raspberry or similar/equivalent linux equipment. (MQTT or just an HTTP request?)

  • Christian Ivarsson
    Christian Ivarsson Год назад +5

    AvE! :D

    • Jens Jensen
      Jens Jensen 11 месяцев назад

      Yeah I can’t watch ave with kids around. Thankfully the Swiss guy is more family friendly.

    • Andreas Spiess
      Andreas Spiess  Год назад +2

      :-)

    • Ruben Lensvelt
      Ruben Lensvelt Год назад +1

      Good enough for the girls I go out with!

  • Cristi Istrate
    Cristi Istrate Год назад +4

    Nice introduction in BLE. I hope you make more on this topic as I am very interested.

  • rodstartube
    rodstartube Год назад

    *¿¿ ARDIONO ??*

  • Joey Novak
    Joey Novak Год назад +1

    First!

    • Andreas Spiess
      Andreas Spiess  Год назад

      I try to answer all the comments. And so far it is still possible.

    • Joey Novak
      Joey Novak Год назад

      Andreas, p.s. I LOVE your videos. Super helpful to stay on top of what's going on in the small computing area and great introductory videos. Thanks for the reply. Makes me feel important :)

    • Andreas Spiess
      Andreas Spiess  Год назад +2

      :-)