Arduino and Python Serial Communication with PySerial Part 3 - Initialization Error Handling

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to part three of my video series on how we can interface Arduino and Python via PI serial in this video we're going to focus on air handling when we establish the serial connection I noticed when I launched the program and quickly requested a data point I'd missed the first one but the points following it would be valid this is unexpected and unusual behavior thinking back to the code in the serial serial function there's a timeout parameter and this is what was executed and explains why we missed a data point we waited a second and then returned nothing this is actually a good thing serial serial resets the arduino upon being called it establishes the serial communication port and the baud rate so to request a point we need to make sure that the arduino is fully up and running before we ask for one to demonstrate the usefulness of the timeout parameter and serial serial we can comment it out removing it from execution I'll run the code and quickly request a data point now we're stuck waiting indefinitely because there's no time out the timeout parameter is unlimited seconds if you don't specify one way to easily see how long it takes for the Arduino to become initialize is to view the l LED on the board by default this tells you how long it takes for the board to initialize in the sketch to be uploaded let's take a look at it in real time slowing it down we can see that it blinks a few times goes low and then goes high and once the LED is high we're ready to collect our data point the takeaway here is that before we can request data points we have to allow the Arduino to initialize a remedy to this issue is to add a fixed time delay before we can request data points to add this functionality in we simply need to use the time module so we'll import it we need to put the time delay in before the user is allowed to ask for a data point will use time dot sleep we can add a time delay of 3 seconds just to be safe this is one very quick and easy way to make sure we allow the Arduino board to initialize fully before requesting data points thank you for watching and stay tuned for future content I'll put the links to the previous tutorials in this video as well if you missed anything
Info
Channel: WaveShapePlay
Views: 35,346
Rating: undefined out of 5
Keywords: arduino, python, pyserial, serial communication
Id: msBWSDbEw2o
Channel Id: undefined
Length: 3min 3sec (183 seconds)
Published: Sun Dec 04 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.