Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removing hidden files

  • Loading branch information...
commit 09634535818e7827c57bd551df26df5e39292f2b 1 parent c77c88e
@abhinavgupta authored
View
23 Xbee-Live-Plots (No Arduino needed)/README~
@@ -1,23 +0,0 @@
-
-TempSensor
-----------
-This is a simple live plotting code for XBee. The hardware setup includes two XBees and a temp sensor connected to the end device's ADC. NO ARDUINOS OR OTHER CONTROLLERS
-
-The transmission although AT in nature, the data packets are in the API I/O frame format. We use the xbee-python library for ease in the data parsing.
-
-Source for xbee-python : http://code.google.com/p/python-xbee/
-
-Using monitor.py, a client computer with the other XBee connected can plot the temperature data transmitted by the Router AT wirelessly.
-
-You need:
- - PyQt
- - PyQwt
- - PySerial
-
-Python modules for this to work correctly.
-
-Note that the serial port is hardcoded in SerialMonitor.py, change it to fit your needs. (USE: 'dmesg|tail' on Linux to know what the serial port is, just after connecting your XBee device). Other things hardcoded in this file is the conversion of ADC data to temperature value using a Look Up Table. The temperature measurement in query is a thermistor hence the setup. If you have a LM35 you just need to map the voltage to the temperature value instead of going through the entire process. I have marked the part which is special to my need in the code.
-
-The Plotter application is a simplified/modified version of Eli Bendersky's
-plotter:
- http://eli.thegreenplace.net/2009/08/07/a-live-data-monitor-with-python-pyqt-and-pyserial/
View
76 Xbee-Live-Plots (No Arduino needed)/SerialMonitor.py~
@@ -1,76 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-import time
-import Queue
-import threading
-from xbee import XBee
-import serial
-import dict_lut
-
-ADC_RESOLUTION = 1024.00
-RESISTANCE = 47.00
-
-class SerialMonitorThread(threading.Thread):
- """ A thread for monitoring a serial port. The serial port is
- opened when the thread is started.
-
- data_q:
- Queue for received data. Items in the queue are
- (data, timestamp) pairs, where data is a binary
- string representing the received data, and timestamp
- is the time elapsed from the thread's start (in
- seconds).
-
- error_q:
- Queue for error messages. In particular, if the
- serial port fails to open for some reason, an error
- is placed into this queue.
- """
- def __init__(self, data_q, error_q):
- threading.Thread.__init__(self)
-
- self.serial_port = None
- self.data_q = data_q
- self.error_q = error_q
-
- self.alive = threading.Event()
- self.alive.set()
-
- def run(self):
- try:
- if self.serial_port:
- self.serial_port.close()
- # Port hardcoded :)
- self.serial_port = serial.Serial("/dev/ttyACM0", 9600)
- except serial.SerialException, e:
- self.error_q.put(e.message)
- return
-
- # Restart the clock
- time.clock()
-
- while self.alive.isSet():
- # Reading 1 byte, followed by whatever is left in the
- # read buffer, as suggested by the developer of
- # PySerial.
- #
- xbee = XBee(self.serial_port)
- # data = self.serial_port.next()
- response = xbee.wait_read_frame()
- sample = response['samples'][0]
- adc_value = sample['adc-0']
- temp_value = ADC_RESOLUTION/adc_value -1
- thermistor_value = RESISTANCE/temp_value
- temperature_value = dict_lut.closest_match(thermistor_value)
- timestamp = time.clock()
- self.data_q.put((temperature_value, timestamp))
-
- # clean up
- if self.serial_port:
- self.serial_port.close()
-
- def join(self, timeout=None):
- self.alive.clear()
- threading.Thread.join(self, timeout)
-
Please sign in to comment.
Something went wrong with that request. Please try again.