Hi again,
think I spotted the problem now:
you’re setting up your connection everytime you enter the function (with the
serial.Serial call), but I guess you’re calling that function repeatedly to
retrieve lines. That’s wrong and means you could loose data that was sent
while you weren’t listening.
You’ll have to open the connection once outside the sensorRead() function,
then pass it the arduino object like this:

def sensorRead (arduino):
    line = arduino.readline().strip()
    line = line.lstrip('{').rstrip('}').strip()
    # rest of your code

# your main program:
arduino = serial.Serial('/dev/ttyACM0', 9600)
sleep(1)
while True:
    reads = sensorRead(arduino)
    # do something with the data

Hope that helps,
Wolfgang


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to