From 1985c99fbd608bfb63b9ee21c0e6e05a6d0a8ee4 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Mon, 8 Dec 2014 16:35:55 -0500 Subject: [PATCH] Initial commit. --- README | 1 + temp_log.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 README create mode 100755 temp_log.py diff --git a/README b/README new file mode 100644 index 0000000..071b03d --- /dev/null +++ b/README @@ -0,0 +1 @@ +Interface for the arduino temperature logger. It is meant to be run on a machine connected to the arduino. diff --git a/temp_log.py b/temp_log.py new file mode 100755 index 0000000..45f2845 --- /dev/null +++ b/temp_log.py @@ -0,0 +1,21 @@ +#! /usr/bin/env python +import serial, sys, time, io +serialPort = '/dev/ttyACM0' +try: + serialPort = sys.argv[1] +except Exception, e: + pass +ser = serial.Serial(port=serialPort, baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) +sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) +ser.isOpen() +buffer = '' +while True: + try: + buffer = ser.readline() + buffer_split = buffer.split(' ') + temp = float(buffer_split[-2]) + print unicode(time.time()) + ',' + unicode(temp) + sys.stdout.flush() + except Exception, e: + sys.stderr.write(str(e) + '\n') + continue