How to make a Bluetooth remote using a Raspberry Pi Pico W and MicroPython

Поділитися
Вставка
  • Опубліковано 7 лип 2024
  • How to make a Bluetooth remote using a Raspberry Pi Pico W and MicroPython.
    Sponsored by PCBWay: www.pcbway.com
    PCBWay, your ultimate destination for PCB manufacturing and assembly. Whether you're a hobbyist, a startup, or a seasoned professional, PCBWay has got you covered.
    Pimoroni Display Pack 2.0: collabs.shop/rdjhin
    Join this channel to get access to perks:
    / @kevinmcaleer28
    💁‍♂️ For more information on SMARS Robots, tutorials and more visit: www.smarsfan.com​
    🎖To join the membership at 🥉bronze, 🥈silver or 🥇gold levels, head over to
    www.smarsfan.com/membership
    Join the list - action.smarsfan.com/join-the-...
    ☕️ Enjoy this video? Buy me a coffee! www.buymeacoffee.com/kevinmca...
    📸 Follow me on Instagram - @kevinmcaleer / kevinmcaleer
    🐦 Follow me on Twitter - @kevsmac / kevsmac
    🙂📘 Join the Facebook group - Small Robots / smallrobots
    👩‍💻 Bluetooth example Code on GitHub: github.com/kevinmcaleer/pico_...
    🎵 Music by Epidemic Sounds www.epidemicsound.com/referra...
    #Pico​ #MicroPython​ #Robotics
    00:00 Introduction
    00:10 Bluetooth Announcement
    00:28 Bluetooth Basics
    01:24 Profiles
    02:28 Bluetooth connection stages
    03:45 Generic Attribute Profiles
    04:19 Synchronous vs Asynchronous code
    06:25 Asynchronous coding
    10:00 BLE Services and Characteristics
    12:45 Demo - BurgerBot
    14:26 VS Code - creating the code
    14:38 Remote-control.py
    28:34 Debugging the code
    29:40 Bluetility
    31:47 testing remote_control.py
    31:59 robot_code.py
    43:57 Remotely Controlling the robot with bluetooth
    44:19 PCBWay Sponsor
  • Розваги

