No video

Arduino and Python Serial Communication with PySerial Part 1

  Рет қаралды 152,778

WaveShapePlay

WaveShapePlay

Күн бұрын

GitHub: github.com/Wav...
This video goes over how to use PySerial in order to use Serial Communication between the Arduino and Python. This allows us to expand the capabilities of our applications and projects - Part 1
Donate: www.paypal.com...

Пікірлер: 136
@SmilesChimichanga
@SmilesChimichanga 5 жыл бұрын
This is the best video I've found on this subject, Very clear breakdown of how the data is generated/transferred/handled. Thanks a lot!
@AliG.G
@AliG.G 4 жыл бұрын
Indeed one of the best by far
@yoente
@yoente 3 жыл бұрын
True
@chrismartinez9735
@chrismartinez9735 4 жыл бұрын
This is an excellent series. Every module is well articulated. I learned a lot!
@fibulacat5025
@fibulacat5025 3 жыл бұрын
This is the best tutorial I've ever seen. Thumbs up.
@jackmanjls
@jackmanjls 5 жыл бұрын
This is an excellent presentation. Clear, concise and enough detail to make this extremely useful. The only comment I would have is that the rate at which you poll the arduino. From what I roughly calc...The actual conversion took 4.58 µs for 12 bits in single conversion mode with a 2 MHz ADC clock. If you read any faster than that you may get inconclusive data. Any comments?
@stefanopadoan8684
@stefanopadoan8684 4 жыл бұрын
Fantastic! Simple, clear, useful! Thanks a lot!
@markm817
@markm817 Жыл бұрын
Sir, you said so clear that I can understand the knowledge, thank you wholeheartly.
@rsa4510
@rsa4510 5 жыл бұрын
Absolutely great tutorial! A lot of times, people posting "how to" videos skip the basics in their explanations. This leaves the beginner confused and unable to enjoy the steps associated with learning. I fully understood this tutorial, and I have hope that it will let me debug a related issue I'm having with my own application. Thanks for your work.
@rightdelo
@rightdelo 2 жыл бұрын
thanks for teaching and breaking it down into simple-to-understand terms. THANKS
@ArulFrances
@ArulFrances 3 жыл бұрын
Great Explanation! Keep up the good work! Thanks for sharing the amazing information!
@WaveShapePlay
@WaveShapePlay 3 жыл бұрын
Thank you for your kind feedback!
@halitekmekci8304
@halitekmekci8304 4 жыл бұрын
smooth exercise, thanks for that.
@cmoulali4835
@cmoulali4835 6 жыл бұрын
I like your videos on the Python ardiuno ,I excited Ooooo
@9205aidme
@9205aidme 4 жыл бұрын
Great work, keeps it really simple, but it works, gave me just the start I was looking for. Running Python 3.8.3
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Great to hear Gregory! That is definitely my goal. Thank you for the feedback!
@brandon_wallace
@brandon_wallace 3 жыл бұрын
This series on Pyserial is great and really helpful!
@swaralipibose9731
@swaralipibose9731 3 жыл бұрын
Best on the best
@vyashas4483
@vyashas4483 5 жыл бұрын
bro this was the best video that i found on this topic thx buddy. you explained it very well.
@anokhautomation4453
@anokhautomation4453 3 жыл бұрын
Very very useful information. And you explained in a clear way. 👍👍 Expecting more tutorials. Reading the same subject.
@ruancastro5973
@ruancastro5973 4 жыл бұрын
in my python version (3.7.6) i need to write ".decode('utf-8"')" instead .decode('ascii) . Great Video, thanks from Brazil for share the knowledge with us !
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Thank you for sharing Ruan!
@TyeDougherty
@TyeDougherty 3 жыл бұрын
Thank you sir I was wondering why the decode function was not working!
@alexoriginals
@alexoriginals 3 жыл бұрын
Raun, tudo bem, será que você poderia me ajudar? você consegue converter estes valores em integer? a sintaxe valor=int(arduinoData) não funcionou no 3.8
@HydeParkCAC
@HydeParkCAC 4 жыл бұрын
Thank you for posting! It was very helpful to see your coding with explanations such as how to use the decode command.
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Thank you for the feedback Jenny! It is confusing at first, but once you get the hang of it it becomes more clear!
@yeshu9985
@yeshu9985 2 ай бұрын
quick tip: close ur serial monitor before u start ur python code or else u would end up getting an error
@ManojKumar-pj8tr
@ManojKumar-pj8tr 4 жыл бұрын
Thnx this is the best tutorial I have come across
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Awesome to hear! Thank you Manoj!
@perinoveriza1658
@perinoveriza1658 3 жыл бұрын
You are the best brother 👍
@mohamedjaveed1366
@mohamedjaveed1366 5 жыл бұрын
Thank you so much for this!! Very well explained 👍
@Swesh99
@Swesh99 4 жыл бұрын
The first video that is realy helpful, thak you so much!
@diegogomez1640
@diegogomez1640 4 жыл бұрын
te mereces una medalla de oro al conocimiento, thank you by your aport
@paulramasco6769
@paulramasco6769 6 жыл бұрын
This is cool, will be helpful for my data acquisition devices.
@ishansmith549
@ishansmith549 5 жыл бұрын
very good series
@mehmetfesli5775
@mehmetfesli5775 2 жыл бұрын
This is a very good explanation!!
@gracewood6768
@gracewood6768 5 жыл бұрын
Oh wow i didn't know this Library is commonly used in Arduino =). My thesis uses this library to communicate on Router =)
@roflcopter645
@roflcopter645 6 жыл бұрын
Thanks for making these videos.
@darshanpanchal3046
@darshanpanchal3046 4 жыл бұрын
Hello sir, can i use pyserial to collect and process data from power analyzer or this works only with arduino?......please answer my question
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
If it uses the Serial protocol then yes. Perhaps look up the documentation for your power analyzer and see if there are existing examples.
@charanmakkar7732
@charanmakkar7732 4 жыл бұрын
smooth exercise, thanks for it sir , awesome stuff and in best easy way
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Glad you liked it!
@vaughntaylor2855
@vaughntaylor2855 2 жыл бұрын
Very nice tutorial, Thank you!
@user-sd9ff5yj2t
@user-sd9ff5yj2t 4 жыл бұрын
Nice video. Thanks man!
@idealzone3652
@idealzone3652 4 жыл бұрын
Im very interesting about this
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Great to hear, it really opens up a lot of applications for us!
@joecandoit5341
@joecandoit5341 5 жыл бұрын
Nice and clear. Thank you! You have a sub.
@kavyajohnson225
@kavyajohnson225 2 жыл бұрын
The video is explained excellently .I have a doubt regarding the timeout value , will be it be delaying the whole data transmission. I am doing a data rate calculation. So my doubt is regarding the timeout parameter. It would be very helpful to if I get a reply
@user-xu9rz7he2i
@user-xu9rz7he2i 3 жыл бұрын
Thank you, this is really helpful to me!
@wisesoar
@wisesoar 3 жыл бұрын
Hi, Thanks for the video. Is there a video talking how to set up the hardware? Which pins did you use from the adruino to computer? Did you use a USB to serial (e.g. UART) adapter or just the USB cable to arduino? Thanks.
@WaveShapePlay
@WaveShapePlay 3 жыл бұрын
Hey - I do not have a video for the Hardware setup, I can make one in the future. For this setup I am using standard USB interface for the Arduino UNO. It uses a USB cable type A/B to connect between the Arduino and the computer.
@sacredinclinations
@sacredinclinations 3 жыл бұрын
great job thanks
@ShivamKumar-rp8kr
@ShivamKumar-rp8kr 4 жыл бұрын
thanks man
@MilanKarakas
@MilanKarakas 3 жыл бұрын
Why it works sometime, and sometime not? Windows 10. Installed serial, but it complains that it is not installed. Once worked, then after changing parameters, does not work. Then again work... confusion.
@Inkieto92
@Inkieto92 5 жыл бұрын
why dont you need the following code in your void setup? pinMode(analogPin, INPUT); don't you have to tell it that it's an input pin?
@reactorark
@reactorark 4 жыл бұрын
Thanks a lot..!! best regads !!! great job,, SUSCRIBED.!
@punjabilog
@punjabilog 4 жыл бұрын
Thank you very much Sir, Its great video...
@cindyespindola4946
@cindyespindola4946 5 жыл бұрын
This video is great, easy to understeand and it works great. One question if someone can help me, is there a way to get the name of the connected port via script?
@baykus790
@baykus790 3 жыл бұрын
amazing. it works..
@WaveShapePlay
@WaveShapePlay 3 жыл бұрын
😎
@3Dprintingshorts
@3Dprintingshorts 2 жыл бұрын
I love your videos i hope you will make more advance tutorials regarding uart communication as well. Just sub to the channel.Love you bro
@n9583
@n9583 2 жыл бұрын
thank you so much but i have a question can you use the arduino mega instead of the arduino
@mrberry43
@mrberry43 5 жыл бұрын
Many thanks this has helped a lot.
@moshk6460
@moshk6460 2 жыл бұрын
hey, why I get this error: serial.serialutil.SerialException: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)
@lazarocamargo
@lazarocamargo 4 жыл бұрын
Excellent tutorial!
@prasadvaidya9563
@prasadvaidya9563 3 жыл бұрын
I’m setting the timeout to 2 while creating the serial object. When I’m reading from serial port I’m checking wether data is present in input buffer by : if(obj.inWaiting>0) : If the data packets are interrupted it hangs in there.... I have given timeout value as 2 still it’s waiting indefinitely... why it’s not considering timeout value????
@idealzone3652
@idealzone3652 4 жыл бұрын
Amazing work
@rverm1000
@rverm1000 5 жыл бұрын
how do you set it up?
@CN-kc3em
@CN-kc3em 5 жыл бұрын
How to communication by Usb?
@SimoneIovane
@SimoneIovane 4 жыл бұрын
SerialException: could not open port 'COM3': PermissionError. Why?
@user-yj8kq3me8f
@user-yj8kq3me8f 5 жыл бұрын
Thanks, very good video.
@thisunnishama4285
@thisunnishama4285 4 жыл бұрын
Hello!....what if i need my python program to give instructions to arduino to do something(like....switch on a specific LED?)
@JNouveau
@JNouveau 3 жыл бұрын
is it possible to replace the integer with string?
@razinrafiqrinuddin1373
@razinrafiqrinuddin1373 Жыл бұрын
how about receiving from python and reading it on arduino?
@controlautomation6875
@controlautomation6875 5 жыл бұрын
Hi Good tutorial !!! Please how we can making python send a float or int data to arduino and arduino get it (not str only )???
@eliredpower9633
@eliredpower9633 2 жыл бұрын
I love you bro
@gebrehiwotmengistu1590
@gebrehiwotmengistu1590 6 жыл бұрын
This is Great! Thank you
@lakshagajyothi258
@lakshagajyothi258 3 жыл бұрын
Hi sir, Is it possible to get the digital inputs and print them as the output using println?
@mayanmaster92
@mayanmaster92 5 жыл бұрын
What if the arduino puts out strings and not bytes? Is there a way to get python to output those strings?
@rverm1000
@rverm1000 5 жыл бұрын
so good and simple. Can you send me more info?
@waleedaiad3411
@waleedaiad3411 2 жыл бұрын
How can i use hc-12 with arduino using python language?.
@afettouchemassinissa9149
@afettouchemassinissa9149 5 жыл бұрын
hello, thanks for the video : good explanation , but for me when I execute the code it returns to me an error : No module named 'serial' ;;;; what should I do
@thomasmarques8040
@thomasmarques8040 5 жыл бұрын
Hi, that was three months ago. Did you find the solution? I have the same error.
@sarthakdas815
@sarthakdas815 5 жыл бұрын
I solved it py pip install pyserial and use a conda environment
@sarthakdas815
@sarthakdas815 5 жыл бұрын
@@thomasmarques8040 I solved it py pip install pyserial and use a conda environment
@123hihoo
@123hihoo 4 жыл бұрын
KING!
@TheCarloszoom3000
@TheCarloszoom3000 5 жыл бұрын
Hi, I'm getting the following error: AttributeError: module 'serial' has no attribute 'Serial' The libraries serial and py serial are already installed. Could it be that you have Python 2.7 and i have 3.7. If so, how different would the code be? Regards,
@sarthakdas815
@sarthakdas815 5 жыл бұрын
yep getting the same error
@sarthakdas815
@sarthakdas815 5 жыл бұрын
I solved it py pip install pyserial and use a conda environment
@chinmaykulkarni7835
@chinmaykulkarni7835 4 жыл бұрын
Can you explain why we declared ser for serial.Serial()
@EunchanPark
@EunchanPark 6 жыл бұрын
it is a cool video! Thank you
@youtuberzp6665
@youtuberzp6665 4 жыл бұрын
when i try to run the code in python 3.7 idle why it is showing invalid syntax?
@fernandohood5542
@fernandohood5542 4 жыл бұрын
what about parity ,stop bit and number of bits?
@banditboy6444
@banditboy6444 4 жыл бұрын
Have my thumbs up!
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
You rock!
@ashabgaming8205
@ashabgaming8205 4 жыл бұрын
THX MAN IT WAS VERY HELPFUL!!! You goa like frome me!👍
@shaider1982
@shaider1982 4 жыл бұрын
Hi there. Will this also work if the python runs from a raspberry pi? Tnx.
@johnger
@johnger 3 жыл бұрын
Hello, I need make file pdf or excel with information of Serial
@lubanmahfuz8271
@lubanmahfuz8271 3 жыл бұрын
Sir I got error permission Denied problem
@DurgeshKumar-ui6jq
@DurgeshKumar-ui6jq 4 жыл бұрын
I am getting the data from python , but there is significant gap can you help you that. Thanks in advance :)
@emreakman5007
@emreakman5007 5 жыл бұрын
Thank you much
@edwintoapanta1975
@edwintoapanta1975 4 жыл бұрын
hi how can i send an excel file from the pc to the arduino
@joshuacanlas4679
@joshuacanlas4679 4 жыл бұрын
great video. May I know the version of python that you are using there and the pyserial. Thanks.
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
The version of Python was 3.7.
@emresagr8593
@emresagr8593 3 жыл бұрын
If you're getting this error: arduinoData = ser.readline().decode() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfe in position 0: invalid start byte I found out first byte that coming from arduino is can't convert with decode, so i added a loop like this ; for _ in range (0,2): arduinoData = ser.readline() i am taking first two value and don't use them and added while loop right after this loop. Full code: import serial ser = serial.Serial("COM3", baudrate = 9600, timeout=1) for _ in range (0,2): #It's giving an error for first byte so with this loop we eliminate first two byte. arduinoData = ser.readline() while 1: arduinoData = ser.readline().decode() arduinoData = int(arduinoData) arduinoData = (arduinoData/1024)*5 print(arduinoData) Ps. Yep, my bad that i don't read the error but I have searched this problem for one our and couldn't find anything :')
@idealzone3652
@idealzone3652 4 жыл бұрын
Thankyou
@darminaxel5809
@darminaxel5809 5 жыл бұрын
Is pit possible to print this to a webpage with cgi/python?
@paulo.galvao
@paulo.galvao 5 жыл бұрын
arduinoString = arduinoData.readline().decode("utf-8") #read the line of text from the serial port dataArray = arduinoString.split(',') #Split it into an array called dataArray may be more easy... github.com/labF212/pyhton-arduino/blob/master/test2serial3.py
@leonhs1476
@leonhs1476 3 жыл бұрын
I get an error that says No module named 'serial'
@WaveShapePlay
@WaveShapePlay 3 жыл бұрын
Hello - Did you download the pySerial model from the pySerial website? This is not a built-in module, it is from a 3rd party.
@kunalgoyal9866
@kunalgoyal9866 4 жыл бұрын
Please can anyone tell how to compare this arduinodata to integer value please!!!!
@shaneebkottakkal3491
@shaneebkottakkal3491 4 жыл бұрын
Can we upload python code into arduino
@idus
@idus 6 ай бұрын
its not ardreno Thanks for the video.
@acy1335
@acy1335 4 жыл бұрын
Where do I write this code in?
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
You can write the python code in IDLE, which is the default Integrated Development Environment (IDE) for Python. For Arduino I would recommend downloading the IDE from their website.
@rverm1000
@rverm1000 5 жыл бұрын
do you have a link to import serial?
@charlesklein7232
@charlesklein7232 5 жыл бұрын
im confused? clearly, your audience is more educated then me. im interested in how to do what you are talking about doing using arduino with "PYSERIAL" which is a program. in order to use python you need a program to run it. two are "ATOM" and "PYCHARM" however their is something called "PYSERIAL" would you consider doing a video on how to get these programs to work, how to install them! im running Ubuntu 16.04 on 64 bit and i have "pIP" but am confused about what to download from pyserial. sorry for my "BABBLING," clearly, im confused. it appears your are doing this manually probably using an "idle" notepad that comes with python.
@WaveShapePlay
@WaveShapePlay 5 жыл бұрын
Hey Charles! Pyserial is a 'module'. A module is code that someone wrote, for the purpose of re-use. We can utilize modules that are already created, so we do not start our programs from scratch. PYCHARM is an integrated development environment (IDE). The IDE allows us to write programs and run them. We use a combination of our own code and existing modules to create a program, then run the program in the IDE.
@dawkos8631
@dawkos8631 4 жыл бұрын
error: module 'serial' has no attribute 'Serial' wtf
@dawkos8631
@dawkos8631 4 жыл бұрын
I find out, i installed "pip install serial", instead "pip install pyserial" :D
@WaveShapePlay
@WaveShapePlay 4 жыл бұрын
Very good! Yup, pip is great but we have to be accurate!
@NguyenDat-sn2pb
@NguyenDat-sn2pb 5 жыл бұрын
how to convert it to int , when i use int(arduinoData) it call the error :: invalid literal for int() with base 10: ''
@kevindrouglazet2379
@kevindrouglazet2379 5 жыл бұрын
I might be wrong but since the incoming information are bytes, I would assume that you need to use int.from_bytes() to convert the data from bytes to int .
@NguyenDat-sn2pb
@NguyenDat-sn2pb 5 жыл бұрын
@@kevindrouglazet2379 thank you , i will try your code
@NEGOX47
@NEGOX47 4 жыл бұрын
Nguyen Dat worked?
@muhajirikhsanushabri9644
@muhajirikhsanushabri9644 5 жыл бұрын
what version of your python?
@user-oz1xu8es3q
@user-oz1xu8es3q 5 жыл бұрын
i thing its python 3
@qvd3533
@qvd3533 5 жыл бұрын
3.5.1 you can see it at the top of the screen
@oscara.quirozbarrera7312
@oscara.quirozbarrera7312 5 жыл бұрын
WHY? UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)
@Alfayeeed
@Alfayeeed 5 жыл бұрын
i got the same errror. Any luck solving it?
@oscara.quirozbarrera7312
@oscara.quirozbarrera7312 5 жыл бұрын
@@Alfayeeed I am trying with pyfirmata, so far is the best option.
@oscara.quirozbarrera7312
@oscara.quirozbarrera7312 5 жыл бұрын
@@Alfayeeed try this: from pyfirmata import Arduino placa=Arduino('COM4') print("vamos a entrar al for") for i in range(12): placa.digital[13].write(1) placa.pass_time(3) placa.digital[13].write(0) placa.pass_time(1.5) print("primera conexion real",i)
@tarunkashyap8515
@tarunkashyap8515 5 жыл бұрын
try this: arData = arData.decode('ISO-8859-1')
@dennisyildirim2708
@dennisyildirim2708 4 жыл бұрын
Can I read data from this device; au.element14.com/amphenol-advanced-sensors/sm-uart-04l/ir-laser-dust-sensor-97ac8394/dp/3021584 By only using my computer, and python ? Without Arduino....
I tried the Cheapest Arduino Alternative (that Nobody heard of)
13:31
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 8 МЛН
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 14 МЛН
Joker can't swim!#joker #shorts
00:46
Untitled Joker
Рет қаралды 41 МЛН
Making Animations in Python using Matplotlib!
22:05
Younes Lab
Рет қаралды 10 М.
Use PyVISA to Program Test Tools with Python - Workbench Wednesdays
13:35
element14 presents
Рет қаралды 36 М.
6 Horribly Common PCB Design Mistakes
10:40
Predictable Designs
Рет қаралды 191 М.
PROTOCOLS: UART - I2C - SPI - Serial communications #001
11:58
Electronoobs
Рет қаралды 1,4 МЛН
Try these 16 Brilliant ESP32 projects!!!
11:18
ToP Projects Compilation
Рет қаралды 570 М.
Python Serial Port Commuincation
16:13
Amit Dhanawade
Рет қаралды 42 М.
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 8 МЛН