Difference between revisions of "TemperatureHumidity"

From TSG Doc
Jump to: navigation, search
Line 21: Line 21:
  
 
<code>
 
<code>
#!/usr/bin/env python
+
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+
# -*- coding: utf-8 -*-
import temperaturehumidity
+
import temperaturehumidity
th = temperaturehumidity.TemperatureHumidity()
+
th = temperaturehumidity.TemperatureHumidity()
print(th.waitString())
+
print(th.waitString())
 
</code>
 
</code>

Revision as of 14:17, 18 January 2016

TemperatureHumidity
Downloads

The TemperatureHumidity is a little (15 x 5 x 5 cm) black box with a black sphere on top. It is connected to your computer with the attached USB cable. When connected it will identify itself as a Virtual Serial port.

Installation

Install the rusocsci package. On the lab computers it is already installed for you. Download the temperaturehumidity module and unzip it in the same directory as your experiment.

Testing

Run the temperaturehumidity module and sensor by running the file 'temperaturehumidity.py'. Double click it in explorer or load in the Psychopy Coder and click 'run'.

Code example

You can read temperature and humidity values with any software that connects to a serial port. Most conveniently you can use the RuSocSci library in python. Here is a little example how to write a script that reads the temperature and humidity and writes it to the standard output (console):

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import temperaturehumidity
th = temperaturehumidity.TemperatureHumidity()
print(th.waitString())