КОМЕНТАРІ • 59

  • @kevinmcaleer28
    @kevinmcaleer28  Рік тому +2

    The code created in this video is available at github.com/kevinmcaleer/pico_ble_remote - please Like and subscribe if you found this useful!

  • @penttiitkonen9765
    @penttiitkonen9765 Рік тому +12

    Finally someone has started making examples and tutorials for Pico BLE. Thanks to Kevin.

    • @alexanderpoplawski577
      @alexanderpoplawski577 11 місяців тому

      It also shows how Copilot can assist with programming, but you still have to know what you are doing.

  • @dougblanding8791
    @dougblanding8791 10 місяців тому +3

    Thanks, Kevin! Excellent tutorial on how to get BLE working between 2 Pico devices. I love the way you cover the history, the overview of the protocol, and the exquisite detail of your working code. I did get it working, by the way, but am having an issue with the remote crashing after about a minute.

    • @dougblanding8791
      @dougblanding8791 9 місяців тому +4

      OK, I finally figured out what was causing this problem. The default value of timeout_ms for client connection is 60 seconds. You have to make a small edit in the code: `await connection.disconnected(timeout_ms=None)`

  • @keithlohmeyer
    @keithlohmeyer Рік тому +1

    One of the first demo tutorials to highlight BLE on the Pico. Thanks!

  • @AerialWaviator
    @AerialWaviator Рік тому +2

    Great tutorial. Had not realized that Bluetooth update was recently released for Pico W. Very timely and through coverage.

  • @philjarvis6729
    @philjarvis6729 Рік тому +1

    Nice example - thanks Kevin

  • @MeArmTM
    @MeArmTM 11 місяців тому

    Fantastic introduction, perfect level of detail, interesting and fluently explained. Cheers Kevin.

  • @lorisrobots
    @lorisrobots Рік тому +2

    Thanks for sharing how to get started with BLE on the Pico! Great work.

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому +1

      Thanks Lori - it was a bit of a learning curve, but the solution is straightforward

  • @Syntax152
    @Syntax152 10 днів тому

    Will you please also make an video for an pico w Bluetooth HID device ? couldn't find any info for it. Great video and thanks a lot

  • @bbmorgan100
    @bbmorgan100 5 місяців тому

    Thank you so much for making this video. You never really finished the discussion of how we get the whole thing to start over. I think the "alive" bit is the key, but I'm having trouble with it. The robot blink task contains a "while True and alive". But that means the blink function runs and closes faster than the peripheral task can get the connection so it never blinks.

  • @matthewchadwick9805
    @matthewchadwick9805 Рік тому +1

    Thanks! Very helpful explanations on how to make use of Bluetooth with the Pico using Micropython.

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому

      Thanks, Matthew! I really appreciate your support

  • @antlister
    @antlister Рік тому +1

    Superb presentation. Keep up the great work and support for MicroPython.

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому

      Thanks for the feedback, this really does encourage me to make more

  • @ingermany1523
    @ingermany1523 11 місяців тому +1

    Thanks for the video. I am starting to develop a pasthrough Bluetooth keyboard/mouse to the USB HID.

    • @kevinmcaleer28
      @kevinmcaleer28  11 місяців тому

      Awesome - do share your progress too!

  • @LoloisKali
    @LoloisKali 11 місяців тому +1

    Bro im in canada thank you for this , for beginners this is good information on asynchronous programming with micro-python!
    I subbed and will continue to watch and share your videos!

  • @lykkeligal
    @lykkeligal Рік тому +1

    Great stuff. Thanks

  • @gargar3
    @gargar3 Рік тому +1

    Fantastic delivery thanks Kevin. You asked for immanent projects relating to Bluetooth... I have 2 PV inverters an SMA sunny and a Solis. I am planning to use a picoW with bluetooth to connect to the SMA and RS485 to connect to the Solis. I then want to ling this to my home wifi and provide the data to Home Assistant. I have other devices working on Home Assistant, and have a bluetooth app working on the SMA. I have yet to get the Solis RS485 working.

  • @makerbymistake
    @makerbymistake 6 місяців тому

    Kev, I'm working on a Canon camera remote control and this was helpful!

  • @marcdurbach7036
    @marcdurbach7036 Рік тому +1

    Very good tutorial, both on bluetooth as well as on async programming.
    Keep the good work, maybe by making a tutorial on transfering video stream from a camera connected to a pico based robot to a remote control ( either a pico with display, if possible, or on an iphone) 😊

  • @leightaylor8069
    @leightaylor8069 11 місяців тому

    Thank you so much for this video, very helpful. What is really stopping me is understanding what all these numbers mean and how to find out what numbers I should be using. For me BLE is a closed book at the moment, maybe you gave me a peek at the first page. How can I find out what numbers I should be using?

  • @mariemeyer2885
    @mariemeyer2885 8 місяців тому

    OMG! I just Coded Blue. The hardware I get, the software...not so much :( Great video Kevin, very informative...I need to watch it a number of times before I comprehend.

  • @lolonono2848
    @lolonono2848 9 місяців тому +1

    I have a quick question, can i use the same code if i want it to connect to my pc instead?
    (I am using windows 10)

  • @Greg-hs9jc
    @Greg-hs9jc 13 днів тому

    Hey, is it possible for the remote also to receive data from the bot? So both devices could read and send data? Try it for a few days but without success... Although your code is great and helps me out pretty good

  • @schippche29
    @schippche29 8 місяців тому +1

    Hello Kevin,
    I am desperately trying to build my child a robot but I can't make the remote control connection.
    Could you show in a video how to send
    array data (int+string) via Bluetooth
    from a Raspberry Pico W to a Raspberry Pi 4 Model B
    please ?
    That would help me sooo much :)
    Kind regeres,
    a Fan

  • @williamjordan2714
    @williamjordan2714 2 місяці тому

    Do you know if CircuitPython 9.0.3 can support BLE as well. I have tried a basic test and am getting _bleio.BluetoothError: Adapter not enabled when trying to construct the BLERadio() object.

  • @guythegeek
    @guythegeek 8 місяців тому

    Hi Kevin nice video. Do you think we can code a RPI Pico W as a BLE to WiFi gateway with MicroPython ?

  • @philjarvis6729
    @philjarvis6729 11 місяців тому +1

    Hi love the example - any Idea why I consistently get a 'GattError' after approx 1 min, regardless of any btn activity - this cause's both pico W's to raise an Error, I altered the asyncio.sleep_ms to 50 in the remote code - has no effect. Both devices have the latest pimoroni firmware build (v1.20.3 23-06-19)

    • @dougblanding8791
      @dougblanding8791 9 місяців тому

      try editing the server code to set the timeout=None.
      `await connection.disconnected(timeout_ms=None)`

  • @robertbock5898
    @robertbock5898 11 місяців тому +1

    Got the display from Pimoroni yesterday. I was wondering if the remote can work with the Pimoroni battery shim.

  • @robertbock5898
    @robertbock5898 Рік тому +1

    Are you using the pimoroni version of micropython or the plain vanilla micropython version 1.20? Good video. I plan to use it on the burger bot I built.

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому

      I’m using the Pimoroni version of Micropython 1.20.3

  • @robertbock5898
    @robertbock5898 11 місяців тому

    I would also like to know if the messages are printing on the display pack or just in the serial monitor.

    • @kevinmcaleer28
      @kevinmcaleer28  11 місяців тому

      I was just printing them to the serial monitor, however it would be reasonably easy to print them to the display pack. I've got a remote control project in the works, not quite ready yet.

  • @MrMontanaG
    @MrMontanaG 10 місяців тому +1

    Which bluetooth package/module do you use? How can I get vscode on my mac to recognize the package and eliminate errors like the following?
    "UUID" is not a known member of module "bluetooth"

    • @dougblanding8791
      @dougblanding8791 10 місяців тому

      You may have overlooked the advice in the beginning of the video where Kevin explains that you need to download and install the latest micropython firmware. Once you have done this, you can use Thonny to `import bluetooth` then do a `dir(bluetooth)` and you will find that `UUID` is indeed a member of bluetooth.

  • @HollyHertig
    @HollyHertig Рік тому +1

    I spent 2016 learning Arduino IDE. Now I gotta learn python.

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому

      Python is a beautiful language, once I learned a few bits of it there was no turning back!

  • @daedalus5483
    @daedalus5483 10 місяців тому

    Can I make a BLE Mesh network with multiple Pico W devices?

  • @kdt85
    @kdt85 3 місяці тому +1

    can we use a mobile phone as a remote? something like the dabble app? cheers

    • @kevinmcaleer28
      @kevinmcaleer28  3 місяці тому

      Currently no, that’s because dabble uses the Classic HID profile and MicroPython doesn’t support that (yet). You could do something like that with CircuitPython though

    • @kdt85
      @kdt85 3 місяці тому

      @@kevinmcaleer28thanks for the reply! I'll look into circuitpython, do you have a video about that? Cheers

  • @natavutkwankeo5070
    @natavutkwankeo5070 Рік тому

    I would like to have a code that can exchange short messages via BLE on a Pi Pico W

  • @williamjordan2714
    @williamjordan2714 2 місяці тому +1

    cui

  • @robertbock5898
    @robertbock5898 10 місяців тому +1

    Where do I get a Gallion Battery in the US? Pimoroni won't ship me one.

    • @kevinmcaleer28
      @kevinmcaleer28  10 місяців тому

      It’s the airlines who don’t allow lipo batteries to be shipped after those Samsung phone set on fire mid flight. Do Adafruit, Sparkfun or Digikey sell anything equivalent?

  • @t1000android
    @t1000android 6 місяців тому +1

    I keep getting an error: ImportError: no module named 'pimoroni'. Please help

    • @kevinmcaleer28
      @kevinmcaleer28  6 місяців тому

      You’ll need to install the pimoroni flavoured MicroPython - instructions and files can be found at www.github.com/pimoroni/pimoroni-pico

    • @t1000android
      @t1000android 6 місяців тому

      Thanks, I will and let you know of the outcome