Python Tutorial - How to Read Data from Arduino via Serial Port

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 มิ.ย. 2024
  • ** Copy/paste the code from here: www.tinkerassist.com/blog/ard... **
    These tutorials assume some basic understanding of Python syntax. If you are a beginner, there are plenty of resources available to quickly learn enough syntax to follow along.
    I am using Visual Studio Code editor to write these examples. To learn how to install VS Code and get set up for Python development, visit code.visualstudio.com/docs/la...
    Visit tinkerassist.com and Subscribe to the Tinker Assist Newsletter - keep up to date on what we are working on, and get your fix of programming, science, and engineering content straight to your inbox!

ความคิดเห็น • 66

  • @m.s.79
    @m.s.79 2 ปีที่แล้ว +4

    It is so great when one of the fist things that look for is exactly the one you need. Thank you very very much for this video.

  • @clicksandbeeps61
    @clicksandbeeps61 2 ปีที่แล้ว +4

    Thanks a lot mate! Great tutorial, explained better than the actual documentation. 👍

  • @user12sb
    @user12sb ปีที่แล้ว

    Thank you so much. This is great tutorial. Recommended!

  • @mohamednaimi7076
    @mohamednaimi7076 ปีที่แล้ว

    Thank you for this, it was very helpful!

  • @engineering-problems
    @engineering-problems 5 หลายเดือนก่อน

    Great explanation thank you , saved me ton of time.

  • @subrotoxing8214
    @subrotoxing8214 2 ปีที่แล้ว +5

    It would be great if you make a complete video starting from how you setup the arduino and the temp sensor ^^.

  • @cikgupython4567
    @cikgupython4567 2 ปีที่แล้ว +1

    Great tutorial!

  • @tiagot6916
    @tiagot6916 ปีที่แล้ว

    Thanks a lot! Great tutorial!

  • @aarjudixit
    @aarjudixit ปีที่แล้ว

    Thanks a lot dude for this wonderful tutorial. It helps me a lot.☺✌

  • @devyani_t05
    @devyani_t05 2 ปีที่แล้ว

    thnx dude.. this video really helped a lot!

  • @Bularistan4o
    @Bularistan4o 2 ปีที่แล้ว +8

    After literally 3 hours of trying to install pyserial, your code finally came alive. 100% what I wanted. Now I just have to see how to write the data in a file, preferably .csv. As someone that has only coded minecraft blocks on a RPi3, how I find another video like this hahaha

  • @cdhiva
    @cdhiva 2 ปีที่แล้ว +13

    Hey Andrew! Great tutorial! My guess is that you are new to python and have experience in either C/C++ or Java from your for loop. In python, you can iterate over a list (portList, in your case) with just add the below code after line 4.

    for port in ports: # You could replace “ports” with serial.list_ports.comports() to remove line 3 in your code.
    if port.startswith(“COM” + str(val)):
    portVar = “COM” + str(val)

    ^this would eliminate the necessity of code from line 6 to line 16.
    Kudos to you for helping me learn serial communication using Python.

    • @matthieuduflot3209
      @matthieuduflot3209 2 ปีที่แล้ว

      Also there will be an issue if you have a COM30 or COM31 or…

    • @freydaniel5134
      @freydaniel5134 ปีที่แล้ว

      program harus berjalan di C:\Users\jhoea\AppData\Local\Programs\Python\Python311\Lib\site-packages

  • @NawtieBoy96
    @NawtieBoy96 2 ปีที่แล้ว

    thanks alot , very nice tutorial

  • @inavigator1779
    @inavigator1779 ปีที่แล้ว +3

    God please bless this guy with a lot of pizzas and money and grant his every single wish

  • @firesports8953
    @firesports8953 3 ปีที่แล้ว

    hello, very nice tutorial, i have question is it possible to make it single line data?

  • @hitterobr
    @hitterobr ปีที่แล้ว +1

    you are literally a God on earth. Thank's for saving me

  • @agst480
    @agst480 ปีที่แล้ว

    Great content, thanks

  • @nouirimohammedelmehdi6642
    @nouirimohammedelmehdi6642 7 หลายเดือนก่อน

    thamks so much for this i apreciate it

  • @firealarmapprentice4517
    @firealarmapprentice4517 2 ปีที่แล้ว

    Great video. I am going to connect to my fire panel serial port. How do I set the parameters for bit, parity and stop bit ?

  • @gerardomtz8435
    @gerardomtz8435 4 หลายเดือนก่อน

    Thank you men!!!

  • @GoTechnobyMkBj
    @GoTechnobyMkBj 2 ปีที่แล้ว

    Thanks a lot for this awesome method. Can you help me further I have a question. I am using ESP32, and want to send AT command to it and then read the Response and use if conditions to do some actions based on the response. Can we do this with python? Please suggest!

  • @lahirusandaruwan6124
    @lahirusandaruwan6124 2 ปีที่แล้ว

    thank you grate video!!

  • @saraluciacontrerasojeda3939
    @saraluciacontrerasojeda3939 2 ปีที่แล้ว

    Thank you!

  • @deeppujara4566
    @deeppujara4566 ปีที่แล้ว

    Great Work

  • @syedfawad8245
    @syedfawad8245 3 ปีที่แล้ว +1

    Hello, very nice tutorial. I have been working on the opposite to this video content i.e. i have to send a list of integers from python to arduino. but i end overflowing the serial port and arduino going crazy. Please do a tutorial on that. THanks

  • @noe2540
    @noe2540 ปีที่แล้ว +1

    Hello ! Thanks for the tuto ! Does it works with Linux on a raspberry pi ?

  • @user-pn5th8kl6k
    @user-pn5th8kl6k ปีที่แล้ว

    Thanks a lot. This is what I want to learn.

  • @adeddy8138
    @adeddy8138 2 ปีที่แล้ว +1

    Can you do the reverse send from python to serial monitor? I really need it

  • @MIKKUCN
    @MIKKUCN ปีที่แล้ว

    Thank you so much 😀😀😀😀😀😀

  • @ferrari1
    @ferrari1 8 หลายเดือนก่อน

    Great video! Would you know how to read the same kind of data but coming from a WiFi connected Arduino such as the Arduino Uno R4 WiFi (not connected to a USB port)?

  • @noobpook5617
    @noobpook5617 9 หลายเดือนก่อน

    Thanks alot bro for your help

  • @creativesamurai8372
    @creativesamurai8372 ปีที่แล้ว

    Amazing video. Is there a chance you could make a py script video that could teach us how to send and receive serial data? ie. arduino sends "Ready" via serial. Python sees "ready" via serial and sends "im ready too"

  • @lavanyau4062
    @lavanyau4062 2 ปีที่แล้ว +1

    How to display for 2 values like temp,pressure???

  • @amirmohammadshamsi2955
    @amirmohammadshamsi2955 2 ปีที่แล้ว

    i can send data from tkinter and serial to another serial port and read it
    but cand receive
    my app crashing when want to read
    do you why?

  • @bektasari
    @bektasari 2 ปีที่แล้ว

    good video. but i take TypeError: Serial.open() missing 1 required positional argument: 'self' error .How can i fix this?

  • @AllanYolticGSolis
    @AllanYolticGSolis ปีที่แล้ว

    It is supposed that I have already installed pyserial like 3 times or so, and on Spyder it says that there is no module called serial, and on Visual it does not allow to use the port, and on issues it appears as a missing import. I need solve it asap.

  • @avyayjain7896
    @avyayjain7896 2 ปีที่แล้ว

    hey can you tell how to store data directly to MySQL from here
    need help asap

  • @mekatronikmuhendisi8420
    @mekatronikmuhendisi8420 2 ปีที่แล้ว

    I try to this python code with stm32 uart, but it's constantly on the line. after each character. How can I fix it ?

  • @benbenameur8429
    @benbenameur8429 ปีที่แล้ว

    Hello
    I am looking for the equivalent of : arduino.write("X="+str(200)+'
    ') in matlab .

  • @rikerthiessen5027
    @rikerthiessen5027 3 ปีที่แล้ว

    I have an Arduino printing data to the serial port every 100 milliseconds, but when I read the data in python and print it to the console, it does not print nearly as fast (maybe every 500 milliseconds?). Do you know of any fix for this?

    • @rikerthiessen5027
      @rikerthiessen5027 3 ปีที่แล้ว

      @@TinkerAssist_ I print 5 values, each separated by a comma, and the last one prints using Serial.println(), and that is followed by delay(100). I bumped up the baud to 115200 and it is printing slightly faster. I decided to use the time library to get the time difference between starting the method and finishing the method, where I print, and python is telling me it actually is 0.10xxxx seconds. However, I did realize that for some reason the prints show up in packs of 3 (I print the array of 5 values from the arduino in one line, my python output is printing the one line in packs of 3 though. it prints the last 3 input readings every 0.3 seconds, even though it is set to print every time the method gets called)... not sure why.

  • @anokhautomation4453
    @anokhautomation4453 2 ปีที่แล้ว

    Hi Sir.
    Can you please explain how we can control gpio pins of raspberry pi pico with python program via serial com port ??

  • @a-xp6ly
    @a-xp6ly 3 หลายเดือนก่อน

    I get a permission error when trying to read data from the port, anyone know why and how to fix?

  • @atuk5854
    @atuk5854 2 ปีที่แล้ว

    hello nice video, but i'm getting an error on 20.-21. line
    the error is :
    open() missing 1 required positional argument: 'self'

    • @atuk5854
      @atuk5854 2 ปีที่แล้ว

      thanks
      I figure out my solution

  • @joramotorsportteam3277
    @joramotorsportteam3277 2 ปีที่แล้ว +1

    Serial not halted after a few hours?

  • @fhier6
    @fhier6 8 หลายเดือนก่อน

    Can you take this one step further and make a video of how to save the serial port data to a .txt or .csv file?

    • @TinkerAssist_
      @TinkerAssist_  6 หลายเดือนก่อน

      Python Tutorial - How to Read/Write Data To/From .CSV Files and Basic Data Parsing/Manipulation
      th-cam.com/video/Nuo8-UrCDrM/w-d-xo.html

  • @shishworld1351
    @shishworld1351 2 ปีที่แล้ว

    Does it matter what kind of arduino I have?

    • @JustinS06
      @JustinS06 2 ปีที่แล้ว

      It shouldn't matter.

  • @riannata8309
    @riannata8309 2 ปีที่แล้ว

    how to save data bro ? thanks

    • @riannata8309
      @riannata8309 2 ปีที่แล้ว

      @@TinkerAssist_ ok, i am waiting for it, thanks

  • @taranjeetsingh1712
    @taranjeetsingh1712 2 ปีที่แล้ว

    source code link pls???

  • @palo_540
    @palo_540 ปีที่แล้ว +1

    Anyone else having issues with val = input("Select Port: COM")?
    For some reason Spyder crashes when this point is reached. What am I missing?
    P.S: For my IT friends, yes, I have tried turning it off and on (if you know, you know) ;)

    • @palo_540
      @palo_540 ปีที่แล้ว

      @@TinkerAssist_ thank you for the reply! i havent, and i surely will. hopefully it will work for me, as it did for the others in the github thread

  • @freydaniel5134
    @freydaniel5134 ปีที่แล้ว

    catatan : program harus berjalan di folder pithon.. dan port serial arduino dan python tidak boleh beradu/sama

  • @zeak_rlab
    @zeak_rlab 2 ปีที่แล้ว

    I cant do that T-T

  • @oggythepro
    @oggythepro 14 วันที่ผ่านมา

    Love you My Boy It helps so much Thank you!!!!!❤❤❤❤❤❤❤❤❤❤❤❤😍😍😍😍😍😍💖💖💖💖💖💖🌹🌹🌹🌹🎉🎉🎉🎉🎉🎉