# # Example program for d5000_serial module # Eli Fulkerson # import d5000_serial def main(): print "Watch Temperature" print "-----------------" print "Connect to thermocouple on COM1 and take continuous readings," print "reporting any changes to the console." print "-----------------" print "Starting Example... press control-c to exit" # our sensor is plugged into COM1 at 9600 baud... other options are specifiable if needed # 0 is COM1, 1 is COM2, etc etc etc. On unix 0 would be /dev/sd0 (I think), 1 would be /dev/sd1 etc... sensor = d5000_serial.sensor("-p 0 -r 9600") # our module is at address #1 module = d5000_serial.module(sensor, 1) min = 1000 # minimum temperature sensed so far max = 0 # maximum temperature sensed so far last = 0 # second-to-most-recent reading # run forever, use control-c to break out while 1: # because we specified address 1, this is equivalent to $RD1 data = module.sendcmd("RD") # turn the ugly string that we were returned into a floating point number current = d5000_serial.to_float(data) if current < min: min = current if current > max: max = current if current > last: direction = "UP....." else: direction = "DOWN..." if not last == current: print "Temperature " + direction + " current - " + str(current) + " min - " + str(min) + " max - " + str(max) last = current main()