Pylab and pyserial plot in real time

googlinggoogler at hotmail.com googlinggoogler at hotmail.com
Sun Nov 6 07:01:49 EST 2005


Hiya,

I've got a PIC microcontroller reading me humidity data via rs232, this
is in ASCII format. I can view this data easily using hyperterminal or
pyserial and convert it to its value (relative humidty with ord(input))

But what im trying to do is plot the data in real time, ideally with
pylab - as it looks simple to use and simple is the way i want to go!

My code is below, it doesnt show a graph, I was wondering whether
someone could suggest whats wrong?

thank you in advance

David

########################################################################

import serial
from pylab import *

ser = serial.Serial(0)
t = arange(0.0, 1.0+0.01, 0.01)

xlabel('time')
ylabel('RH %')
title(' RH sensor data sampled at 1 sec intervals ')
#grid(true)

x = 0

while 1:
	s = ser.read()
	b = ord(s)
	h = []
	h.append(b)
	x = x + 1
	plot(t,h)

ser.close

########################################################################




More information about the Python-list mailing list