Find and Connect to Com Port for Arduino with PySerial - Serial Communication

Поділитися
Вставка

КОМЕНТАРІ • 58

  • @StarChild.no1
    @StarChild.no1 3 місяці тому

    Wonderful. Today I stopped having to reboot my raspberry pi. Bonus, Codium AI took over(without me asking) and optimized the code for performance, exception handling and best practices.

  • @ChrisAnja
    @ChrisAnja 3 роки тому +1

    Simple, but i thought would be useful. I was work at electronic company, but dont know any programming language yet. Lately learn Python as it community base good, and lot of module. Glad to know that i can use Python also on electronics (even i hear lot people python has slow performance, but stil its good for starter)

  • @sameerk12982
    @sameerk12982 3 роки тому +1

    Hello from India... Thank you very much for this easy to understand and very helpful video.

    • @WaveShapePlay
      @WaveShapePlay  3 роки тому +1

      Hello my friend, thank you for watching!

  • @rverm1000
    @rverm1000 5 років тому +1

    Its refreshing to realize Im getting good enough to troubleshoot the program if something isn't going right

  • @j.p.wagner6461
    @j.p.wagner6461 3 роки тому +1

    Holy smokes - this is what I've been seeking for about the last two weeks .. thank you !
    Some disgruntled idiot at work decided to leave the company with his HW & SW (python) in a complete clusterfucked state of fubar. No commenting whatsoever .. what a special kind of prick, right ?
    Well this tutorial got me back making progress with this diaper-change of a task. Thank you again ..

    • @WaveShapePlay
      @WaveShapePlay  3 роки тому +1

      This is my favorite comment of all time! Glad you found it useful my friend.

  • @Diwakar007you
    @Diwakar007you 5 років тому +6

    AT LINE 18: port= foundports[i] should be replace by portsfound[i]

  • @hetalpandya6137
    @hetalpandya6137 4 роки тому +2

    EXACTLY WHAT I WAS SEARCHING FOR!!!!

  • @vikashkumar-cr7ee
    @vikashkumar-cr7ee 2 роки тому +1

    Hi there, I can find only USB serial CH340 in device manager port (which is connected to COM 3. I can't find Arduino UNO in the device manager port which is why I am getting an error "'SerialException: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)"' . Could you please tell me how to add arduino in port ?

    • @thomasvos138
      @thomasvos138 2 роки тому +1

      Hi! I have the same problem, Have you found a solution?

    • @SolomonTeklehaimanot-d8f
      @SolomonTeklehaimanot-d8f Рік тому

      when i run that code i commit the error =UnboundLocalError: local variable 'commPort' referenced before assignment. your question is similar to mine. have you got solution recently my brother tell me if you got please!!!

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

    Thanks ...very much
    your simple code
    to be easy learn and correct program

  • @SolomonTeklehaimanot-d8f
    @SolomonTeklehaimanot-d8f Рік тому

    interesting video.
    I tried this without changing code but when I run it the following error is found.
    Cell In[4], line 17
    connectPort=findArduino(foundPorts)
    Cell In[4], line 15 in findArduino
    return commPort
    UnboundLocalError: local variable 'commPort' referenced before assignment
    ****how could it be resolved tell me please!!!!!!!

  • @timothynicholson8231
    @timothynicholson8231 5 років тому +1

    I'm on a mac and the USB devices are read differently. How could one modify this code to use the USB's Manufacturer information to automate finding the Arduino? The following code seems to do the trick, but how can one have python double-check the connection? Thank you for your help!
    import serial.tools.list_ports
    def findArduino(manufacturer):
    for pinfo in serial.tools.list_ports.comports():
    if pinfo.manufacturer == manufacturer:
    return serial.Serial(pinfo.device)
    raise IOError("Could not find an arduino - is it plugged in?")
    ser = findArduino(manufacturer='Arduino (www.arduino.cc)')

  • @Priyanka-hf2qm
    @Priyanka-hf2qm 5 років тому +2

    HELLO @WaveShapePlay
    PLEASE TELL ME HOW TO FIX THE ERROR: "typeerror 'generator' object is not subscriptable" AT LINE 18: port= foundports[i]
    please reply

    • @Priyanka-hf2qm
      @Priyanka-hf2qm 5 років тому

      anyone there??, please reply, I am in need.

    • @TechnoTinker
      @TechnoTinker 5 років тому +1

      @@Priyanka-hf2qm I know it's a little late, but perhaps if you cast it with list(foundports)[i] it might work. The other thing is possibly if it didn't find any ports, it might throw that error (just a guess).

    • @martijnvenselaar4760
      @martijnvenselaar4760 5 років тому

      @@TechnoTinker i ran into the same problem but this works indeed

    • @danielinfantes1799
      @danielinfantes1799 2 роки тому

      Replace the statment 'port = foundPorts[i]' by 'port = portsFound[i]'

  • @tomgruenewald8106
    @tomgruenewald8106 7 років тому +1

    Hi, thanks for the good videos!
    Do you have an idea how I can identify multiple Arduinos on the same Host and connect do a defined Arduino?

    • @skeletar85
      @skeletar85 6 років тому

      if they were different types you could do
      if 'Arduino Uno'
      if 'Genuino'
      etc...
      if they were the same type, i am not sure. posibly it would be Aduino (1) and adiuno (2)

  • @charlesklein7232
    @charlesklein7232 5 років тому

    i was just looking for the exact video but i dident know what to type in to search for it and it appeared on my screen when i logged into utub. THANK YOU but in Linux or Ubuntu it displays its port in arduino.

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

    Is there a way to have this work on either mac or windows devices?

  • @LopserGaming
    @LopserGaming 3 роки тому

    This list ports function is hidden in the documentation, thanks for sharing this!

    • @WaveShapePlay
      @WaveShapePlay  3 роки тому +1

      Thank you for watching!

    • @LopserGaming
      @LopserGaming 3 роки тому +1

      @@WaveShapePlay hey quick question, on my device manager my arduino is just showing up as USB serial device but in the IDE the board is recognised. I’m on windows 10, I can’t find any quick fixes online. Do you know how to sort this? Thanks :)
      I’ll be using pyserial on a bunch of PCs and trying to automate stuff so it would be nice if the port is named as “COM3 (Arduino Uno)” or whatever.

    • @WaveShapePlay
      @WaveShapePlay  3 роки тому +1

      That is Interesting. I did find a Arduino forum thread that is trying to solve that exact issue here:
      forum.arduino.cc/t/device-description-under-device-manager-windows/73011/7
      It looks like the .INF file in the arduino drivers helps define how windows defines the device. I have not personally tried this solution yet, but it is worth a try!

    • @LopserGaming
      @LopserGaming 3 роки тому +1

      @@WaveShapePlay thank you!!!

  • @miguelbustamantesubiabre2576
    @miguelbustamantesubiabre2576 7 років тому +2

    excellent, great work!

  • @bhanuprakashreddy
    @bhanuprakashreddy 3 роки тому

    i am getting empty list like [ ], how to solve this

  • @stifenjans4342
    @stifenjans4342 2 роки тому

    Any suggestion group of people work with these kind arduino n python stuff to join, this library kind a least update, im not to familiar with javascript or johhny5, thank u, my appologize if my text seem worst

  • @Mecatronicgarage
    @Mecatronicgarage 2 роки тому +1

    HI, excellent video. When i try to run the code i get this error: ModuleNotFoundError: No module named 'serial.tools', I have installed the PySerial library but the error keeps showing up. Has it happened to anyone ? Thanks.

    • @annikenkvalsund5393
      @annikenkvalsund5393 2 роки тому

      That happens to me too! Did you find any solution?

    • @Mecatronicgarage
      @Mecatronicgarage 2 роки тому +1

      @@annikenkvalsund5393 My problem was in the python version.
      At first I installed the latest version of python, but then I found that the version was not compatible with w10, so I went looking for a compatible version, then I reinstalled everything including the Pyserial packages again.

    • @annikenkvalsund5393
      @annikenkvalsund5393 2 роки тому +1

      @@Mecatronicgarage Thanks! I reinstalled python and every package, too, that seemed to do the deal

  • @bayramalak2673
    @bayramalak2673 4 роки тому +1

    Excellent buddy!

  • @juancarlossoto3748
    @juancarlossoto3748 3 роки тому

    What is the problem here? AttributeError: module 'serial' has no attribute 'Serial' ??????

  • @harwindsingh
    @harwindsingh 5 років тому +1

    Helped a Lot

  • @4BohrKid
    @4BohrKid 2 роки тому

    Goat

  • @sergei4203
    @sergei4203 7 років тому +1

    Thanks a lot. Please leave a link to the program code in another video.

    • @WaveShapePlay
      @WaveShapePlay  7 років тому

      You got it! Here is the link for convenience: github.com/WaveShapePlay/ArduinoPyserialComConnect

  • @TheFreshDeals
    @TheFreshDeals 4 роки тому

    thanks good script i'll use it for make my own arduino serial monitor

  • @rverm1000
    @rverm1000 5 років тому

    Do you arduino code for the arduino in this video.?

  • @VasylKripko
    @VasylKripko 2 роки тому

    why you need to parse some output of __str__ if you can directly access list_ports_common.ListPortInfo fields?
    Your "code reuse" just obscures real meaning of what that function does
    def find_port_by_description(substring):
    port: list_ports_common.ListPortInfo
    for i, port in enumerate(list_ports.comports()):
    if substring in port.description:
    return port.device
    return None
    that would be much cleaner solution in my opinion

  • @gedtoon6451
    @gedtoon6451 2 роки тому +1

    I use the following function which will find genuine Arduino boards and clones using the CH340 and CP210 USB to serial chips.
    def find_arduino():
    ports_found = serial.tools.list_ports.comports()
    port = 'None'
    look_for = ["Arduino", "CH340", "CP210"]
    type = None
    for l in look_for:
    for p in ports_found:
    str_port = str(p)
    if l in str_port:
    type = l
    port = str_port.split(' ')[0]
    break
    if port != "None":
    break
    return port, type

    • @SolomonTeklehaimanot-d8f
      @SolomonTeklehaimanot-d8f Рік тому

      you created very nice function !! let me ask you, after executing this function how can you access the port found? or, how can I incoporate your function to the code=ser= serial.Serial( ,9600)? I am waiting to your response please tell me!!!

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

      @@SolomonTeklehaimanot-d8f Hi. I assume you realise that you need to load the arduino with a sketch that can receive commands and return data via its serial port. In the python program, my function looks for ports that could be connected to an arduino or clone. It returns a tuple, where the first element is a string with the port name found, i.e. "CH340". If the name is "None", no port was found.
      The second element in the tuple is the port name, i.e. "Com 4". You use this in your pyserial com port open command. Hope this helps.

  • @icebs5443
    @icebs5443 3 роки тому

    Спасибо за этот гайд !

  • @rafaeldsplay
    @rafaeldsplay 4 роки тому

    I LOVE U, MAN

  • @gopro2804
    @gopro2804 3 роки тому

    In line 21 change 'Arduino' to 'CH340' for chines clone boards.

    • @gedtoon6451
      @gedtoon6451 3 роки тому

      I have added a 'if else' block that first looks for 'Arduino' then CH340 and finally 'CP210X'.

  • @lazyDev02
    @lazyDev02 4 роки тому

    thanks man