Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Say I have the following python script to read in serial data from my Arduino:

import serial

ser = serial.Serial("dev/ttyACM1", 9600)
ser.timeout = 2

On the other end I've flashed my Arduino with a program that sends 20 voltage readings every 0.5 seconds. The Arduino starts sending those readings from the moment it's hooked up, then after 20 seconds it stops and sends nothing.

Now what I've noticed is that I can read those 20 voltage values using the first script whenever I want. That is, I can hook up the Arduino, wait a couple of minutes then read in the values. This makes me think that the data is getting stored somewhere. I'm inclined to think that it's not being stored on the Arduino but on my laptop somewhere.

I've come up with a few questions that I hope the community could help me with:

  1. Where is PySerial getting the data from?
  2. For how long is the data stored in this place?
  3. Is there a way to clear this space before reading in values?
  4. How much storage space is there?
  5. When you set the baud rate in PySerial (second line in script), is this the rate that PySerial reads data from the storage area (not the Arduino)?
  6. I've noticed that if I set the baud rate in PySerial too high the first few lines of data are fragmented and sometimes completely wrong, why?
  7. Not exactly related but when you set serial.Serial.timeout are the units in seconds?

I appreciate your time.

share|improve this question

closed as off-topic by Leon Heller, Daniel Grillo, Matt Young, Chetan Bhargava, Nick Alexeev Feb 17 at 18:30

  • This question does not appear to be about electronics design within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Maybe a better fit for Linux&Unix.SE. –  Vorac Feb 17 at 12:31
This question appears to be off-topic because it is not about electronic design. –  Leon Heller Feb 17 at 12:57
For what it's worth your Arduino is probably resetting when you open the serial port. –  Dan Nixon Jul 17 at 21:24